mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
Synchronization code
This commit is contained in:
parent
18735dab57
commit
ed0c2e1777
@ -61,6 +61,14 @@ namespace SqlSugar
|
||||
isIsNegate = true;
|
||||
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);
|
||||
if (methodExp.Method.Name == "IF")
|
||||
{
|
||||
|
@ -11,6 +11,21 @@ namespace SqlSugar
|
||||
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)
|
||||
{
|
||||
var isNav = false;
|
||||
|
@ -345,11 +345,17 @@ namespace SqlSugar
|
||||
{
|
||||
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
|
||||
{
|
||||
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)
|
||||
{
|
||||
parameter.CommonTempData = CommonTempDataType.Result;
|
||||
|
Loading…
Reference in New Issue
Block a user