- 优化 表达式对整数除法的处理,解析为整除;

This commit is contained in:
28810
2019-09-06 14:48:37 +08:00
parent d51aef2aa9
commit d105041858
15 changed files with 110 additions and 7 deletions

View File

@ -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)

View File

@ -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);