mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-24 16:18:47 +08:00
Update Core
This commit is contained in:
parent
f7dda4401d
commit
61b895b896
@ -472,6 +472,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
asName = GetAsName(item, shortName, property);
|
asName = GetAsName(item, shortName, property);
|
||||||
}
|
}
|
||||||
|
else if (comumnInfo!=null&&this.Context.SugarContext != null&&this.Context.SugarContext.Context != null)
|
||||||
|
{
|
||||||
|
var entityInfo=this.Context.SugarContext.Context.EntityMaintenance.GetEntityInfo(item.Type);
|
||||||
|
var entityColumn = entityInfo.Columns.FirstOrDefault(it => it.PropertyName == property.Name);
|
||||||
|
if (entityColumn != null && entityColumn.IsJson)
|
||||||
|
{
|
||||||
|
asName = GetAsName(item, shortName, property);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (isSameType)
|
else if (isSameType)
|
||||||
{
|
{
|
||||||
|
@ -30,8 +30,15 @@ namespace SqlSugar
|
|||||||
var operatorValue = parameter.OperatorValue = ExpressionTool.GetOperator(expression.NodeType);
|
var operatorValue = parameter.OperatorValue = ExpressionTool.GetOperator(expression.NodeType);
|
||||||
|
|
||||||
if (IsGroupSubquery(expression.Right,operatorValue))
|
if (IsGroupSubquery(expression.Right,operatorValue))
|
||||||
|
{
|
||||||
|
if (ExpressionTool.IsUnConvertExpress(expression.Right))
|
||||||
|
{
|
||||||
|
InSubGroupByConvertExpress(expression);
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
InSubGroupBy(expression);
|
InSubGroupBy(expression);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +105,24 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void InSubGroupByConvertExpress(BinaryExpression expression)
|
||||||
|
{
|
||||||
|
var leftSql = GetNewExpressionValue(expression.Left);
|
||||||
|
var rightExpression = (expression.Right as UnaryExpression).Operand as MethodCallExpression;
|
||||||
|
var selector = GetNewExpressionValue(rightExpression.Arguments[0]);
|
||||||
|
var rightSql = GetNewExpressionValue(rightExpression.Object).Replace("SELECT FROM", $"SELECT {selector} FROM");
|
||||||
|
if (this.Context.IsSingle && this.Context.SingleTableNameSubqueryShortName == null)
|
||||||
|
{
|
||||||
|
var leftExp = expression.Left;
|
||||||
|
if (leftExp is UnaryExpression)
|
||||||
|
{
|
||||||
|
leftExp = (leftExp as UnaryExpression).Operand;
|
||||||
|
}
|
||||||
|
var p = (leftExp as MemberExpression);
|
||||||
|
this.Context.SingleTableNameSubqueryShortName = p.Expression.ToString();
|
||||||
|
}
|
||||||
|
base.Context.Result.Append($" {leftSql} in ({rightSql}) ");
|
||||||
|
}
|
||||||
private void InSubGroupBy(BinaryExpression expression)
|
private void InSubGroupBy(BinaryExpression expression)
|
||||||
{
|
{
|
||||||
var leftSql = GetNewExpressionValue(expression.Left);
|
var leftSql = GetNewExpressionValue(expression.Left);
|
||||||
@ -128,6 +152,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (ExpressionTool.IsUnConvertExpress(rightExpression))
|
||||||
|
{
|
||||||
|
rightExpression = (rightExpression as UnaryExpression).Operand;
|
||||||
|
}
|
||||||
if ((rightExpression is MethodCallExpression) == false)
|
if ((rightExpression is MethodCallExpression) == false)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -46,7 +46,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var meExp = expArgs[0] as LambdaExpression;
|
var meExp = expArgs[0] as LambdaExpression;
|
||||||
var selfParameterName = meExp.Parameters.First().Name;
|
var selfParameterName = meExp.Parameters.First().Name;
|
||||||
|
if ((meExp.Body is BinaryExpression))
|
||||||
|
{
|
||||||
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Left as MemberExpression).Expression as ParameterExpression).Name;
|
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Left as MemberExpression).Expression as ParameterExpression).Name;
|
||||||
|
}
|
||||||
if (context.SingleTableNameSubqueryShortName == selfParameterName)
|
if (context.SingleTableNameSubqueryShortName == selfParameterName)
|
||||||
{
|
{
|
||||||
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Right as MemberExpression).Expression as ParameterExpression).Name;
|
context.SingleTableNameSubqueryShortName = (((meExp.Body as BinaryExpression).Right as MemberExpression).Expression as ParameterExpression).Name;
|
||||||
|
@ -394,6 +394,7 @@ namespace SqlSugar
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var classProperties = type.GetProperties().ToList();
|
var classProperties = type.GetProperties().ToList();
|
||||||
|
var columns = this.Context.EntityMaintenance.GetEntityInfo(type).Columns;
|
||||||
foreach (var prop in classProperties)
|
foreach (var prop in classProperties)
|
||||||
{
|
{
|
||||||
var name = prop.Name;
|
var name = prop.Name;
|
||||||
@ -403,29 +404,14 @@ namespace SqlSugar
|
|||||||
var suagrColumn=prop.GetCustomAttribute<SugarColumn>();
|
var suagrColumn=prop.GetCustomAttribute<SugarColumn>();
|
||||||
if (suagrColumn != null && suagrColumn.IsJson)
|
if (suagrColumn != null && suagrColumn.IsJson)
|
||||||
{
|
{
|
||||||
var key = (typeName + "." + name).ToLower();
|
Json(readerValues, result, name, typeName);
|
||||||
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("}"))
|
else if (columns.Any(it => it.IsJson))
|
||||||
{
|
{
|
||||||
result.Add(name, this.DeserializeObject<dynamic>(jsonString + ""));
|
var column = columns.FirstOrDefault(it => it.PropertyName == name);
|
||||||
}
|
if (column != null && column.IsJson)
|
||||||
else
|
|
||||||
{
|
|
||||||
result.Add(name, this.DeserializeObject<List<Dictionary<string, object>>>(jsonString + ""));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
Json(readerValues, result, name, typeName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -462,6 +448,34 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void Json(Dictionary<string, object> readerValues, Dictionary<string, object> result, string name, string typeName)
|
||||||
|
{
|
||||||
|
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 + ""));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Serialize
|
#region Serialize
|
||||||
|
Loading…
Reference in New Issue
Block a user