Exp to sql

This commit is contained in:
sunkaixuan 2025-04-28 22:33:03 +08:00
parent 0ce74d5a4a
commit 92f6a6feff
3 changed files with 12 additions and 0 deletions

View File

@ -147,6 +147,13 @@ namespace SqlSugar
default:
break;
}
if (this.Result.Length > 0 && this.Result[this.Result.Length - 1] == ',')
{
if (parameter?.ToString()?.StartsWith(" AS ") ==true && parameter?.ToString()?.EndsWith(" ,")==true)
{
this.Result.Length--; // 直接删掉最后一个字符
}
}
this.Result.Append(parameter);
}

View File

@ -27,6 +27,7 @@ namespace SqlSugar
var value = ExpressionTool.DynamicInvoke(express.Test);
if (value is bool boolValue)
{
args[0] = boolValue ? UtilConstants.ExpTrue :UtilConstants.ExpFalse;
// 根据结果选择分支
var next = boolValue ? express.IfTrue : express.IfFalse;
args[1] = next;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Dynamic;
using System.Globalization;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
namespace SqlSugar
{
@ -77,5 +78,8 @@ namespace SqlSugar
"Millisecond",
"Date"
};
public static ConstantExpression ExpTrue = Expression.Constant(true);
public static ConstantExpression ExpFalse = Expression.Constant(false);
}
}