mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-07-31 15:56:25 +08:00
Update exp to sql (Optimization of +)
This commit is contained in:
parent
47f308ae6e
commit
9938bec957
@ -33,12 +33,34 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
SubGroup(expression, operatorValue);
|
SubGroup(expression, operatorValue);
|
||||||
}
|
}
|
||||||
|
else if (IsJoinString(expression, operatorValue))
|
||||||
|
{
|
||||||
|
JoinString(parameter, expression);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DefaultBinary(parameter, expression, operatorValue);
|
DefaultBinary(parameter, expression, operatorValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void JoinString(ExpressionParameter parameter, BinaryExpression expression)
|
||||||
|
{
|
||||||
|
var leftString = GetNewExpressionValue(expression.Left);
|
||||||
|
var RightString = GetNewExpressionValue(expression.Right);
|
||||||
|
var joinString = this.Context.DbMehtods.MergeString(leftString, RightString);
|
||||||
|
if (this.Context.Result.Contains(ExpressionConst.FormatSymbol))
|
||||||
|
{
|
||||||
|
base.Context.Result.Replace("{0}", $" {joinString} ");
|
||||||
|
base.Context.Result.Append(" " + ExpressionConst.ExpressionReplace + parameter.BaseParameter.Index + " ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
base.Context.Result.Append($" {joinString} ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void DefaultBinary(ExpressionParameter parameter, BinaryExpression expression, string operatorValue)
|
private void DefaultBinary(ExpressionParameter parameter, BinaryExpression expression, string operatorValue)
|
||||||
{
|
{
|
||||||
var isEqual = expression.NodeType == ExpressionType.Equal;
|
var isEqual = expression.NodeType == ExpressionType.Equal;
|
||||||
@ -232,7 +254,12 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
private static bool IsJoinString(BinaryExpression expression, string operatorValue)
|
||||||
|
{
|
||||||
|
return operatorValue == "+"
|
||||||
|
&& expression.Right.Type == UtilConstants.StringType
|
||||||
|
&& expression.Left.Type==UtilConstants.StringType;
|
||||||
|
}
|
||||||
private static bool RightIsHasValue(Expression leftExpression, Expression rightExpression,bool isLogic)
|
private static bool RightIsHasValue(Expression leftExpression, Expression rightExpression,bool isLogic)
|
||||||
{
|
{
|
||||||
return isLogic&&
|
return isLogic&&
|
||||||
|
Loading…
Reference in New Issue
Block a user