1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
+ using Microsoft . EntityFrameworkCore . TestModels . BasicTypesModel ;
5
+
4
6
namespace Microsoft . EntityFrameworkCore . Query . Translations . Temporal ;
5
7
6
8
public class DateTimeTranslationsSqlServerTest : DateTimeTranslationsTestBase < BasicTypesQuerySqlServerFixture >
@@ -18,7 +20,7 @@ public override async Task Now()
18
20
19
21
AssertSql (
20
22
"""
21
- @myDatetime='2015-04-10T00:00:00.0000000'
23
+ @myDatetime='2015-04-10T00:00:00.0000000' (DbType = DateTime)
22
24
23
25
SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan]
24
26
FROM [BasicTypesEntities] AS [b]
@@ -32,7 +34,7 @@ public override async Task UtcNow()
32
34
33
35
AssertSql (
34
36
"""
35
- @myDatetime='2015-04-10T00:00:00.0000000'
37
+ @myDatetime='2015-04-10T00:00:00.0000000' (DbType = DateTime)
36
38
37
39
SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan]
38
40
FROM [BasicTypesEntities] AS [b]
@@ -241,6 +243,34 @@ FROM [BasicTypesEntities] AS [b]
241
243
""" ) ;
242
244
}
243
245
246
+ [ ConditionalFact ]
247
+ public virtual async Task Now_has_proper_type_mapping_for_constant_comparison ( )
248
+ {
249
+ await AssertQuery (
250
+ ss => ss . Set < BasicTypesEntity > ( ) . Where ( x => DateTime . Now > new DateTime ( 2025 , 1 , 1 ) ) ) ;
251
+
252
+ AssertSql (
253
+ """
254
+ SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan]
255
+ FROM [BasicTypesEntities] AS [b]
256
+ WHERE GETDATE() > '2025-01-01T00:00:00.000'
257
+ """ ) ;
258
+ }
259
+
260
+ [ ConditionalFact ]
261
+ public virtual async Task UtcNow_has_proper_type_mapping_for_constant_comparison ( )
262
+ {
263
+ await AssertQuery (
264
+ ss => ss . Set < BasicTypesEntity > ( ) . Where ( x => DateTime . UtcNow > new DateTime ( 2025 , 1 , 1 ) ) ) ;
265
+
266
+ AssertSql (
267
+ """
268
+ SELECT [b].[Id], [b].[Bool], [b].[Byte], [b].[ByteArray], [b].[DateOnly], [b].[DateTime], [b].[DateTimeOffset], [b].[Decimal], [b].[Double], [b].[Enum], [b].[FlagsEnum], [b].[Float], [b].[Guid], [b].[Int], [b].[Long], [b].[Short], [b].[String], [b].[TimeOnly], [b].[TimeSpan]
269
+ FROM [BasicTypesEntities] AS [b]
270
+ WHERE GETUTCDATE() > '2025-01-01T00:00:00.000'
271
+ """ ) ;
272
+ }
273
+
244
274
[ ConditionalFact ]
245
275
public virtual void Check_all_tests_overridden ( )
246
276
=> TestHelpers . AssertAllMethodsOverridden ( GetType ( ) ) ;
0 commit comments