mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-19 12:28:15 +08:00
- 优化 表达式对整数除法的处理,解析为整除;
This commit is contained in:
@ -483,6 +483,9 @@ namespace FreeSql.Internal
|
||||
switch (oper)
|
||||
{
|
||||
case "%": return _common.Mod(left, right, leftExp.Type, rightExp.Type);
|
||||
case "/":
|
||||
if (leftExp.Type.IsIntegerType() && rightExp.Type.IsIntegerType()) return _common.Div(left, right, leftExp.Type, rightExp.Type);
|
||||
break;
|
||||
case "AND":
|
||||
case "OR":
|
||||
left = GetBoolString(left);
|
||||
@ -490,10 +493,6 @@ namespace FreeSql.Internal
|
||||
break;
|
||||
}
|
||||
tsc.mapType = null;
|
||||
//switch(oper)
|
||||
//{
|
||||
// case "/": return ExpressionLambdaToSqlCallMath(Expression.Call(MethodMathFloor, Expression.Constant(1213.1d, typeof(double))), tsc)?.Replace("1213.1", $"{left} {oper} {right}");
|
||||
//}
|
||||
return $"{left} {oper} {right}";
|
||||
}
|
||||
public string ExpressionLambdaToSql(Expression exp, ExpTSC tsc)
|
||||
|
@ -32,6 +32,7 @@ namespace FreeSql.Internal
|
||||
public abstract string IsNull(string sql, object value);
|
||||
public abstract string StringConcat(string[] objs, Type[] types);
|
||||
public abstract string Mod(string left, string right, Type leftType, Type rightType);
|
||||
public abstract string Div(string left, string right, Type leftType, Type rightType);
|
||||
public abstract string QuoteWriteParamter(Type type, string paramterName);
|
||||
public abstract string QuoteReadColumn(Type type, string columnName);
|
||||
|
||||
|
Reference in New Issue
Block a user