Browse Source

Synchronization code

pull/40/head
sunkaixuan 1 year ago
parent
commit
7f256b1ad6
  1. 30
      Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs

30
Src/Asp.NetCore2/SqlSugar/ExpressionsToSql/ResolveItems/BinaryExpressionResolve.cs

@ -51,7 +51,7 @@ namespace SqlSugar
{ {
JoinString(parameter, expression); JoinString(parameter, expression);
} }
else if (IsUpdateJson(parameter,expression, operatorValue)) else if (IsUpdateJson(parameter, expression, operatorValue))
{ {
parameter.CommonTempData = "IsJson=true"; parameter.CommonTempData = "IsJson=true";
DefaultBinary(parameter, expression, operatorValue); DefaultBinary(parameter, expression, operatorValue);
@ -63,11 +63,39 @@ namespace SqlSugar
DefaultBinary(parameter, expression, operatorValue); DefaultBinary(parameter, expression, operatorValue);
parameter.CommonTempData = null; parameter.CommonTempData = null;
} }
else if (IsBinaryGroup(operatorValue,expression))
{
var isComparisonOperator = ExpressionTool.IsComparisonOperator(expression);
var getLeft=GetNewExpressionValue(expression.Left);
var getRight = GetNewExpressionValue(expression.Right);
base.Context.Result.Append($"( {getLeft} {operatorValue} {getRight} )");
}
else else
{ {
DefaultBinary(parameter, expression, operatorValue); DefaultBinary(parameter, expression, operatorValue);
} }
} }
private bool IsBinaryGroup(string operatorValue, BinaryExpression expression)
{
var left = ExpressionTool.RemoveConvert(expression.Left);
var right = ExpressionTool.RemoveConvert(expression.Right);
if (operatorValue?.IsIn("AND","OR")==true&&left is BinaryExpression&& right is BinaryExpression)
{
var leftChild = ExpressionTool.RemoveConvert((left as BinaryExpression).Right);
var rightChild = ExpressionTool.RemoveConvert((right as BinaryExpression).Right);
if (ExpressionTool.GetMethodName(leftChild)=="Select"
&& ExpressionTool.GetMethodName(rightChild) == "Select"
&& ExpressionTool.ContainsMethodName(left as BinaryExpression, "Group")
&&ExpressionTool.ContainsMethodName(right as BinaryExpression, "Group"))
{
return true;
}
}
return false;
}
private bool IsUpdateArray(ExpressionParameter parameter, BinaryExpression expression, string operatorValue) private bool IsUpdateArray(ExpressionParameter parameter, BinaryExpression expression, string operatorValue)
{ {
var isOk = parameter.Context.ResolveType == ResolveExpressType.WhereSingle && operatorValue == "=" && (expression.Left is MemberExpression) && expression.Left.Type.IsClass(); var isOk = parameter.Context.ResolveType == ResolveExpressType.WhereSingle && operatorValue == "=" && (expression.Left is MemberExpression) && expression.Left.Type.IsClass();

Loading…
Cancel
Save