fix:修复达梦数据库上时间相减永远输出为0的问题

This commit is contained in:
xieyidong
2025-02-07 16:26:04 +08:00
parent 8d21ec7a62
commit d30a82d986

View File

@@ -389,11 +389,11 @@ namespace FreeSql.Dameng
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})";
case "TotalDays": return $"DATEDIFF(Day, {getExp(date2)}, {getExp(date1)})";
case "TotalHours": return $"DATEDIFF(Hour, {getExp(date2)}, {getExp(date1)})";
case "TotalMilliseconds": return $"DATEDIFF(MS, {getExp(date2)}, {getExp(date1)})";
case "TotalMinutes": return $"DATEDIFF(Minute, {getExp(date2)}, {getExp(date1)})";
case "TotalSeconds": return $"DATEDIFF(Second, {getExp(date2)}, {getExp(date1)})";
}
return null;
}