mirror of
				https://gitee.com/dotnetchina/SqlSugar.git
				synced 2025-11-01 00:46:50 +08:00 
			
		
		
		
	Update exp to sql
This commit is contained in:
		| @@ -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
	 sunkaixuan
					sunkaixuan