mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 18:22:23 +08:00
Queryable.Select json array bug
This commit is contained in:
@@ -94,6 +94,7 @@
|
|||||||
<Compile Include="Models\OrderItem.cs" />
|
<Compile Include="Models\OrderItem.cs" />
|
||||||
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
<Compile Include="Demo\Demo0_SqlSugarClient.cs" />
|
||||||
<Compile Include="Models\ViewOrder.cs" />
|
<Compile Include="Models\ViewOrder.cs" />
|
||||||
|
<Compile Include="UnitTest\Models\TestModel.cs" />
|
||||||
<Compile Include="UnitTest\UCustom01.cs" />
|
<Compile Include="UnitTest\UCustom01.cs" />
|
||||||
<Compile Include="UnitTest\UCustom02.cs" />
|
<Compile Include="UnitTest\UCustom02.cs" />
|
||||||
<Compile Include="UnitTest\UCustom03.cs" />
|
<Compile Include="UnitTest\UCustom03.cs" />
|
||||||
|
24
Src/Asp.Net/SqlServerTest/UnitTest/Models/TestModel.cs
Normal file
24
Src/Asp.Net/SqlServerTest/UnitTest/Models/TestModel.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugarSelect
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarTable("UnitTestModel1")]
|
||||||
|
public class TestModel1
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Titlt { get; set; }
|
||||||
|
[SqlSugar.SugarColumn(ColumnDataType = "ntext", IsJson = true)]
|
||||||
|
public Guid[] Ids { get; set; }
|
||||||
|
}
|
||||||
|
[SqlSugar.SugarTable("UnitTestModel2")]
|
||||||
|
public class TestModel2
|
||||||
|
{
|
||||||
|
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int Pid { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -34,6 +34,30 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
throw new Exception("unit error");
|
throw new Exception("unit error");
|
||||||
}
|
}
|
||||||
|
var db = Db;
|
||||||
|
db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(SqlSugarSelect.TestModel1));
|
||||||
|
db.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(SqlSugarSelect.TestModel2));
|
||||||
|
|
||||||
|
#region 加入数据
|
||||||
|
var isadd = !db.Queryable<TestModel1>().Any();
|
||||||
|
if (isadd)
|
||||||
|
{
|
||||||
|
db.Insertable(new SqlSugarSelect.TestModel1
|
||||||
|
{
|
||||||
|
Ids = new Guid []{ Guid.NewGuid() },
|
||||||
|
Titlt = "123"
|
||||||
|
}).ExecuteCommand();
|
||||||
|
db.Insertable(new SqlSugarSelect.TestModel2
|
||||||
|
{
|
||||||
|
Pid = 1
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
#region 实际搜索代码,Bug所在处
|
||||||
|
var rv = db.Queryable<SqlSugarSelect.TestModel2>()
|
||||||
|
.LeftJoin<SqlSugarSelect.TestModel1>((a, b) => a.Pid == b.Id)
|
||||||
|
.Select((a, b) => new { a, b }).ToList();
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -412,6 +412,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
result.Add(name, this.DeserializeObject<Dictionary<string, object>>(jsonString + ""));
|
result.Add(name, this.DeserializeObject<Dictionary<string, object>>(jsonString + ""));
|
||||||
}
|
}
|
||||||
|
else if (jsonString.ToString().Replace(" ","")!="[]"&&!jsonString.ToString().Contains("{")&&!jsonString.ToString().Contains("}"))
|
||||||
|
{
|
||||||
|
result.Add(name, this.DeserializeObject<dynamic>(jsonString + ""));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result.Add(name, this.DeserializeObject<List<Dictionary<string, object>>>(jsonString + ""));
|
result.Add(name, this.DeserializeObject<List<Dictionary<string, object>>>(jsonString + ""));
|
||||||
|
Reference in New Issue
Block a user