diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/EntitySplittingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/EntitySplittingQuerySqlServerTest.cs index d0331af77b8..0d487558750 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/EntitySplittingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/EntitySplittingQuerySqlServerTest.cs @@ -208,7 +208,7 @@ public override async Task Normal_entity_owning_a_split_reference_with_main_frag AssertSql( """ SELECT [e].[Id], CASE - WHEN [e].[OwnedReference_Id] IS NOT NULL AND [e].[OwnedReference_OwnedIntValue1] IS NOT NULL AND [e].[OwnedReference_OwnedIntValue2] IS NOT NULL AND [o0].[OwnedIntValue3] IS NOT NULL AND [o].[OwnedIntValue4] IS NOT NULL THEN [o].[OwnedIntValue4] + WHEN [e].[OwnedReference_Id] IS NOT NULL AND [e].[OwnedReference_OwnedIntValue1] IS NOT NULL AND [e].[OwnedReference_OwnedIntValue2] IS NOT NULL AND [o0].[OwnedIntValue3] IS NOT NULL THEN [o].[OwnedIntValue4] END AS [OwnedIntValue4], CASE WHEN [e].[OwnedReference_Id] IS NOT NULL AND [e].[OwnedReference_OwnedIntValue1] IS NOT NULL AND [e].[OwnedReference_OwnedIntValue2] IS NOT NULL AND [o0].[OwnedIntValue3] IS NOT NULL AND [o].[OwnedIntValue4] IS NOT NULL THEN [o].[OwnedStringValue4] END AS [OwnedStringValue4] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 55c50a51dd2..7aad1d2b704 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -1003,10 +1003,7 @@ public override async Task Null_propagation_optimization4(bool async) """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NULL THEN NULL - ELSE CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -1019,9 +1016,7 @@ public override async Task Null_propagation_optimization5(bool async) """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -1034,9 +1029,7 @@ public override async Task Null_propagation_optimization6(bool async) """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -1047,9 +1040,7 @@ public override async Task Select_null_propagation_optimization7(bool async) // issue #16050 AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] -END +SELECT [g].[LeaderNickname] + [g].[LeaderNickname] FROM [Gears] AS [g] """); } @@ -1232,9 +1223,7 @@ public override async Task Select_null_propagation_works_for_multiple_navigation AssertSql( """ -SELECT CASE - WHEN [c].[Name] IS NOT NULL THEN [c].[Name] -END +SELECT [c].[Name] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] LEFT JOIN [Tags] AS [t0] ON ([g].[Nickname] = [t0].[GearNickName] OR ([g].[Nickname] IS NULL AND [t0].[GearNickName] IS NULL)) AND ([g].[SquadId] = [t0].[GearSquadId] OR ([g].[SquadId] IS NULL AND [t0].[GearSquadId] IS NULL)) @@ -3646,9 +3635,7 @@ public override async Task Select_null_conditional_with_inheritance(bool async) AssertSql( """ -SELECT CASE - WHEN [f].[CommanderName] IS NOT NULL THEN [f].[CommanderName] -END +SELECT [f].[CommanderName] FROM [Factions] AS [f] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs index b0bd1c81497..43dc60fdab4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindGroupByQuerySqlServerTest.cs @@ -2499,9 +2499,7 @@ public override async Task GroupBy_group_Where_Select_Distinct_aggregate(bool as AssertSql( """ -SELECT [o].[CustomerID] AS [Key], MAX(DISTINCT (CASE - WHEN [o].[OrderDate] IS NOT NULL THEN [o].[OrderDate] -END)) AS [Max] +SELECT [o].[CustomerID] AS [Key], MAX(DISTINCT ([o].[OrderDate])) AS [Max] FROM [Orders] AS [o] GROUP BY [o].[CustomerID] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs index b77f60c9cb0..f1cf3665736 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NullSemanticsQuerySqlServerTest.cs @@ -4465,9 +4465,7 @@ public override async Task Is_not_null_optimizes_unary_op(bool async) AssertSql( """ -SELECT CASE - WHEN [e].[NullableIntA] IS NOT NULL THEN ~[e].[NullableIntA] -END +SELECT ~[e].[NullableIntA] FROM [Entities1] AS [e] """); } @@ -4478,9 +4476,7 @@ public override async Task Is_not_null_optimizes_binary_op(bool async) AssertSql( """ -SELECT CASE - WHEN [e].[NullableIntA] IS NOT NULL AND [e].[NullableIntB] IS NOT NULL THEN [e].[NullableIntA] + [e].[NullableIntB] -END +SELECT [e].[NullableIntA] + [e].[NullableIntB] FROM [Entities1] AS [e] """); } @@ -4491,9 +4487,7 @@ public override async Task Is_not_null_optimizes_binary_op_with_partial_checks(b AssertSql( """ -SELECT CASE - WHEN [e].[NullableStringA] IS NOT NULL AND [e].[NullableStringB] IS NOT NULL THEN [e].[NullableStringA] + [e].[NullableStringB] + COALESCE([e].[NullableStringC], N'') -END +SELECT [e].[NullableStringA] + [e].[NullableStringB] + COALESCE([e].[NullableStringC], N'') FROM [Entities1] AS [e] """); } @@ -4504,11 +4498,7 @@ public override async Task Is_not_null_optimizes_binary_op_with_nested_checks(bo AssertSql( """ -SELECT CASE - WHEN [e].[NullableStringA] IS NOT NULL THEN CASE - WHEN [e].[NullableStringB] IS NOT NULL THEN [e].[NullableStringA] + [e].[NullableStringB] - END -END +SELECT [e].[NullableStringA] + [e].[NullableStringB] FROM [Entities1] AS [e] """); } @@ -4520,7 +4510,7 @@ public override async Task Is_not_null_optimizes_binary_op_with_mixed_checks(boo AssertSql( """ SELECT CASE - WHEN [e].[NullableStringA] IS NOT NULL AND [e].[BoolA] = CAST(1 AS bit) THEN [e].[NullableStringA] + COALESCE([e].[NullableStringB], N'') + WHEN [e].[BoolA] = CAST(1 AS bit) THEN [e].[NullableStringA] + COALESCE([e].[NullableStringB], N'') END FROM [Entities1] AS [e] """); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs index 8b5dc90d599..913fd4bb891 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeographyTest.cs @@ -88,10 +88,7 @@ public override async Task AsBinary_with_null_check(bool async) AssertSql( """ -SELECT [p].[Id], CASE - WHEN [p].[Point] IS NULL THEN NULL - ELSE [p].[Point].STAsBinary() -END AS [Binary] +SELECT [p].[Id], [p].[Point].STAsBinary() AS [Binary] FROM [PointEntity] AS [p] """); } @@ -285,10 +282,7 @@ public override async Task Disjoint_with_null_check(bool async) """ @__point_0='0xE6100000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Object) -SELECT [p].[Id], CASE - WHEN [p].[Polygon] IS NULL THEN NULL - ELSE [p].[Polygon].STDisjoint(@__point_0) -END AS [Disjoint] +SELECT [p].[Id], [p].[Polygon].STDisjoint(@__point_0) AS [Disjoint] FROM [PolygonEntity] AS [p] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs index b7aaa29bd74..a8bcc2e3b41 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/SpatialQuerySqlServerGeometryTest.cs @@ -83,10 +83,7 @@ public override async Task AsBinary_with_null_check(bool async) AssertSql( """ -SELECT [p].[Id], CASE - WHEN [p].[Point] IS NULL THEN NULL - ELSE [p].[Point].STAsBinary() -END AS [Binary] +SELECT [p].[Id], [p].[Point].STAsBinary() AS [Binary] FROM [PointEntity] AS [p] """); } @@ -404,10 +401,7 @@ public override async Task Disjoint_with_null_check(bool async) """ @__point_0='0x00000000010C000000000000F03F000000000000F03F' (Size = 22) (DbType = Object) -SELECT [p].[Id], CASE - WHEN [p].[Polygon] IS NULL THEN NULL - ELSE [p].[Polygon].STDisjoint(@__point_0) -END AS [Disjoint] +SELECT [p].[Id], [p].[Polygon].STDisjoint(@__point_0) AS [Disjoint] FROM [PolygonEntity] AS [p] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index 7f10653376e..4f78cfb68c5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -1395,10 +1395,7 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [u] -WHERE CASE - WHEN [u].[LeaderNickname] IS NULL THEN NULL - ELSE CAST(LEN([u].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([u].[LeaderNickname]) AS int) = 5 """); } @@ -1417,9 +1414,7 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [u] -WHERE CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(LEN([u].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([u].[LeaderNickname]) AS int) = 5 """); } @@ -1438,9 +1433,7 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [u] -WHERE CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(LEN([u].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([u].[LeaderNickname]) AS int) = 5 """); } @@ -1451,9 +1444,7 @@ public override async Task Select_null_propagation_optimization7(bool async) // issue #16050 AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN [u].[LeaderNickname] + [u].[LeaderNickname] -END +SELECT [u].[LeaderNickname] + [u].[LeaderNickname] FROM ( SELECT [g].[LeaderNickname] FROM [Gears] AS [g] @@ -1738,9 +1729,7 @@ public override async Task Select_null_propagation_works_for_multiple_navigation AssertSql( """ -SELECT CASE - WHEN [c].[Name] IS NOT NULL THEN [c].[Name] -END +SELECT [c].[Name] FROM [Tags] AS [t] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] @@ -4859,9 +4848,7 @@ public override async Task Select_null_conditional_with_inheritance(bool async) AssertSql( """ -SELECT CASE - WHEN [l].[CommanderName] IS NOT NULL THEN [l].[CommanderName] -END +SELECT [l].[CommanderName] FROM [LocustHordes] AS [l] """); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index 735d94600c5..a424bbca373 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -1216,10 +1216,7 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE CASE - WHEN [g].[LeaderNickname] IS NULL THEN NULL - ELSE CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -1235,9 +1232,7 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -1253,9 +1248,7 @@ WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -1266,9 +1259,7 @@ public override async Task Select_null_propagation_optimization7(bool async) // issue #16050 AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] -END +SELECT [g].[LeaderNickname] + [g].[LeaderNickname] FROM [Gears] AS [g] """); } @@ -1469,9 +1460,7 @@ public override async Task Select_null_propagation_works_for_multiple_navigation AssertSql( """ -SELECT CASE - WHEN [c].[Name] IS NOT NULL THEN [c].[Name] -END +SELECT [c].[Name] FROM [Tags] AS [t] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] @@ -4151,9 +4140,7 @@ public override async Task Select_null_conditional_with_inheritance(bool async) AssertSql( """ -SELECT CASE - WHEN [l].[CommanderName] IS NOT NULL THEN [l].[CommanderName] -END +SELECT [l].[CommanderName] FROM [Factions] AS [f] LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] WHERE [l].[Id] IS NOT NULL diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs index f772b926c0f..b355bbe7e47 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs @@ -1848,9 +1848,9 @@ public override async Task LeftJoin_with_Any_on_outer_source_and_projecting_coll SELECT CASE WHEN [s].[OneToOne_Required_PK_Date] IS NULL OR [s].[Level1_Required_Id] IS NULL OR [s].[OneToMany_Required_Inverse2Id] IS NULL OR CASE - WHEN [s].[PeriodEnd0] IS NOT NULL AND [s].[PeriodStart0] IS NOT NULL THEN [s].[PeriodEnd0] + WHEN [s].[PeriodStart0] IS NOT NULL THEN [s].[PeriodEnd0] END IS NULL OR CASE - WHEN [s].[PeriodEnd0] IS NOT NULL AND [s].[PeriodStart0] IS NOT NULL THEN [s].[PeriodStart0] + WHEN [s].[PeriodEnd0] IS NOT NULL THEN [s].[PeriodStart0] END IS NULL THEN 0 WHEN [s].[OneToOne_Required_PK_Date] IS NOT NULL AND [s].[Level1_Required_Id] IS NOT NULL AND [s].[OneToMany_Required_Inverse2Id] IS NOT NULL AND [s].[PeriodEnd0] IS NOT NULL AND [s].[PeriodStart0] IS NOT NULL THEN [s].[Id0] END, [l].[Id], [s].[Id], [s].[Id0], [l4].[Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Level3_Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id], [l4].[PeriodEnd], [l4].[PeriodStart] @@ -1866,9 +1866,9 @@ WHERE [l1].[OneToOne_Required_PK_Date] IS NOT NULL AND [l1].[Level1_Required_Id] WHEN [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL THEN [l2].[Id] END WHERE [l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL AND CASE - WHEN [l2].[PeriodEnd] IS NOT NULL AND [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodEnd] + WHEN [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodEnd] END IS NOT NULL AND CASE - WHEN [l2].[PeriodEnd] IS NOT NULL AND [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodStart] + WHEN [l2].[PeriodEnd] IS NOT NULL THEN [l2].[PeriodStart] END IS NOT NULL ) AS [s] ON [l].[Id] = [s].[Level1_Required_Id] LEFT JOIN ( @@ -2251,9 +2251,9 @@ public override async Task Null_check_in_anonymous_type_projection_should_not_be LEFT JOIN ( SELECT CASE WHEN [l2].[Level2_Required_Id] IS NULL OR [l2].[OneToMany_Required_Inverse3Id] IS NULL OR CASE - WHEN [l2].[PeriodEnd] IS NOT NULL AND [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodEnd] + WHEN [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodEnd] END IS NULL OR CASE - WHEN [l2].[PeriodEnd] IS NOT NULL AND [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodStart] + WHEN [l2].[PeriodEnd] IS NOT NULL THEN [l2].[PeriodStart] END IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c], [l2].[Level3_Name], [l0].[Id], [l2].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] @@ -2282,9 +2282,9 @@ public override async Task Null_check_in_Dto_projection_should_not_be_removed(bo LEFT JOIN ( SELECT CASE WHEN [l2].[Level2_Required_Id] IS NULL OR [l2].[OneToMany_Required_Inverse3Id] IS NULL OR CASE - WHEN [l2].[PeriodEnd] IS NOT NULL AND [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodEnd] + WHEN [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodEnd] END IS NULL OR CASE - WHEN [l2].[PeriodEnd] IS NOT NULL AND [l2].[PeriodStart] IS NOT NULL THEN [l2].[PeriodStart] + WHEN [l2].[PeriodEnd] IS NOT NULL THEN [l2].[PeriodStart] END IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c], [l2].[Level3_Name], [l0].[Id], [l2].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index b9e79770e4d..306d840f375 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -1594,9 +1594,7 @@ public override async Task Null_propagation_optimization6(bool async) """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -4015,9 +4013,7 @@ public override async Task Null_propagation_optimization5(bool async) """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -4991,10 +4987,7 @@ public override async Task Null_propagation_optimization4(bool async) """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd], [g].[PeriodStart], [g].[Rank] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NULL THEN NULL - ELSE CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE CAST(LEN([g].[LeaderNickname]) AS int) = 5 """); } @@ -5147,9 +5140,7 @@ public override async Task Select_null_propagation_optimization7(bool async) AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] -END +SELECT [g].[LeaderNickname] + [g].[LeaderNickname] FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] """); } @@ -5810,9 +5801,7 @@ public override async Task Select_null_propagation_works_for_multiple_navigation AssertSql( """ -SELECT CASE - WHEN [c].[Name] IS NOT NULL THEN [c].[Name] -END +SELECT [c].[Name] FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t0] ON ([g].[Nickname] = [t0].[GearNickName] OR ([g].[Nickname] IS NULL AND [t0].[GearNickName] IS NULL)) AND ([g].[SquadId] = [t0].[GearSquadId] OR ([g].[SquadId] IS NULL AND [t0].[GearSquadId] IS NULL)) @@ -7849,9 +7838,7 @@ public override async Task Select_null_conditional_with_inheritance(bool async) AssertSql( """ -SELECT CASE - WHEN [f].[CommanderName] IS NOT NULL THEN [f].[CommanderName] -END +SELECT [f].[CommanderName] FROM [Factions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [f] """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index cddc6d96f46..5aaa7c36e41 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -1063,9 +1063,7 @@ public override async Task Null_propagation_optimization6(bool async) """ SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank" FROM "Gears" AS "g" -WHERE CASE - WHEN "g"."LeaderNickname" IS NOT NULL THEN length("g"."LeaderNickname") -END = 5 +WHERE length("g"."LeaderNickname") = 5 """); } @@ -3191,9 +3189,7 @@ public override async Task Select_null_propagation_works_for_multiple_navigation AssertSql( """ -SELECT CASE - WHEN "c"."Name" IS NOT NULL THEN "c"."Name" -END +SELECT "c"."Name" FROM "Tags" AS "t" LEFT JOIN "Gears" AS "g" ON "t"."GearNickName" = "g"."Nickname" AND "t"."GearSquadId" = "g"."SquadId" LEFT JOIN "Tags" AS "t0" ON ("g"."Nickname" = "t0"."GearNickName" OR ("g"."Nickname" IS NULL AND "t0"."GearNickName" IS NULL)) AND ("g"."SquadId" = "t0"."GearSquadId" OR ("g"."SquadId" IS NULL AND "t0"."GearSquadId" IS NULL)) @@ -5790,9 +5786,7 @@ public override async Task Select_null_propagation_optimization7(bool async) AssertSql( """ -SELECT CASE - WHEN "g"."LeaderNickname" IS NOT NULL THEN "g"."LeaderNickname" || "g"."LeaderNickname" -END +SELECT "g"."LeaderNickname" || "g"."LeaderNickname" FROM "Gears" AS "g" """); } @@ -6440,9 +6434,7 @@ public override async Task Select_null_conditional_with_inheritance(bool async) AssertSql( """ -SELECT CASE - WHEN "f"."CommanderName" IS NOT NULL THEN "f"."CommanderName" -END +SELECT "f"."CommanderName" FROM "Factions" AS "f" """); } @@ -7517,9 +7509,7 @@ public override async Task Null_propagation_optimization5(bool async) """ SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank" FROM "Gears" AS "g" -WHERE CASE - WHEN "g"."LeaderNickname" IS NOT NULL THEN length("g"."LeaderNickname") -END = 5 +WHERE length("g"."LeaderNickname") = 5 """); } @@ -8297,10 +8287,7 @@ public override async Task Null_propagation_optimization4(bool async) """ SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank" FROM "Gears" AS "g" -WHERE CASE - WHEN "g"."LeaderNickname" IS NULL THEN NULL - ELSE length("g"."LeaderNickname") -END = 5 +WHERE length("g"."LeaderNickname") = 5 """); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs index 8fd9e52daed..780aba7a2dd 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/SpatialQuerySqliteTest.cs @@ -128,10 +128,7 @@ public override async Task AsBinary_with_null_check(bool async) AssertSql( """ -SELECT "p"."Id", CASE - WHEN "p"."Point" IS NULL THEN NULL - ELSE AsBinary("p"."Point") -END AS "Binary" +SELECT "p"."Id", AsBinary("p"."Point") AS "Binary" FROM "PointEntity" AS "p" """); }