mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update exp to sql
This commit is contained in:
parent
741a63fa5f
commit
2da4ece3c9
@ -507,7 +507,11 @@ namespace SqlSugar
|
||||
if (property.PropertyType.IsClass())
|
||||
{
|
||||
var comumnInfo=property.GetCustomAttribute<SugarColumn>();
|
||||
if (comumnInfo != null && comumnInfo.IsJson)
|
||||
if (comumnInfo != null && comumnInfo.IsJson && isSameType)
|
||||
{
|
||||
asName = GetAsNameAndShortName(item, shortName, property);
|
||||
}
|
||||
else if(comumnInfo != null && comumnInfo.IsJson)
|
||||
{
|
||||
asName = GetAsName(item, shortName, property);
|
||||
}
|
||||
|
@ -408,7 +408,16 @@ namespace SqlSugar
|
||||
var suagrColumn=prop.GetCustomAttribute<SugarColumn>();
|
||||
if (suagrColumn != null && suagrColumn.IsJson)
|
||||
{
|
||||
Json(readerValues, result, name, typeName);
|
||||
|
||||
if (mappingKeys.ContainsKey(item.Name))
|
||||
{
|
||||
var key = mappingKeys[item.Name];
|
||||
Json(readerValues, result, name, typeName,key);
|
||||
}
|
||||
else
|
||||
{
|
||||
Json(readerValues, result, name, typeName);
|
||||
}
|
||||
}
|
||||
else if (columns.Any(it => it.IsJson))
|
||||
{
|
||||
@ -457,31 +466,42 @@ namespace SqlSugar
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Json(Dictionary<string, object> readerValues, Dictionary<string, object> result, string name, string typeName)
|
||||
private void Json(Dictionary<string, object> readerValues, Dictionary<string, object> result, string name, string typeName,string shortName=null)
|
||||
{
|
||||
var key = (typeName + "." + name).ToLower();
|
||||
if (readerValues.Any(it => it.Key.EqualCase(key)))
|
||||
{
|
||||
var jsonString = readerValues.First(it => it.Key.EqualCase(key)).Value;
|
||||
if (jsonString != null)
|
||||
{
|
||||
if (jsonString.ToString().First() == '{' && jsonString.ToString().Last() == '}')
|
||||
{
|
||||
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
|
||||
{
|
||||
result.Add(name, this.DeserializeObject<List<Dictionary<string, object>>>(jsonString + ""));
|
||||
|
||||
}
|
||||
}
|
||||
AddJson(result, name, jsonString);
|
||||
}
|
||||
else
|
||||
{
|
||||
key = (shortName+"."+typeName + "." + name).ToLower();
|
||||
if (readerValues.Any(it => it.Key.EqualCase(key)))
|
||||
{
|
||||
var jsonString = readerValues.First(it => it.Key.EqualCase(key)).Value;
|
||||
AddJson(result, name, jsonString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void AddJson(Dictionary<string, object> result, string name, object jsonString)
|
||||
{
|
||||
if (jsonString != null)
|
||||
{
|
||||
if (jsonString.ToString().First() == '{' && jsonString.ToString().Last() == '}')
|
||||
{
|
||||
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
|
||||
{
|
||||
result.Add(name, this.DeserializeObject<List<Dictionary<string, object>>>(jsonString + ""));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
Loading…
Reference in New Issue
Block a user