- 忧化 DateTime.Subtract(date).TotalDays 表达式解析对应 datediff(day, date1, date2);

This commit is contained in:
2881099
2024-12-19 17:00:55 +08:00
parent e0941609c9
commit b5b67f1dcf
20 changed files with 751 additions and 772 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1902,32 +1902,46 @@ namespace FreeSql.Internal
case "System.String": extRet = ExpressionLambdaToSqlMemberAccessString(exp4, tsc); break;
case "System.DateTime": extRet = ExpressionLambdaToSqlMemberAccessDateTime(exp4, tsc); break;
case "System.TimeSpan":
if (exp4.Expression != null && (
// 如果是以 TimeSpan.Subtract(DateTime) 的方式调用的
(exp4.Expression.NodeType == ExpressionType.Call &&
exp4.Expression is MethodCallExpression exp4CallExp &&
exp4CallExp.Method.Name == "Subtract" &&
exp4CallExp.Object != null && exp4CallExp.Object.Type == typeof(DateTime) &&
exp4CallExp.Arguments.Count == 1 && exp4CallExp.Arguments[0].Type == typeof(DateTime))
// 如果是以 TimeSpan1 -/+ TimeSpan2 的方式调用的
|| (exp4.Expression.NodeType == ExpressionType.Subtract || exp4.Expression.NodeType == ExpressionType.Add)
)
)
if (exp4.Expression != null)
{
var left = ExpressionLambdaToSql(exp4.Expression, tsc);
switch (exp4.Member.Name)
var exp4MemberIsTrue = false;
// 如果是以 DateTime.Subtract(DateTime) 的方式调用的
if (exp4.Expression.NodeType == ExpressionType.Call &&
exp4.Expression is MethodCallExpression exp4CallExp &&
exp4CallExp.Method.Name == "Subtract" &&
exp4CallExp.Object != null && exp4CallExp.Object.Type == typeof(DateTime) &&
exp4CallExp.Arguments.Count == 1 && exp4CallExp.Arguments[0].Type == typeof(DateTime))
{
case "Days": return $"floor(({left})/{60 * 60 * 24})";
case "Hours": return $"floor(({left})/{60 * 60}%24)";
case "Milliseconds": return $"(({left})*1000)";
case "Minutes": return $"floor(({left})/60%60)";
case "Seconds": return $"(({left})%60)";
case "Ticks": return $"(({left})*10000000)";
case "TotalDays": return $"(({left})/{60 * 60 * 24}.0)";
case "TotalHours": return $"(({left})/{60 * 60}.0)";
case "TotalMilliseconds": return $"(({left})*1000)";
case "TotalMinutes": return $"(({left})/60.0)";
case "TotalSeconds": return $"({left})";
extRet = ExpressionLambdaToSqlCallDateDiff(exp4.Member.Name, exp4CallExp.Object, exp4CallExp.Arguments[0], tsc);
if (string.IsNullOrEmpty(extRet) == false) return extRet;
exp4MemberIsTrue = true;
}
// 如果是以 DateTime1 - DateTime2 的方式调用的
else if (exp4.Expression.NodeType == ExpressionType.Subtract && exp4.Expression.Type == typeof(TimeSpan) &&
exp4.Expression is BinaryExpression exp4BinaryExp &&
exp4BinaryExp.Left.Type == typeof(DateTime) && exp4BinaryExp.Right.Type == typeof(DateTime))
{
extRet = ExpressionLambdaToSqlCallDateDiff(exp4.Member.Name, exp4BinaryExp.Left, exp4BinaryExp.Right, tsc);
if (string.IsNullOrEmpty(extRet) == false) return extRet;
exp4MemberIsTrue = true;
}
if (exp4MemberIsTrue)
{
var left = ExpressionLambdaToSql(exp4.Expression, tsc);
switch (exp4.Member.Name)
{
case "Days": return $"floor(({left})/{60 * 60 * 24})";
case "Hours": return $"floor(({left})/{60 * 60}%24)";
case "Milliseconds": return $"(({left})*1000)";
case "Minutes": return $"floor(({left})/60%60)";
case "Seconds": return $"(({left})%60)";
case "Ticks": return $"(({left})*10000000)";
case "TotalDays": return $"(({left})/{60 * 60 * 24}.0)";
case "TotalHours": return $"(({left})/{60 * 60}.0)";
case "TotalMilliseconds": return $"(({left})*1000)";
case "TotalMinutes": return $"(({left})/60.0)";
case "TotalSeconds": return $"({left})";
}
}
}
throw new Exception(CoreErrorStrings.Unable_Parse_Expression(exp4));
@@ -2398,6 +2412,7 @@ namespace FreeSql.Internal
public abstract string ExpressionLambdaToSqlMemberAccessDateTime(MemberExpression exp, ExpTSC tsc);
public abstract string ExpressionLambdaToSqlCallString(MethodCallExpression exp, ExpTSC tsc);
public abstract string ExpressionLambdaToSqlCallMath(MethodCallExpression exp, ExpTSC tsc);
public virtual string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc) { return null; }
public abstract string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc);
public abstract string ExpressionLambdaToSqlCallConvert(MethodCallExpression exp, ExpTSC tsc);
public abstract string ExpressionLambdaToSqlOther(Expression exp, ExpTSC tsc);

