Browse Source

Update Select Json Bug

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

9
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);
};
@ -155,8 +153,7 @@ namespace OrmTest.Test
{
User = a ,
Items = a.UserDpt
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
{

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

@ -372,9 +372,21 @@ namespace SqlSugar
var name = prop.Name;
var typeName = type.Name;
if (prop.PropertyType.IsClass())
{
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
{
var key = typeName + "." + name;

Loading…
Cancel
Save