mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-20 02:29:39 +08:00
Synchronization code
This commit is contained in:
@@ -61,6 +61,14 @@ namespace SqlSugar
|
|||||||
isIsNegate = true;
|
isIsNegate = true;
|
||||||
exp = (exp as UnaryExpression).Operand;
|
exp = (exp as UnaryExpression).Operand;
|
||||||
}
|
}
|
||||||
|
if (methodExp.Method.Name.IsIn("Return", "End")&& exp .Type==UtilConstants.BoolType&& ExpressionTool.IsEqualOrLtOrGt(exp))
|
||||||
|
{
|
||||||
|
exp=ExpressionTool.GetConditionalExpression(exp);
|
||||||
|
}
|
||||||
|
else if (methodExp.Method.Name.IsIn("Return", "End") && exp.Type == UtilConstants.BoolType && ExpressionTool.GetMethodName(exp).IsIn("Contains", "StartsWith", "EndsWith"))
|
||||||
|
{
|
||||||
|
exp = ExpressionTool.GetConditionalExpression(exp);
|
||||||
|
}
|
||||||
var sql = SubTools.GetMethodValue(this.context, exp, this.context.IsSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple);
|
var sql = SubTools.GetMethodValue(this.context, exp, this.context.IsSingle ? ResolveExpressType.WhereSingle : ResolveExpressType.WhereMultiple);
|
||||||
if (methodExp.Method.Name == "IF")
|
if (methodExp.Method.Name == "IF")
|
||||||
{
|
{
|
||||||
|
@@ -11,6 +11,21 @@ namespace SqlSugar
|
|||||||
public class ExpressionTool
|
public class ExpressionTool
|
||||||
{
|
{
|
||||||
|
|
||||||
|
internal static Expression GetConditionalExpression(Expression item)
|
||||||
|
{
|
||||||
|
ConstantExpression trueConstant = Expression.Constant(true, typeof(bool));
|
||||||
|
ConstantExpression falseConstant = Expression.Constant(false, typeof(bool));
|
||||||
|
|
||||||
|
// 创建条件表达式:item ? true : false
|
||||||
|
Expression conditionalExpression = Expression.Condition(
|
||||||
|
test: item,
|
||||||
|
ifTrue: trueConstant,
|
||||||
|
ifFalse: falseConstant
|
||||||
|
);
|
||||||
|
return conditionalExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static bool IsNavMember(ExpressionContext context, Expression member)
|
internal static bool IsNavMember(ExpressionContext context, Expression member)
|
||||||
{
|
{
|
||||||
var isNav = false;
|
var isNav = false;
|
||||||
|
@@ -345,11 +345,17 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
model.Args.Add(base.GetMethodCallArgs(parameter, item));
|
model.Args.Add(base.GetMethodCallArgs(parameter, item));
|
||||||
}
|
}
|
||||||
|
else if (methodExpression.Method.Name.IsIn("Contains", "EndsWith", "StartsWith"))
|
||||||
|
{
|
||||||
|
Expression conditionalExpression =ExpressionTool.GetConditionalExpression(item);
|
||||||
|
model.Args.Add(base.GetMethodCallArgs(parameter, conditionalExpression));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Check.Exception(true, "The SqlFunc.IIF(arg1,arg2,arg3) , {0} argument do not support ", item.ToString());
|
Check.Exception(true, "The SqlFunc.IIF(arg1,arg2,arg3) , {0} argument do not support ", item.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AppendModel(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item,string name, IEnumerable<Expression> args)
|
private void AppendModel(ExpressionParameter parameter, MethodCallExpressionModel model, Expression item,string name, IEnumerable<Expression> args)
|
||||||
{
|
{
|
||||||
parameter.CommonTempData = CommonTempDataType.Result;
|
parameter.CommonTempData = CommonTempDataType.Result;
|
||||||
|
Reference in New Issue
Block a user