View File

@@ -421,6 +421,19 @@ namespace FreeSql.ClickHouse
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"dateDiff(day,{getExp(date2)},toDateTime({getExp(date1)}))";
case "TotalHours": return $"dateDiff(hour,{getExp(date2)},toDateTime({getExp(date1)}))";
case "TotalMilliseconds": return $"dateDiff(millisecond, {getExp(date2)},toDateTime({getExp(date1)}))";
case "TotalMinutes": return $"dateDiff(minute,{getExp(date2)},toDateTime({getExp(date1)}))";
case "TotalSeconds": return $"dateDiff(second,{getExp(date2)},toDateTime({getExp(date1)}))";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -379,6 +379,18 @@ namespace FreeSql.Custom.MySql
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"timestampdiff(day,{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"timestampdiff(hour,{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"timestampdiff(minute,{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"timestampdiff(second,{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -384,6 +384,19 @@ namespace FreeSql.Custom.Oracle
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"(({getExp(date1)}+0)-({getExp(date2)}+0))";
case "TotalHours": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*24)";
case "TotalMilliseconds": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60 * 60 * 1000})";
case "TotalMinutes": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60})";
case "TotalSeconds": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60 * 60})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -381,6 +381,19 @@ namespace FreeSql.Custom.SqlServer
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff(day,{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"datediff(hour,{getExp(date2)},{getExp(date1)})";
case "TotalMilliseconds": return $"datediff(millisecond,{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"datediff(minute,{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"datediff(second,{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -384,6 +384,19 @@ namespace FreeSql.Dameng
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"(cast({getExp(date1)} as timestamp with time zone)-{getExp(date2)})";
case "TotalHours": return $"((cast({getExp(date1)} as timestamp with time zone)-{getExp(date2)})*24)";
case "TotalMilliseconds": return $"((cast({getExp(date1)} as timestamp with time zone)-{getExp(date2)})*{24 * 60 * 60 * 1000})";
case "TotalMinutes": return $"((cast({getExp(date1)} as timestamp with time zone)-{getExp(date2)})*{24 * 60})";
case "TotalSeconds": return $"((cast({getExp(date1)} as timestamp with time zone)-{getExp(date2)})*{24 * 60 * 60})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -369,6 +369,19 @@ namespace FreeSql.Firebird
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff(day from {getExp(date2)} to {getExp(date1)})";
case "TotalHours": return $"datediff(hour from {getExp(date2)} to {getExp(date1)})";
case "TotalMilliseconds": return $"datediff(millisecond from {getExp(date2)} to {getExp(date1)})";
case "TotalMinutes": return $"datediff(minute from {getExp(date2)} to {getExp(date1)})";
case "TotalSeconds": return $"datediff(second from {getExp(date2)} to {getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -369,6 +369,19 @@ namespace FreeSql.GBase
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"({getExp(date1)}-{getExp(date2)})";
case "TotalHours": return $"(({getExp(date1)}-{getExp(date2)})*24)";
case "TotalMilliseconds": return $"(({getExp(date1)}-{getExp(date2)})*{24 * 60 * 60 * 1000})";
case "TotalMinutes": return $"(({getExp(date1)}-{getExp(date2)})*{24 * 60})";
case "TotalSeconds": return $"(({getExp(date1)}-{getExp(date2)})*{24 * 60 * 60})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -321,6 +321,18 @@ namespace FreeSql.MsAccess
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff('d',{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"datediff('h',{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"datediff('n',{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"datediff('s',{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -381,6 +381,18 @@ namespace FreeSql.MySql
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"timestampdiff(day,{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"timestampdiff(hour,{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"timestampdiff(minute,{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"timestampdiff(second,{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -379,6 +379,18 @@ namespace FreeSql.Odbc.MySql
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"timestampdiff(day,{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"timestampdiff(hour,{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"timestampdiff(minute,{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"timestampdiff(second,{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -384,6 +384,19 @@ namespace FreeSql.Odbc.Oracle
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"(({getExp(date1)}+0)-({getExp(date2)}+0))";
case "TotalHours": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*24)";
case "TotalMilliseconds": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60 * 60 * 1000})";
case "TotalMinutes": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60})";
case "TotalSeconds": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60 * 60})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -381,6 +381,19 @@ namespace FreeSql.Odbc.SqlServer
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff(day,{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"datediff(hour,{getExp(date2)},{getExp(date1)})";
case "TotalMilliseconds": return $"datediff(millisecond,{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"datediff(minute,{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"datediff(second,{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -384,6 +384,19 @@ namespace FreeSql.Oracle
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"(({getExp(date1)}+0)-({getExp(date2)}+0))";
case "TotalHours": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*24)";
case "TotalMilliseconds": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60 * 60 * 1000})";
case "TotalMinutes": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60})";
case "TotalSeconds": return $"((({getExp(date1)}+0)-({getExp(date2)}+0))*{24 * 60 * 60})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -420,7 +420,18 @@ namespace FreeSql.QuestDb
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff('d',{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"datediff('h',{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"datediff('m',{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"datediff('s',{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -428,6 +428,18 @@ namespace FreeSql.ShenTong
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff('day',{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"datediff('hour',{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"datediff('minute',{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"datediff('second',{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
@@ -460,7 +472,7 @@ namespace FreeSql.ShenTong
case "AddMilliseconds": return $"dateadd('second',({args1})/1000,{left})";
case "AddMinutes": return $"dateadd('minute',{args1},{left})";
case "AddMonths": return $"dateadd('month',{args1},{left})";
case "AddSeconds": return $"dateadd('second', {args1}, {left})";
case "AddSeconds": return $"dateadd('second',{args1},{left})";
case "AddTicks": return $"dateadd('second',({args1})/10000000,{left})";
case "AddYears": return $"dateadd('year',{args1},{left})";
case "Subtract":

View File

@@ -380,6 +380,19 @@ namespace FreeSql.SqlServer
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff(day,{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"datediff(hour,{getExp(date2)},{getExp(date1)})";
case "TotalMilliseconds": return $"datediff(millisecond,{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"datediff(minute,{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"datediff(second,{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -396,6 +396,16 @@ namespace FreeSql.Sqlite
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"(strftime('%d',{getExp(date1)})-strftime('%d',{getExp(date2)}))";
case "TotalHours": return $"(strftime('%h',{getExp(date1)})-strftime('%h',{getExp(date2)}))";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);

View File

@@ -429,6 +429,19 @@ namespace FreeSql.Xugu
}
return null;
}
public override string ExpressionLambdaToSqlCallDateDiff(string memberName, Expression date1, Expression date2, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
switch (memberName)
{
case "TotalDays": return $"datediff(day,{getExp(date2)},{getExp(date1)})";
case "TotalHours": return $"datediff(hour,{getExp(date2)},{getExp(date1)})";
case "TotalMilliseconds": return $"datediff(millisecond,{getExp(date2)},{getExp(date1)})";
case "TotalMinutes": return $"datediff(minute,{getExp(date2)},{getExp(date1)})";
case "TotalSeconds": return $"datediff(second,{getExp(date2)},{getExp(date1)})";
}
return null;
}
public override string ExpressionLambdaToSqlCallDateTime(MethodCallExpression exp, ExpTSC tsc)
{
Func<Expression, string> getExp = exparg => ExpressionLambdaToSql(exparg, tsc);
@@ -467,7 +480,7 @@ namespace FreeSql.Xugu
case "Subtract":
switch ((exp.Arguments[0].Type.IsNullableType() ? exp.Arguments[0].Type.GetGenericArguments().FirstOrDefault() : exp.Arguments[0].Type).FullName)
{
case "System.DateTime": return $"datediff(second, {args1}, {left})";
case "System.DateTime": return $"datediff(second,{args1},{left})";
}
break;
case "Equals": return $"({left} = {args1})";