mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 18:34:55 +08:00
Update exp to sql
This commit is contained in:
@@ -507,7 +507,11 @@ namespace SqlSugar
|
|||||||
if (property.PropertyType.IsClass())
|
if (property.PropertyType.IsClass())
|
||||||
{
|
{
|
||||||
var comumnInfo=property.GetCustomAttribute<SugarColumn>();
|
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);
|
asName = GetAsName(item, shortName, property);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -408,7 +408,16 @@ namespace SqlSugar
|
|||||||
var suagrColumn=prop.GetCustomAttribute<SugarColumn>();
|
var suagrColumn=prop.GetCustomAttribute<SugarColumn>();
|
||||||
if (suagrColumn != null && suagrColumn.IsJson)
|
if (suagrColumn != null && suagrColumn.IsJson)
|
||||||
{
|
{
|
||||||
Json(readerValues, result, name, typeName);
|
|
||||||
|
if (mappingKeys!=null&&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))
|
else if (columns.Any(it => it.IsJson))
|
||||||
{
|
{
|
||||||
@@ -457,31 +466,42 @@ namespace SqlSugar
|
|||||||
return result;
|
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();
|
var key = (typeName + "." + name).ToLower();
|
||||||
if (readerValues.Any(it => it.Key.EqualCase(key)))
|
if (readerValues.Any(it => it.Key.EqualCase(key)))
|
||||||
{
|
{
|
||||||
var jsonString = readerValues.First(it => it.Key.EqualCase(key)).Value;
|
var jsonString = readerValues.First(it => it.Key.EqualCase(key)).Value;
|
||||||
if (jsonString != null)
|
AddJson(result, name, jsonString);
|
||||||
{
|
|
||||||
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 + ""));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
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
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user