diff --git a/Providers/FreeSql.Provider.Dameng/DamengExpression.cs b/Providers/FreeSql.Provider.Dameng/DamengExpression.cs index 23ed1cedd..2ced154e1 100644 --- a/Providers/FreeSql.Provider.Dameng/DamengExpression.cs +++ b/Providers/FreeSql.Provider.Dameng/DamengExpression.cs @@ -389,11 +389,11 @@ namespace FreeSql.Dameng Func 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; }