- 修复 Expression OrElse 两侧括号丢失的 bug;

- 修复 Expression DateTime 类型 CompareTo 在 MySql/SqlServer 下的 bug;
This commit is contained in:
28810
2019-04-23 18:54:55 +08:00
parent 9dd85f33f9
commit b16218d779
11 changed files with 280 additions and 16 deletions

View File

@ -771,10 +771,11 @@ namespace FreeSql.Internal {
if (string.IsNullOrEmpty(other99Exp) == false) return other99Exp;
return "";
}
if (expBinary.NodeType == ExpressionType.Coalesce) {
return _common.IsNull(
ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style),
ExpressionLambdaToSql(expBinary.Right, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style));
switch (expBinary.NodeType) {
case ExpressionType.Coalesce:
return _common.IsNull(ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style), ExpressionLambdaToSql(expBinary.Right, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style));
case ExpressionType.OrElse:
return $"({ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style)} OR {ExpressionLambdaToSql(expBinary.Right, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style)})";
}
if (dicExpressionOperator.TryGetValue(expBinary.NodeType, out var tryoper) == false) return "";
var left = ExpressionLambdaToSql(expBinary.Left, _tables, _selectColumnMap, getSelectGroupingMapString, tbtype, isQuoteName, isDisableDiyParse, style);

View File

@ -335,7 +335,7 @@ namespace FreeSql.MySql {
}
break;
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
case "CompareTo": return $"(({left}) - ({getExp(exp.Arguments[0])}))";
case "CompareTo": return $"timestampdiff(microsecond,{getExp(exp.Arguments[0])},{left})";
case "ToString": return $"date_format({left}, '%Y-%m-%d %H:%i:%s.%f')";
}
}

View File

@ -320,7 +320,7 @@ namespace FreeSql.SqlServer {
}
break;
case "Equals": return $"({left} = {getExp(exp.Arguments[0])})";
case "CompareTo": return $"(({left}) - ({getExp(exp.Arguments[0])}))";
case "CompareTo": return $"datediff(second,{getExp(exp.Arguments[0])},{left})";
case "ToString": return $"convert(varchar, {left}, 121)";
}
}