mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-04 20:57:58 +08:00
Update exp to sql
This commit is contained in:
parent
65f9dd1420
commit
c5457aeddb
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user