Browse Source

Update Select Json Bug

pull/1/head
skx 4 years ago
parent
commit
f2adb90d43
  1. 11
      Src/Asp.Net/PgSqlTest/Bugs/BugTest5.cs
  2. 6
      Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs
  3. 14
      Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs

11
Src/Asp.Net/PgSqlTest/Bugs/BugTest5.cs

@ -100,13 +100,11 @@ namespace OrmTest.Test
});
db.Aop.OnError = (exp) =>//SQL报错
db.Aop.OnLogExecuted = (s,p) =>//SQL报错
{
string sql = exp.Sql;
//exp.sql 这样可以拿到错误SQL
Console.WriteLine(s);
};
@ -154,9 +152,8 @@ namespace OrmTest.Test
{
User = a,
Items = a.UserDpt
User = a ,
de=a.UserDpt
}).ToList();

6
Src/Asp.Net/SqlSugar/ExpressionsToSql/ResolveItems/BaseResolve.cs

@ -438,7 +438,11 @@ namespace SqlSugar
}
if (property.PropertyType.IsClass())
{
var comumnInfo=property.GetCustomAttribute<SugarColumn>();
if (comumnInfo != null && comumnInfo.IsJson)
{
asName = GetAsName(item, shortName, property);
}
}
else
{

14
Src/Asp.Net/SqlSugar/Infrastructure/ContextMethods.cs

@ -373,7 +373,19 @@ namespace SqlSugar
var typeName = type.Name;
if (prop.PropertyType.IsClass())
{
result.Add(name, DataReaderToDynamicList_Part(readerValues, prop, reval));
var suagrColumn=prop.GetCustomAttribute<SugarColumn>();
if (suagrColumn != null && suagrColumn.IsJson)
{
var key = (typeName + "." + name).ToLower();
if (readerValues.ContainsKey(key)&& readerValues[key]!=null)
{
result.Add(name,this.DeserializeObject<List<Dictionary<string,object>>>(readerValues[key]+""));
}
}
else
{
result.Add(name, DataReaderToDynamicList_Part(readerValues, prop, reval));
}
}
else
{

Loading…
Cancel
Save