File tree Expand file tree Collapse file tree
Orm/Xtensive.Orm/Orm/Providers/Expressions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -215,6 +215,14 @@ private static bool IsBooleanExpression(Expression expression) =>
215215
216216 private static bool IsDateTimeExpression ( Expression expression ) =>
217217 IsExpressionOf ( expression , WellKnownTypes . DateTime ) ;
218+ #if NET6_0_OR_GREATER //DO_DATEONLY
219+
220+ private static bool IsDateOnlyExpression ( Expression expression ) =>
221+ IsExpressionOf ( expression , WellKnownTypes . DateOnly ) ;
222+
223+ private static bool IsTimeOnlyExpression ( Expression expression ) =>
224+ IsExpressionOf ( expression , WellKnownTypes . TimeOnly ) ;
225+ #endif
218226
219227 private static bool IsDateTimeOffsetExpression ( Expression expression ) =>
220228 IsExpressionOf ( expression , WellKnownTypes . DateTimeOffset ) ;
Original file line number Diff line number Diff line change @@ -217,10 +217,21 @@ protected override SqlExpression VisitBinary(BinaryExpression expression)
217217 if ( dateTimeEmulation
218218 && left . NodeType != SqlNodeType . Null
219219 && right . NodeType != SqlNodeType . Null
220- && IsComparisonExpression ( expression )
221- && ( IsDateTimeExpression ( expression . Left ) || IsDateTimeExpression ( expression . Right ) ) ) {
222- left = SqlDml . Cast ( left , SqlType . DateTime ) ;
223- right = SqlDml . Cast ( right , SqlType . DateTime ) ;
220+ && IsComparisonExpression ( expression ) ) {
221+ if ( IsDateTimeExpression ( expression . Left ) || IsDateTimeExpression ( expression . Right ) ) {
222+ left = SqlDml . Cast ( left , SqlType . DateTime ) ;
223+ right = SqlDml . Cast ( right , SqlType . DateTime ) ;
224+ }
225+ #if NET6_0_OR_GREATER
226+ else if ( IsDateOnlyExpression ( expression . Left ) || IsDateOnlyExpression( expression . Right ) ) {
227+ left = SqlDml . Cast ( left , SqlType . Date ) ;
228+ right = SqlDml . Cast ( right , SqlType . Date ) ;
229+ }
230+ else if ( IsTimeOnlyExpression ( expression . Left ) || IsDateOnlyExpression( expression . Right ) ) {
231+ left = SqlDml . Cast ( left , SqlType . Time ) ;
232+ right = SqlDml . Cast ( right , SqlType . Time ) ;
233+ }
234+ #endif
224235 }
225236
226237 //handle SQLite DateTimeOffset comparsion
You can’t perform that action at this time.
0 commit comments