@@ -90,7 +90,7 @@ public override async Task Parameter_collection_Count_with_column_predicate_with
9090FROM [PrimitiveCollectionsEntity] AS [p]
9191WHERE (
9292 SELECT COUNT(*)
93- FROM (VALUES (2 ), (999), (1000)) AS [i]([Value])
93+ FROM (VALUES (CAST(2 AS int) ), (999), (1000)) AS [i]([Value])
9494 WHERE [i].[Value] > [p].[Id]) = 2
9595""" ) ;
9696 }
@@ -335,7 +335,9 @@ public override async Task Inline_collection_Min_with_two_values()
335335 """
336336SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
337337FROM [PrimitiveCollectionsEntity] AS [p]
338- WHERE LEAST(30, [p].[Int]) = 30
338+ WHERE (
339+ SELECT MIN([v].[Value])
340+ FROM (VALUES (CAST(30 AS int)), ([p].[Int])) AS [v]([Value])) = 30
339341""" ) ;
340342 }
341343
@@ -347,7 +349,9 @@ public override async Task Inline_collection_List_Min_with_two_values()
347349 """
348350SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
349351FROM [PrimitiveCollectionsEntity] AS [p]
350- WHERE LEAST(30, [p].[Int]) = 30
352+ WHERE (
353+ SELECT MIN([v].[Value])
354+ FROM (VALUES (CAST(30 AS int)), ([p].[Int])) AS [v]([Value])) = 30
351355""" ) ;
352356 }
353357
@@ -359,7 +363,9 @@ public override async Task Inline_collection_Max_with_two_values()
359363 """
360364SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
361365FROM [PrimitiveCollectionsEntity] AS [p]
362- WHERE GREATEST(30, [p].[Int]) = 30
366+ WHERE (
367+ SELECT MAX([v].[Value])
368+ FROM (VALUES (CAST(30 AS int)), ([p].[Int])) AS [v]([Value])) = 30
363369""" ) ;
364370 }
365371
@@ -371,7 +377,9 @@ public override async Task Inline_collection_List_Max_with_two_values()
371377 """
372378SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
373379FROM [PrimitiveCollectionsEntity] AS [p]
374- WHERE GREATEST(30, [p].[Int]) = 30
380+ WHERE (
381+ SELECT MAX([v].[Value])
382+ FROM (VALUES (CAST(30 AS int)), ([p].[Int])) AS [v]([Value])) = 30
375383""" ) ;
376384 }
377385
@@ -385,7 +393,9 @@ public override async Task Inline_collection_Min_with_three_values()
385393
386394SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
387395FROM [PrimitiveCollectionsEntity] AS [p]
388- WHERE LEAST(30, [p].[Int], @i) = 25
396+ WHERE (
397+ SELECT MIN([v].[Value])
398+ FROM (VALUES (CAST(30 AS int)), ([p].[Int]), (@i)) AS [v]([Value])) = 25
389399""" ) ;
390400 }
391401
@@ -399,7 +409,9 @@ public override async Task Inline_collection_List_Min_with_three_values()
399409
400410SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
401411FROM [PrimitiveCollectionsEntity] AS [p]
402- WHERE LEAST(30, [p].[Int], @i) = 25
412+ WHERE (
413+ SELECT MIN([v].[Value])
414+ FROM (VALUES (CAST(30 AS int)), ([p].[Int]), (@i)) AS [v]([Value])) = 25
403415""" ) ;
404416 }
405417
@@ -413,7 +425,9 @@ public override async Task Inline_collection_Max_with_three_values()
413425
414426SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
415427FROM [PrimitiveCollectionsEntity] AS [p]
416- WHERE GREATEST(30, [p].[Int], @i) = 35
428+ WHERE (
429+ SELECT MAX([v].[Value])
430+ FROM (VALUES (CAST(30 AS int)), ([p].[Int]), (@i)) AS [v]([Value])) = 35
417431""" ) ;
418432 }
419433
@@ -427,7 +441,9 @@ public override async Task Inline_collection_List_Max_with_three_values()
427441
428442SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
429443FROM [PrimitiveCollectionsEntity] AS [p]
430- WHERE GREATEST(30, [p].[Int], @i) = 35
444+ WHERE (
445+ SELECT MAX([v].[Value])
446+ FROM (VALUES (CAST(30 AS int)), ([p].[Int]), (@i)) AS [v]([Value])) = 35
431447""" ) ;
432448 }
433449
@@ -441,7 +457,9 @@ public override async Task Inline_collection_of_nullable_value_type_Min()
441457
442458SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
443459FROM [PrimitiveCollectionsEntity] AS [p]
444- WHERE LEAST(30, [p].[Int], @i) = 25
460+ WHERE (
461+ SELECT MIN([v].[Value])
462+ FROM (VALUES (CAST(30 AS int)), ([p].[Int]), (@i)) AS [v]([Value])) = 25
445463""" ) ;
446464 }
447465
@@ -455,7 +473,9 @@ public override async Task Inline_collection_of_nullable_value_type_Max()
455473
456474SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
457475FROM [PrimitiveCollectionsEntity] AS [p]
458- WHERE GREATEST(30, [p].[Int], @i) = 35
476+ WHERE (
477+ SELECT MAX([v].[Value])
478+ FROM (VALUES (CAST(30 AS int)), ([p].[Int]), (@i)) AS [v]([Value])) = 35
459479""" ) ;
460480 }
461481
@@ -467,7 +487,9 @@ public override async Task Inline_collection_of_nullable_value_type_with_null_Mi
467487 """
468488SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
469489FROM [PrimitiveCollectionsEntity] AS [p]
470- WHERE LEAST(30, [p].[NullableInt], NULL) = 30
490+ WHERE (
491+ SELECT MIN([v].[Value])
492+ FROM (VALUES (CAST(30 AS int)), ([p].[NullableInt]), (NULL)) AS [v]([Value])) = 30
471493""" ) ;
472494 }
473495
@@ -479,7 +501,9 @@ public override async Task Inline_collection_of_nullable_value_type_with_null_Ma
479501 """
480502SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
481503FROM [PrimitiveCollectionsEntity] AS [p]
482- WHERE GREATEST(30, [p].[NullableInt], NULL) = 30
504+ WHERE (
505+ SELECT MAX([v].[Value])
506+ FROM (VALUES (CAST(30 AS int)), ([p].[NullableInt]), (NULL)) AS [v]([Value])) = 30
483507""" ) ;
484508 }
485509
@@ -1130,7 +1154,7 @@ public override async Task Column_collection_index_int()
11301154 """
11311155SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
11321156FROM [PrimitiveCollectionsEntity] AS [p]
1133- WHERE CAST( JSON_VALUE([p].[Ints], '$[1]') AS int) = 10
1157+ WHERE JSON_VALUE([p].[Ints], '$[1]' RETURNING int) = 10
11341158""" ) ;
11351159 }
11361160
@@ -1142,7 +1166,7 @@ public override async Task Column_collection_index_string()
11421166 """
11431167SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
11441168FROM [PrimitiveCollectionsEntity] AS [p]
1145- WHERE JSON_VALUE([p].[Strings], '$[1]') = N'10'
1169+ WHERE JSON_VALUE([p].[Strings], '$[1]' RETURNING nvarchar(max) ) = N'10'
11461170""" ) ;
11471171 }
11481172
@@ -1154,7 +1178,7 @@ public override async Task Column_collection_index_datetime()
11541178 """
11551179SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
11561180FROM [PrimitiveCollectionsEntity] AS [p]
1157- WHERE CAST( JSON_VALUE([p].[DateTimes], '$[1]') AS datetime2) = '2020-01-10T12:30:00.0000000Z'
1181+ WHERE JSON_VALUE([p].[DateTimes], '$[1]' RETURNING datetime2) = '2020-01-10T12:30:00.0000000Z'
11581182""" ) ;
11591183 }
11601184
@@ -1166,7 +1190,7 @@ public override async Task Column_collection_index_beyond_end()
11661190 """
11671191SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
11681192FROM [PrimitiveCollectionsEntity] AS [p]
1169- WHERE CAST( JSON_VALUE([p].[Ints], '$[999]') AS int) = 10
1193+ WHERE JSON_VALUE([p].[Ints], '$[999]' RETURNING int) = 10
11701194""" ) ;
11711195 }
11721196
@@ -1179,7 +1203,7 @@ public override async Task Nullable_reference_column_collection_index_equals_nul
11791203 """
11801204SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
11811205FROM [PrimitiveCollectionsEntity] AS [p]
1182- WHERE JSON_VALUE([p].[NullableStrings], '$[2]') = [p].[NullableString] OR (JSON_VALUE([p].[NullableStrings], '$[2]') IS NULL AND [p].[NullableString] IS NULL)
1206+ WHERE JSON_VALUE([p].[NullableStrings], '$[2]' RETURNING nvarchar(max)) = [p].[NullableString] OR (JSON_VALUE([p].[NullableStrings], '$[2]' RETURNING nvarchar(max) ) IS NULL AND [p].[NullableString] IS NULL)
11831207""" ) ;
11841208 }
11851209
@@ -1193,7 +1217,7 @@ public override async Task Non_nullable_reference_column_collection_index_equals
11931217FROM [PrimitiveCollectionsEntity] AS [p]
11941218WHERE EXISTS (
11951219 SELECT 1
1196- FROM OPENJSON([p].[Strings]) AS [s]) AND JSON_VALUE([p].[Strings], '$[1]') = [p].[NullableString]
1220+ FROM OPENJSON([p].[Strings]) AS [s]) AND JSON_VALUE([p].[Strings], '$[1]' RETURNING nvarchar(max) ) = [p].[NullableString]
11971221""" ) ;
11981222 }
11991223
@@ -1221,11 +1245,7 @@ public override async Task Inline_collection_index_Column_with_EF_Constant()
12211245 """
12221246SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
12231247FROM [PrimitiveCollectionsEntity] AS [p]
1224- WHERE (
1225- SELECT [i].[Value]
1226- FROM (VALUES (0, CAST(1 AS int)), (1, 2), (2, 3)) AS [i]([_ord], [Value])
1227- ORDER BY [i].[_ord]
1228- OFFSET [p].[Int] ROWS FETCH NEXT 1 ROWS ONLY) = 1
1248+ WHERE CAST(JSON_VALUE(N'[1,2,3]', '$[' + CAST([p].[Int] AS nvarchar(max)) + ']') AS int) = 1
12291249""" ) ;
12301250 }
12311251
@@ -1299,7 +1319,7 @@ public override async Task Column_collection_ElementAt()
12991319 """
13001320SELECT [p].[Id], [p].[Bool], [p].[Bools], [p].[DateTime], [p].[DateTimes], [p].[Enum], [p].[Enums], [p].[Int], [p].[Ints], [p].[NullableInt], [p].[NullableInts], [p].[NullableString], [p].[NullableStrings], [p].[NullableWrappedId], [p].[NullableWrappedIdWithNullableComparer], [p].[String], [p].[Strings], [p].[WrappedId]
13011321FROM [PrimitiveCollectionsEntity] AS [p]
1302- WHERE CAST( JSON_VALUE([p].[Ints], '$[1]') AS int) = 10
1322+ WHERE JSON_VALUE([p].[Ints], '$[1]' RETURNING int) = 10
13031323""" ) ;
13041324 }
13051325
@@ -1827,7 +1847,7 @@ SELECT COUNT(*)
18271847 SELECT [i1].[Value]
18281848 FROM (
18291849 SELECT [i].[Value]
1830- FROM (VALUES (1 , @ints1), (2 , @ints2)) AS [i]([_ord], [Value])
1850+ FROM (VALUES (0 , @ints1), (1 , @ints2)) AS [i]([_ord], [Value])
18311851 ORDER BY [i].[_ord]
18321852 OFFSET 1 ROWS
18331853 ) AS [i1]
@@ -1917,7 +1937,7 @@ FROM [PrimitiveCollectionsEntity] AS [p]
19171937 SELECT COUNT(*)
19181938 FROM (
19191939 SELECT [i].[Value] AS [Value0]
1920- FROM (VALUES (1 , @ints1), (2 , @ints2)) AS [i]([_ord], [Value])
1940+ FROM (VALUES (0 , @ints1), (1 , @ints2)) AS [i]([_ord], [Value])
19211941 ORDER BY [i].[_ord]
19221942 OFFSET 1 ROWS
19231943 ) AS [i0]
@@ -2147,7 +2167,7 @@ public override async Task Project_primitive_collections_element()
21472167
21482168 AssertSql (
21492169 """
2150- SELECT CAST( JSON_VALUE([p].[Ints], '$[0]') AS int) AS [Indexer], CAST( JSON_VALUE([p].[DateTimes], '$[0]') AS datetime2) AS [EnumerableElementAt], JSON_VALUE([p].[Strings], '$[1]') AS [QueryableElementAt]
2170+ SELECT JSON_VALUE([p].[Ints], '$[0]' RETURNING int) AS [Indexer], JSON_VALUE([p].[DateTimes], '$[0]' RETURNING datetime2) AS [EnumerableElementAt], JSON_VALUE([p].[Strings], '$[1]' RETURNING nvarchar(max) ) AS [QueryableElementAt]
21512171FROM [PrimitiveCollectionsEntity] AS [p]
21522172WHERE [p].[Id] < 4
21532173ORDER BY [p].[Id]
@@ -2267,10 +2287,6 @@ public TestSqlLoggerFactory TestSqlLoggerFactory
22672287 protected override ITestStoreFactory TestStoreFactory
22682288 => SqlServerTestStoreFactory . Instance ;
22692289
2270- public override DbContextOptionsBuilder AddOptions ( DbContextOptionsBuilder builder )
2271- => base . AddOptions ( builder )
2272- . UseSqlServer ( b => b . UseCompatibilityLevel ( 160 ) ) ;
2273-
22742290 protected override void OnModelCreating ( ModelBuilder modelBuilder , DbContext context )
22752291 {
22762292 base . OnModelCreating ( modelBuilder , context ) ;
0 commit comments