From 373016116de1dc22cc71c5716ad6b67406478211 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Tue, 3 Dec 2024 12:01:20 +0100 Subject: [PATCH 1/2] Refactor method/member translation tests into their own suite Closes #34872 --- .../NorthwindFunctionsQueryCosmosTest.cs | 2031 +-- .../Query/NorthwindWhereQueryCosmosTest.cs | 421 - .../BasicTypesQueryCosmosFixture.cs | 28 + .../EnumTranslationsCosmosTest.cs | 281 + .../MathTranslationsCosmosTest.cs | 901 ++ .../MiscellaneousTranslationsCosmosTest.cs | 184 + .../StringTranslationsCosmosTest.cs | 1249 ++ .../TemporalTranslationsCosmosTest.cs | 739 + .../NorthwindFunctionsQueryInMemoryTest.cs | 14 +- .../Query/NorthwindWhereQueryInMemoryTest.cs | 4 - .../BasicTypesQueryInMemoryFixture.cs | 10 + .../EnumTranslationsInMemoryTest.cs | 7 + .../MathTranslationsInMemoryTest.cs | 7 + .../MiscellaneousTranslationsInMemoryTest.cs | 7 + .../StringTranslationsInMemoryTest.cs | 19 + .../TemporalTranslationsInMemoryTest.cs | 7 + ...rthwindFunctionsQueryRelationalTestBase.cs | 30 - .../NorthwindWhereQueryRelationalTestBase.cs | 3 - .../StringTranslationsRelationalTestBase.cs | 83 + .../Query/GearsOfWarQueryTestBase.cs | 855 +- ...orthwindAggregateOperatorsQueryTestBase.cs | 4 +- .../Query/NorthwindFunctionsQueryTestBase.cs | 2003 +-- .../NorthwindNavigationsQueryTestBase.cs | 2 +- .../Query/NorthwindSelectQueryTestBase.cs | 2 +- .../Query/NorthwindWhereQueryTestBase.cs | 306 - .../Query/OwnedQueryTestBase.cs | 2 +- .../BasicTypesQueryFixtureBase.cs | 112 + .../Translations/EnumTranslationsTestBase.cs | 252 + .../Translations/MathTranslationsTestBase.cs | 532 + .../MiscellaneousTranslationsTestBase.cs | 432 + .../StringTranslationsTestBase.cs | 1157 ++ .../TemporalTranslationsTestBase.cs | 595 + .../TestModels/BasicTypesModel/BasicEnum.cs | 11 + .../BasicTypesModel/BasicFlagsEnum.cs | 16 + .../BasicTypesModel/BasicTypesContext.cs | 24 + .../BasicTypesModel/BasicTypesData.cs | 265 + .../BasicTypesModel/BasicTypesEntity.cs | 32 + .../NullableBasicTypesEntity.cs | 32 + .../Query/GearsOfWarQuerySqlServerTest.cs | 9878 +++++------- ...NorthwindFunctionsQuerySqlServer160Test.cs | 2861 +--- .../NorthwindFunctionsQuerySqlServerTest.cs | 2785 +--- .../Query/NorthwindWhereQuerySqlServerTest.cs | 439 - .../Query/TPCGearsOfWarQuerySqlServerTest.cs | 13333 +++++++--------- .../Query/TPTGearsOfWarQuerySqlServerTest.cs | 11368 ++++++------- .../TemporalGearsOfWarQuerySqlServerTest.cs | 1162 +- .../BasicTypesQuerySqlServerFixture.cs | 29 + .../EnumTranslationsSqlServerTest.cs | 309 + .../MathTranslationsSqlServer160Test.cs | 135 + .../MathTranslationsSqlServerTest.cs | 742 + .../MiscellaneousTranslationsSqlServerTest.cs | 812 + .../StringTranslationsSqlServer160Test.cs | 109 + .../StringTranslationsSqlServerTest.cs | 1487 ++ .../TemporalTranslationsSqlServerTest.cs | 909 ++ .../Query/GearsOfWarQuerySqliteTest.cs | 971 +- .../NorthwindFunctionsQuerySqliteTest.cs | 1501 +- .../Query/NorthwindWhereQuerySqliteTest.cs | 218 - .../Query/TPCGearsOfWarQuerySqliteTest.cs | 192 - .../Query/TPTGearsOfWarQuerySqliteTest.cs | 192 - .../BasicTypesQuerySqliteFixture.cs | 12 + .../EnumTranslationsSqliteTest.cs | 311 + .../MathTranslationsSqliteTest.cs | 804 + .../MiscellaneousTranslationsSqliteTest.cs | 283 + .../StringTranslationsSqliteTest.cs | 1517 ++ .../TemporalTranslationsSqliteTest.cs | 766 + 64 files changed, 30828 insertions(+), 34956 deletions(-) create mode 100644 test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs create mode 100644 test/EFCore.Cosmos.FunctionalTests/Query/Translations/EnumTranslationsCosmosTest.cs create mode 100644 test/EFCore.Cosmos.FunctionalTests/Query/Translations/MathTranslationsCosmosTest.cs create mode 100644 test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs create mode 100644 test/EFCore.Cosmos.FunctionalTests/Query/Translations/StringTranslationsCosmosTest.cs create mode 100644 test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/Translations/BasicTypesQueryInMemoryFixture.cs create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/Translations/EnumTranslationsInMemoryTest.cs create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/Translations/MathTranslationsInMemoryTest.cs create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/Translations/MiscellaneousTranslationsInMemoryTest.cs create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/Translations/StringTranslationsInMemoryTest.cs create mode 100644 test/EFCore.InMemory.FunctionalTests/Query/Translations/TemporalTranslationsInMemoryTest.cs create mode 100644 test/EFCore.Relational.Specification.Tests/Query/Translations/StringTranslationsRelationalTestBase.cs create mode 100644 test/EFCore.Specification.Tests/Query/Translations/BasicTypesQueryFixtureBase.cs create mode 100644 test/EFCore.Specification.Tests/Query/Translations/EnumTranslationsTestBase.cs create mode 100644 test/EFCore.Specification.Tests/Query/Translations/MathTranslationsTestBase.cs create mode 100644 test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs create mode 100644 test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs create mode 100644 test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs create mode 100644 test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicEnum.cs create mode 100644 test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs create mode 100644 test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesContext.cs create mode 100644 test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs create mode 100644 test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesEntity.cs create mode 100644 test/EFCore.Specification.Tests/TestModels/BasicTypesModel/NullableBasicTypesEntity.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/BasicTypesQuerySqlServerFixture.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/EnumTranslationsSqlServerTest.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServer160Test.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServerTest.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServer160Test.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServerTest.cs create mode 100644 test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/Translations/BasicTypesQuerySqliteFixture.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/Translations/EnumTranslationsSqliteTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/Translations/MathTranslationsSqliteTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs create mode 100644 test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs index 9eef259e05a..b375c17b8d8 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindFunctionsQueryCosmosTest.cs @@ -24,2055 +24,96 @@ public NorthwindFunctionsQueryCosmosTest( public virtual void Check_all_tests_overridden() => TestHelpers.AssertAllMethodsOverridden(GetType()); - #region String.StartsWith - - public override Task String_StartsWith_Literal(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_StartsWith_Literal(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STARTSWITH(c["ContactName"], "M") -"""); - }); - - public override Task String_StartsWith_Parameter(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_StartsWith_Parameter(a); - - AssertSql( - """ -@pattern='M' - -SELECT VALUE c -FROM root c -WHERE STARTSWITH(c["ContactName"], @pattern) -"""); - }); - - public override Task String_StartsWith_Identity(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_StartsWith_Identity(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STARTSWITH(c["ContactName"], c["ContactName"]) -"""); - }); - - public override Task String_StartsWith_Column(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_StartsWith_Column(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STARTSWITH(c["ContactName"], c["ContactName"]) -"""); - }); - - public override Task String_StartsWith_MethodCall(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_StartsWith_MethodCall(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STARTSWITH(c["ContactName"], "M") -"""); - }); - - public override Task String_StartsWith_with_StringComparison_Ordinal(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_StartsWith_with_StringComparison_Ordinal(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STARTSWITH(c["CompanyName"], "Qu", false) -"""); - }); - - public override Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + public override Task Client_evaluation_of_uncorrelated_method_call(bool async) => Fixture.NoSyncTest( async, async a => { - await base.String_StartsWith_with_StringComparison_OrdinalIgnoreCase(a); + await base.Client_evaluation_of_uncorrelated_method_call(a); AssertSql( """ SELECT VALUE c FROM root c -WHERE STARTSWITH(c["CompanyName"], "Qu", true) +WHERE (((c["$type"] = "OrderDetail") AND (c["UnitPrice"] < 7.0)) AND (10 < c["ProductID"])) """); }); - public override async Task String_StartsWith_with_StringComparison_unsupported(bool async) + public override async Task Order_by_length_twice(bool async) { // Always throws for sync. if (async) { - await base.String_StartsWith_with_StringComparison_unsupported(async); - } - } - - #endregion String.StartsWith - - #region String.EndsWith - - public override Task String_EndsWith_Literal(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_EndsWith_Literal(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ENDSWITH(c["ContactName"], "b") -"""); - }); - - public override Task String_EndsWith_Parameter(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_EndsWith_Parameter(a); - - AssertSql( - """ -@pattern='b' - -SELECT VALUE c -FROM root c -WHERE ENDSWITH(c["ContactName"], @pattern) -"""); - }); - - public override Task String_EndsWith_Identity(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_EndsWith_Identity(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ENDSWITH(c["ContactName"], c["ContactName"]) -"""); - }); - - public override Task String_EndsWith_Column(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_EndsWith_Column(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ENDSWITH(c["ContactName"], c["ContactName"]) -"""); - }); - - public override Task String_EndsWith_MethodCall(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_EndsWith_MethodCall(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ENDSWITH(c["ContactName"], "m") -"""); - }); - - public override Task String_EndsWith_with_StringComparison_Ordinal(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_EndsWith_with_StringComparison_Ordinal(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ENDSWITH(c["ContactName"], "DY", false) -"""); - }); - - public override Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_EndsWith_with_StringComparison_OrdinalIgnoreCase(a); + // Unsupported ORDER BY clause. Issue #27037. + await Assert.ThrowsAsync(() => base.Order_by_length_twice(async)); - AssertSql( - """ + AssertSql( + """ SELECT VALUE c FROM root c -WHERE ENDSWITH(c["ContactName"], "DY", true) +ORDER BY LENGTH(c["id"]), c["id"] """); - }); - - public override async Task String_EndsWith_with_StringComparison_unsupported(bool async) - { - // Always throws for sync. - if (async) - { - await base.String_EndsWith_with_StringComparison_unsupported(async); } } - #endregion String.EndsWith - - #region String.Contains - - public override Task String_Contains_Literal(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_Literal(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE CONTAINS(c["ContactName"], "M") -"""); - }); - - public override Task String_Contains_Identity(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_Identity(a); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE CONTAINS(c["ContactName"], c["ContactName"]) -"""); - }); - - public override Task String_Contains_Column(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_Column(a); + public override async Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed( + () => base.Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(async)); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE CONTAINS(c["CompanyName"], c["ContactName"]) -"""); - }); + AssertSql(); + } - public override Task String_Contains_with_StringComparison_Ordinal(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_with_StringComparison_Ordinal(a); + public override Task Sum_over_round_works_correctly_in_projection(bool async) + => AssertTranslationFailed(() => base.Sum_over_round_works_correctly_in_projection(async)); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE CONTAINS(c["ContactName"], "M", false) -"""); - }); + public override Task Sum_over_round_works_correctly_in_projection_2(bool async) + => AssertTranslationFailed(() => base.Sum_over_round_works_correctly_in_projection_2(async)); - public override Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_with_StringComparison_OrdinalIgnoreCase(a); + public override Task Sum_over_truncate_works_correctly_in_projection(bool async) + => AssertTranslationFailed(() => base.Sum_over_truncate_works_correctly_in_projection(async)); - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE CONTAINS(c["ContactName"], "M", true) -"""); - }); + public override Task Sum_over_truncate_works_correctly_in_projection_2(bool async) + => AssertTranslationFailed(() => base.Sum_over_truncate_works_correctly_in_projection_2(async)); - public override async Task String_Contains_with_StringComparison_unsupported(bool async) + public override async Task Where_functions_nested(bool async) { - // Always throws for sync. - if (async) - { - await base.String_Contains_with_StringComparison_unsupported(async); - } - } + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Where_functions_nested(async)); - #endregion String.Contains + AssertSql(); + } - public override Task String_FirstOrDefault_MethodCall(bool async) + public override Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) => Fixture.NoSyncTest( async, async a => { - await base.String_FirstOrDefault_MethodCall(a); + await base.Static_equals_nullable_datetime_compared_to_non_nullable(a); AssertSql( """ -SELECT VALUE c -FROM root c -WHERE (LEFT(c["ContactName"], 1) = "A") -"""); - }); - - public override Task String_LastOrDefault_MethodCall(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_LastOrDefault_MethodCall(a); +@arg='1996-07-04T00:00:00' - AssertSql( - """ SELECT VALUE c FROM root c -WHERE (RIGHT(c["ContactName"], 1) = "s") +WHERE ((c["$type"] = "Order") AND (c["OrderDate"] = @arg)) """); }); - public override Task String_Contains_MethodCall(bool async) + public override Task Static_equals_int_compared_to_long(bool async) => Fixture.NoSyncTest( async, async a => { - await base.String_Contains_MethodCall(a); + await base.Static_equals_int_compared_to_long(a); AssertSql( """ SELECT VALUE c FROM root c -WHERE CONTAINS(c["ContactName"], "M") +WHERE ((c["$type"] = "Order") AND false) """); }); - public override async Task String_Compare_simple_zero(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_simple_zero(async)); - - AssertSql(); - } - - public override async Task String_Compare_simple_one(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_simple_one(async)); - - AssertSql(); - } - - public override async Task String_compare_with_parameter(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_compare_with_parameter(async)); - - AssertSql(); - } - - public override async Task String_Compare_simple_more_than_one(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_simple_more_than_one(async)); - - AssertSql(); - } - - public override async Task String_Compare_nested(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_nested(async)); - - AssertSql(); - } - - public override async Task String_Compare_multi_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_multi_predicate(async)); - - AssertSql(); - } - - public override async Task String_Compare_to_simple_zero(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_to_simple_zero(async)); - - AssertSql(); - } - - public override async Task String_Compare_to_simple_one(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_to_simple_one(async)); - - AssertSql(); - } - - public override async Task String_compare_to_with_parameter(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_compare_to_with_parameter(async)); - - AssertSql(); - } - - public override async Task String_Compare_to_simple_more_than_one(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_to_simple_more_than_one(async)); - - AssertSql(); - } - - public override async Task String_Compare_to_nested(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_to_nested(async)); - - AssertSql(); - } - - public override async Task String_Compare_to_multi_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.String_Compare_to_multi_predicate(async)); - - AssertSql(); - } - - public override Task Where_math_abs1(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_abs1(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Product") AND (ABS(c["ProductID"]) > 10)) -"""); - }); - - public override Task Where_math_abs2(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_abs2(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["UnitPrice"] < 7.0)) AND (ABS(c["Quantity"]) > 10)) -"""); - }); - - public override Task Where_math_abs3(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_abs3(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (ABS(c["UnitPrice"]) > 10.0)) -"""); - }); - - public override Task Where_math_abs_uncorrelated(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_abs_uncorrelated(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["UnitPrice"] < 7.0)) AND (10 < c["ProductID"])) -"""); - }); - - public override async Task Where_math_ceiling1(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_ceiling1(async)); - - AssertSql(); - } - - public override Task Where_math_ceiling2(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_ceiling2(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (CEILING(c["UnitPrice"]) > 10.0)) -"""); - }); - - public override Task Where_math_floor(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_floor(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (FLOOR(c["UnitPrice"]) > 10.0)) -"""); - }); - - public override async Task Where_math_power(bool async) - { - // Convert node. Issue #25120. - await AssertTranslationFailed(() => base.Where_math_power(async)); - - AssertSql(); - } - - public override async Task Where_math_square(bool async) - { - // Convert node. Issue #25120. - await AssertTranslationFailed(() => base.Where_math_square(async)); - - AssertSql(); - } - - public override Task Where_math_round(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_round(async); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (ROUND(c["UnitPrice"]) > 10.0)) -"""); - }); - - public override Task Sum_over_round_works_correctly_in_projection(bool async) - => AssertTranslationFailed(() => base.Sum_over_round_works_correctly_in_projection(async)); - - public override Task Sum_over_round_works_correctly_in_projection_2(bool async) - => AssertTranslationFailed(() => base.Sum_over_round_works_correctly_in_projection_2(async)); - - public override Task Sum_over_truncate_works_correctly_in_projection(bool async) - => AssertTranslationFailed(() => base.Sum_over_truncate_works_correctly_in_projection(async)); - - public override Task Sum_over_truncate_works_correctly_in_projection_2(bool async) - => AssertTranslationFailed(() => base.Sum_over_truncate_works_correctly_in_projection_2(async)); - - public override Task Select_math_round_int(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Select_math_round_int(a); - - AssertSql( - """ -SELECT VALUE c["OrderID"] -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderID"] < 10250)) -"""); - }); - - public override Task Select_math_truncate_int(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Select_math_truncate_int(a); - - AssertSql( - """ -SELECT VALUE c["OrderID"] -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderID"] < 10250)) -"""); - }); - - public override async Task Where_math_round2(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_round2(async)); - - AssertSql(); - } - - public override Task Where_math_truncate(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_truncate(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["Quantity"] < 5)) AND (TRUNC(c["UnitPrice"]) > 10.0)) -"""); - }); - - public override async Task Where_math_exp(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_exp(async)); - - AssertSql(); - } - - public override async Task Where_math_log10(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_log10(async)); - - AssertSql(); - } - - public override async Task Where_math_log(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_log(async)); - - AssertSql(); - } - - public override async Task Where_math_log_new_base(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_log_new_base(async)); - - AssertSql(); - } - - public override async Task Where_math_sqrt(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_sqrt(async)); - - AssertSql(); - } - - public override async Task Where_math_acos(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_acos(async)); - - AssertSql(); - } - - public override async Task Where_math_asin(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_asin(async)); - - AssertSql(); - } - - public override async Task Where_math_atan(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_atan(async)); - - AssertSql(); - } - - public override async Task Where_math_atan2(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_atan2(async)); - - AssertSql(); - } - - public override async Task Where_math_cos(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_cos(async)); - - AssertSql(); - } - - public override async Task Where_math_sin(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_sin(async)); - - AssertSql(); - } - - public override async Task Where_math_tan(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_tan(async)); - - AssertSql(); - } - - public override Task Where_math_sign(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_math_sign(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SIGN(c["Discount"]) > 0)) -"""); - }); - - public override async Task Where_math_min(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_min(async)); - - AssertSql(); - } - - public override async Task Where_math_min_nested(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_min(async)); - - AssertSql(); - } - - public override async Task Where_math_min_nested_twice(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_min(async)); - - AssertSql(); - } - - public override async Task Where_math_max(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_max(async)); - - AssertSql(); - } - - public override async Task Where_math_max_nested(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_max(async)); - - AssertSql(); - } - - public override async Task Where_math_max_nested_twice(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_max(async)); - - AssertSql(); - } - - public override async Task Where_math_degrees(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_degrees(async)); - - AssertSql(); - } - - public override async Task Where_math_radians(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_math_radians(async)); - - AssertSql(); - } - - public override async Task Where_mathf_abs1(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_mathf_abs1(async)); - - AssertSql(); - } - - public override Task Where_mathf_ceiling1(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_ceiling1(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["UnitPrice"] < 7.0)) AND (CEILING(c["Discount"]) > 0.0)) -"""); - }); - - public override async Task Where_mathf_floor(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_mathf_floor(async)); - - AssertSql(); - } - - public override Task Where_mathf_power(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_power(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "OrderDetail") AND (POWER(c["Discount"], 3.0) > 0.005)) -"""); - }); - - public override Task Where_mathf_square(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_square(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "OrderDetail") AND (POWER(c["Discount"], 2.0) > 0.05)) -"""); - }); - - public override async Task Where_mathf_round2(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_mathf_round2(async)); - - AssertSql(); - } - - public override async Task Where_mathf_truncate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_mathf_truncate(async)); - - AssertSql(); - } - - public override Task Where_mathf_exp(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_exp(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (EXP(c["Discount"]) > 1.0)) -"""); - }); - - public override Task Where_mathf_log10(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_log10(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND ((c["OrderID"] = 11077) AND (c["Discount"] > 0.0))) AND (LOG10(c["Discount"]) < 0.0)) -"""); - }); - - public override Task Where_mathf_log(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_log(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND ((c["OrderID"] = 11077) AND (c["Discount"] > 0.0))) AND (LOG(c["Discount"]) < 0.0)) -"""); - }); - - public override Task Where_mathf_log_new_base(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_log_new_base(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND ((c["OrderID"] = 11077) AND (c["Discount"] > 0.0))) AND (LOG(c["Discount"], 7.0) < -1.0)) -"""); - }); - - public override Task Where_mathf_sqrt(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_sqrt(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SQRT(c["Discount"]) > 0.0)) -"""); - }); - - public override Task Where_mathf_acos(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_acos(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ACOS(c["Discount"]) > 1.0)) -"""); - }); - - public override Task Where_mathf_asin(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_asin(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ASIN(c["Discount"]) > 0.0)) -"""); - }); - - public override Task Where_mathf_atan(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_atan(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ATAN(c["Discount"]) > 0.0)) -"""); - }); - - public override Task Where_mathf_atan2(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_atan2(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (ATN2(c["Discount"], 1.0) > 0.0)) -"""); - }); - - public override Task Where_mathf_cos(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_cos(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (COS(c["Discount"]) > 0.0)) -"""); - }); - - public override Task Where_mathf_sin(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_sin(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SIN(c["Discount"]) > 0.0)) -"""); - }); - - public override Task Where_mathf_tan(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_tan(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (TAN(c["Discount"]) > 0.0)) -"""); - }); - - public override Task Where_mathf_sign(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_sign(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (SIGN(c["Discount"]) > 0)) -"""); - }); - - public override Task Where_mathf_degrees(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_degrees(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (DEGREES(c["Discount"]) > 0.0)) -"""); - }); - - public override Task Where_mathf_radians(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_mathf_radians(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (((c["$type"] = "OrderDetail") AND (c["OrderID"] = 11077)) AND (RADIANS(c["Discount"]) > 0.0)) -"""); - }); - - public override async Task Where_guid_newguid(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_guid_newguid(async)); - - AssertSql(); - } - - public override Task Where_string_to_upper(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_to_upper(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (UPPER(c["id"]) = "ALFKI") -"""); - }); - - public override Task Where_string_to_lower(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_to_lower(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (LOWER(c["id"]) = "alfki") -"""); - }); - - public override async Task Where_functions_nested(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_functions_nested(async)); - - AssertSql(); - } - - public override async Task Convert_ToBoolean(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToBoolean(async)); - - AssertSql(); - } - - public override async Task Convert_ToByte(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToByte(async)); - - AssertSql(); - } - - public override async Task Convert_ToDecimal(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToDecimal(async)); - - AssertSql(); - } - - public override async Task Convert_ToDouble(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToDouble(async)); - - AssertSql(); - } - - public override async Task Convert_ToInt16(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToInt16(async)); - - AssertSql(); - } - - public override async Task Convert_ToInt32(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToInt32(async)); - - AssertSql(); - } - - public override async Task Convert_ToInt64(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToInt64(async)); - - AssertSql(); - } - - public override async Task Convert_ToString(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Convert_ToString(async)); - - AssertSql(); - } - - public override Task Indexof_with_emptystring(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Indexof_with_emptystring(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (INDEX_OF(c["Region"], "") = 0) -"""); - }); - - public override Task Indexof_with_one_constant_arg(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Indexof_with_one_constant_arg(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (INDEX_OF(c["ContactName"], "a") = 1) -"""); - }); - - public override Task Indexof_with_one_parameter_arg(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Indexof_with_one_parameter_arg(a); - - AssertSql( - """ -@pattern='a' - -SELECT VALUE c -FROM root c -WHERE (INDEX_OF(c["ContactName"], @pattern) = 1) -"""); - }); - - public override Task Indexof_with_constant_starting_position(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Indexof_with_constant_starting_position(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (INDEX_OF(c["ContactName"], "a", 2) = 4) -"""); - }); - - public override Task Indexof_with_parameter_starting_position(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Indexof_with_parameter_starting_position(a); - - AssertSql( - """ -@start='2' - -SELECT VALUE c -FROM root c -WHERE (INDEX_OF(c["ContactName"], "a", @start) = 4) -"""); - }); - - public override Task Replace_with_emptystring(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Replace_with_emptystring(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (REPLACE(c["ContactName"], "ia", "") = "Mar Anders") -"""); - }); - - public override Task Replace_using_property_arguments(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Replace_using_property_arguments(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (REPLACE(c["ContactName"], c["ContactName"], c["id"]) = c["id"]) -"""); - }); - - public override Task Substring_with_one_arg_with_zero_startindex(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_one_arg_with_zero_startindex(a); - - AssertSql( - """ -SELECT VALUE c["ContactName"] -FROM root c -WHERE (SUBSTRING(c["id"], 0, LENGTH(c["id"])) = "ALFKI") -"""); - }); - - public override Task Substring_with_one_arg_with_constant(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_one_arg_with_constant(a); - - AssertSql( - """ -SELECT VALUE c["ContactName"] -FROM root c -WHERE (SUBSTRING(c["id"], 1, LENGTH(c["id"])) = "LFKI") -"""); - }); - - public override Task Substring_with_one_arg_with_closure(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_one_arg_with_closure(a); - - AssertSql( - """ -@start='2' - -SELECT VALUE c["ContactName"] -FROM root c -WHERE (SUBSTRING(c["id"], @start, LENGTH(c["id"])) = "FKI") -"""); - }); - - public override Task Substring_with_two_args_with_zero_startindex(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_two_args_with_zero_startindex(a); - - AssertSql( - """ -SELECT VALUE LEFT(c["ContactName"], 3) -FROM root c -WHERE (c["id"] = "ALFKI") -"""); - }); - - public override Task Substring_with_two_args_with_zero_length(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_two_args_with_zero_length(a); - - AssertSql( - """ -SELECT VALUE SUBSTRING(c["ContactName"], 2, 0) -FROM root c -WHERE (c["id"] = "ALFKI") -"""); - }); - - public override Task Substring_with_two_args_with_constant(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_two_args_with_constant(a); - - AssertSql( - """ -SELECT VALUE SUBSTRING(c["ContactName"], 1, 3) -FROM root c -WHERE (c["id"] = "ALFKI") -"""); - }); - - public override Task Substring_with_two_args_with_closure(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_two_args_with_closure(a); - - AssertSql( - """ -@start='2' - -SELECT VALUE SUBSTRING(c["ContactName"], @start, 3) -FROM root c -WHERE (c["id"] = "ALFKI") -"""); - }); - - public override Task Substring_with_two_args_with_Index_of(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Substring_with_two_args_with_Index_of(a); - - AssertSql( - """ -SELECT VALUE SUBSTRING(c["ContactName"], INDEX_OF(c["ContactName"], "a"), 3) -FROM root c -WHERE (c["id"] = "ALFKI") -"""); - }); - - public override async Task IsNullOrEmpty_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.IsNullOrEmpty_in_predicate(async)); - - AssertSql(); - } - - public override async Task IsNullOrEmpty_negated_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.IsNullOrEmpty_negated_in_predicate(async)); - - AssertSql(); - } - - public override async Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(async)); - - AssertSql(); - } - - public override Task IsNullOrEmpty_in_projection(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.IsNullOrEmpty_in_projection(a); - - AssertSql( - """ -SELECT c["id"], c["Region"] -FROM root c -"""); - }); - - public override Task IsNullOrEmpty_negated_in_projection(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.IsNullOrEmpty_negated_in_projection(a); - - AssertSql( - """ -SELECT c["id"], c["Region"] -FROM root c -"""); - }); - - public override async Task IsNullOrWhiteSpace_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.IsNullOrWhiteSpace_in_predicate(async)); - - AssertSql(); - } - - public override Task TrimStart_without_arguments_in_predicate(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.TrimStart_without_arguments_in_predicate(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (LTRIM(c["ContactTitle"]) = "Owner") -"""); - }); - - public override async Task TrimStart_with_char_argument_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.TrimStart_with_char_argument_in_predicate(async)); - - AssertSql(); - } - - public override async Task TrimStart_with_char_array_argument_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.TrimStart_with_char_array_argument_in_predicate(async)); - - AssertSql(); - } - - public override Task TrimEnd_without_arguments_in_predicate(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.TrimEnd_without_arguments_in_predicate(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (RTRIM(c["ContactTitle"]) = "Owner") -"""); - }); - - public override async Task TrimEnd_with_char_argument_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.TrimEnd_with_char_argument_in_predicate(async)); - - AssertSql(); - } - - public override async Task TrimEnd_with_char_array_argument_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.TrimEnd_with_char_array_argument_in_predicate(async)); - - AssertSql(); - } - - public override Task Trim_without_argument_in_predicate(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Trim_without_argument_in_predicate(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (TRIM(c["ContactTitle"]) = "Owner") -"""); - }); - - public override async Task Trim_with_char_argument_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Trim_with_char_argument_in_predicate(async)); - - AssertSql(); - } - - public override async Task Trim_with_char_array_argument_in_predicate(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Trim_with_char_array_argument_in_predicate(async)); - - AssertSql(); - } - - public override async Task Order_by_length_twice(bool async) - { - // Always throws for sync. - if (async) - { - // Unsupported ORDER BY clause. Issue #27037. - await Assert.ThrowsAsync(() => base.Order_by_length_twice(async)); - - AssertSql( - """ -SELECT VALUE c -FROM root c -ORDER BY LENGTH(c["id"]), c["id"] -"""); - } - } - - public override async Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed( - () => base.Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(async)); - - AssertSql(); - } - - public override Task Static_string_equals_in_predicate(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Static_string_equals_in_predicate(a); - - AssertSql("ReadItem(None, ANATR)"); - }); - - public override Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Static_equals_nullable_datetime_compared_to_non_nullable(a); - - AssertSql( - """ -@arg='1996-07-04T00:00:00' - -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderDate"] = @arg)) -"""); - }); - - public override Task Static_equals_int_compared_to_long(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Static_equals_int_compared_to_long(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND false) -"""); - }); - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Projecting_Math_Truncate_and_ordering_by_it_twice(async)); - - AssertSql(); - } - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Projecting_Math_Truncate_and_ordering_by_it_twice2(async)); - - AssertSql(); - } - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Projecting_Math_Truncate_and_ordering_by_it_twice3(async)); - - AssertSql(); - } - - public override async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.DateTime_Compare_to_simple_zero(async, compareTo)); - - AssertSql(); - } - - public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.TimeSpan_Compare_to_simple_zero(async, compareTo)); - - AssertSql(); - } - - public override async Task Int_Compare_to_simple_zero(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Int_Compare_to_simple_zero(async)); - - AssertSql(); - } - - public override Task Regex_IsMatch_MethodCall(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Regex_IsMatch_MethodCall(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch(c["id"], "^T") -"""); - }); - - public override Task Regex_IsMatch_MethodCall_constant_input(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Regex_IsMatch_MethodCall_constant_input(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch("ALFKI", c["id"]) -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Option_None(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.None))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch(c["id"], "^T") -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Option_IgnoreCase(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnoreCase))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch(c["id"], "^T", "i") -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Option_Multiline(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.Multiline))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch(c["id"], "^T", "m") -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Option_Singleline(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.Singleline))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch(c["id"], "^T", "s") -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Option_IgnorePatternWhitespace(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnorePatternWhitespace))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch(c["id"], "^T", "x") -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Options_IgnoreCase_And_IgnorePatternWhitespace(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where( - o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE RegexMatch(c["id"], "^T", "ix") -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Unsupported_Option(bool async) - => AssertTranslationFailed( - () => AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.RightToLeft)))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_With_Any_Unsupported_Option(bool async) - => AssertTranslationFailed( - () => AssertQuery( - async, - ss => ss.Set() - .Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnoreCase | RegexOptions.RightToLeft)))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Case_insensitive_string_comparison_instance(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.Equals("alFkI", StringComparison.OrdinalIgnoreCase))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STRINGEQUALS(c["id"], "alFkI", true) -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Case_insensitive_string_comparison_static(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Equals(c.CustomerID, "alFkI", StringComparison.OrdinalIgnoreCase))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STRINGEQUALS(c["id"], "alFkI", true) -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Case_sensitive_string_comparison_instance(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.Equals("ALFKI", StringComparison.Ordinal))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STRINGEQUALS(c["id"], "ALFKI") -"""); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Case_sensitive_string_comparison_static(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Equals(c.CustomerID, "ALFKI", StringComparison.Ordinal))); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STRINGEQUALS(c["id"], "ALFKI") -"""); - }); - - public override async Task Datetime_subtraction_TotalDays(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Datetime_subtraction_TotalDays(async)); - - AssertSql(); - } - - public override Task String_Contains_constant_with_whitespace(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_constant_with_whitespace(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE CONTAINS(c["ContactName"], " ") -"""); - }); - - public override Task String_Contains_parameter_with_whitespace(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_parameter_with_whitespace(a); - - AssertSql( - """ -@pattern=' ' - -SELECT VALUE c -FROM root c -WHERE CONTAINS(c["ContactName"], @pattern) -"""); - }); - - public override Task Select_mathf_round(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Select_mathf_round(a); - - AssertSql( - """ -SELECT VALUE c["OrderID"] -FROM root c -WHERE ((c["$type"] = "Order") AND (c["OrderID"] < 10250)) -"""); - }); - - public override Task Select_mathf_round2(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Select_mathf_round2(a); - - AssertSql( - """ -SELECT VALUE c["UnitPrice"] -FROM root c -WHERE ((c["$type"] = "OrderDetail") AND (c["Quantity"] < 5)) -"""); - }); - - public override Task Select_mathf_truncate(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Select_mathf_truncate(a); - - AssertSql( - """ -SELECT VALUE c["UnitPrice"] -FROM root c -WHERE ((c["$type"] = "OrderDetail") AND (c["Quantity"] < 5)) -"""); - }); - - public override Task String_Contains_negated_in_predicate(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_negated_in_predicate(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE NOT(CONTAINS(c["CompanyName"], c["ContactName"])) -"""); - }); - - public override Task String_Contains_negated_in_projection(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_negated_in_projection(a); - - AssertSql( - """ -SELECT VALUE -{ - "Id" : c["id"], - "Value" : NOT(CONTAINS(c["CompanyName"], c["ContactName"])) -} -FROM root c -"""); - }); - - [ConditionalTheory(Skip = "issue #33858")] - public override Task String_Contains_in_projection(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.String_Contains_in_projection(a); - - AssertSql(""); - }); - - public override Task String_Join_over_non_nullable_column(bool async) - => AssertTranslationFailed(() => base.String_Join_over_non_nullable_column(async)); - - public override Task String_Join_with_predicate(bool async) - => AssertTranslationFailed(() => base.String_Join_with_predicate(async)); - - public override Task String_Join_with_ordering(bool async) - => AssertTranslationFailed(() => base.String_Join_with_ordering(async)); - - public override Task String_Join_over_nullable_column(bool async) - => AssertTranslationFailed(() => base.String_Join_over_nullable_column(async)); - - public override Task String_Join_non_aggregate(bool async) - => AssertTranslationFailed(() => base.String_Join_non_aggregate(async)); - - public override Task String_Concat(bool async) - => AssertTranslationFailed(() => base.String_Concat(async)); - - public override Task Where_DateOnly_FromDateTime(bool async) - => AssertTranslationFailed(() => base.Where_DateOnly_FromDateTime(async)); - - public override Task Select_ToString_IndexOf(bool async) - => AssertTranslationFailed(() => base.Select_ToString_IndexOf(async)); - - public override Task Select_IndexOf_ToString(bool async) - => AssertTranslationFailed(() => base.Select_IndexOf_ToString(async)); - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs index ed57b6165a0..07f8df00f9f 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/NorthwindWhereQueryCosmosTest.cs @@ -946,34 +946,6 @@ public override async Task Where_client_deep_inside_predicate_and_server_top_lev AssertSql(); } - public override Task Where_equals_method_string(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_equals_method_string(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (c["City"] = "London") -"""); - }); - - public override Task Where_equals_method_string_with_ignore_case(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_equals_method_string_with_ignore_case(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE STRINGEQUALS(c["City"], "London", true) -"""); - }); - public override Task Where_equals_method_int(bool async) => Fixture.NoSyncTest( async, async a => @@ -1146,254 +1118,6 @@ FROM root c """); }); - public override Task Where_string_length(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_length(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (LENGTH(c["City"]) = 6) -"""); - }); - - public override Task Where_string_indexof(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_indexof(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (INDEX_OF(c["City"], "Sea") != -1) -"""); - }); - - public override Task Where_string_replace(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_replace(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (REPLACE(c["City"], "Sea", "Rea") = "Reattle") -"""); - }); - - public override Task Where_string_substring(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_substring(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE (SUBSTRING(c["City"], 1, 2) = "ea") -"""); - }); - - public override async Task Where_datetime_now(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_datetime_now(async)); - - AssertSql(); - } - - public override Task Where_datetime_utcnow(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_utcnow(a); - - AssertSql( - """ -@myDatetime='2015-04-10T00:00:00' - -SELECT VALUE c -FROM root c -WHERE (GetCurrentDateTime() != @myDatetime) -"""); - }); - - public override Task Where_datetimeoffset_utcnow(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetimeoffset_utcnow(a); - - AssertSql( - """ -@myDatetimeOffset='2015-04-10T00:00:00-08:00' - -SELECT VALUE c -FROM root c -WHERE (GetCurrentDateTime() != @myDatetimeOffset) -"""); - }); - - public override async Task Where_datetime_today(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_datetime_today(async)); - - AssertSql(); - } - - public override async Task Where_datetime_date_component(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_datetime_date_component(async)); - - AssertSql(); - } - - public override Task Where_date_add_year_constant_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_date_add_year_constant_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("yyyy", DateTimeAdd("yyyy", -1, c["OrderDate"])) = 1997)) -"""); - }); - - public override Task Where_datetime_year_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_year_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("yyyy", c["OrderDate"]) = 1998)) -"""); - }); - - public override Task Where_datetime_month_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_month_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("mm", c["OrderDate"]) = 4)) -"""); - }); - - public override async Task Where_datetime_dayOfYear_component(bool async) - { - // DateTime.DayOfYear not supported by Cosmos - await AssertTranslationFailed(() => base.Where_datetime_dayOfYear_component(async)); - - AssertSql(); - } - - public override Task Where_datetime_day_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_day_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("dd", c["OrderDate"]) = 4)) -"""); - }); - - public override Task Where_datetime_hour_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_hour_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("hh", c["OrderDate"]) = 0)) -"""); - }); - - public override Task Where_datetime_minute_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_minute_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("mi", c["OrderDate"]) = 0)) -"""); - }); - - public override Task Where_datetime_second_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_second_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("ss", c["OrderDate"]) = 0)) -"""); - }); - - public override Task Where_datetime_millisecond_component(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_datetime_millisecond_component(a); - - AssertSql( - """ -SELECT VALUE c -FROM root c -WHERE ((c["$type"] = "Order") AND (DateTimePart("ms", c["OrderDate"]) = 0)) -"""); - }); - - public override async Task Where_datetimeoffset_now_component(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_datetimeoffset_now_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_utcnow_component(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow_component(async)); - - AssertSql(); - } - public override Task Where_simple_reversed(bool async) => Fixture.NoSyncTest( async, async a => @@ -1922,90 +1646,6 @@ public override Task Where_expression_invoke_3(bool async) AssertSql("ReadItem(None, ALFKI)"); }); - public override async Task Where_concat_string_int_comparison1(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_concat_string_int_comparison1(async)); - - AssertSql(); - } - - public override async Task Where_concat_string_int_comparison2(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_concat_string_int_comparison2(async)); - - AssertSql(); - } - - public override async Task Where_concat_string_int_comparison3(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_concat_string_int_comparison3(async)); - - AssertSql(); - } - - public override async Task Where_concat_string_int_comparison4(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Where_concat_string_int_comparison4(async)); - - AssertSql( - ); - } - - public override Task Where_string_concat_method_comparison(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_concat_method_comparison(a); - - AssertSql( - """ -@i='A' - -SELECT VALUE c["id"] -FROM root c -WHERE ((@i || c["id"]) = "AAROUT") -"""); - }); - - public override Task Where_string_concat_method_comparison_2(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_concat_method_comparison_2(a); - - AssertSql( - """ -@i='A' -@j='B' - -SELECT VALUE c["id"] -FROM root c -WHERE ((@i || (@j || c["id"])) = "ABANATR") -"""); - }); - - public override Task Where_string_concat_method_comparison_3(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_string_concat_method_comparison_3(a); - - AssertSql( - """ -@i='A' -@j='B' -@k='C' - -SELECT VALUE c["id"] -FROM root c -WHERE ((@i || (@j || (@k || c["id"]))) = "ABCANTON") -"""); - }); - public override Task Where_ternary_boolean_condition_true(bool async) => Fixture.NoSyncTest( async, async a => @@ -2268,20 +1908,6 @@ public override async Task Where_subquery_FirstOrDefault_compared_to_entity(bool AssertSql(); } - public override Task Time_of_day_datetime(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Time_of_day_datetime(a); - - AssertSql( - """ -SELECT VALUE c["OrderDate"] -FROM root c -WHERE (c["$type"] = "Order") -"""); - }); - public override Task TypeBinary_short_circuit(bool async) => Fixture.NoSyncTest( async, async a => @@ -2328,22 +1954,6 @@ public override async Task Filter_non_nullable_value_after_FirstOrDefault_on_emp AssertSql(); } - public override async Task Like_with_non_string_column_using_ToString(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Like_with_non_string_column_using_ToString(async)); - - AssertSql(); - } - - public override async Task Like_with_non_string_column_using_double_cast(bool async) - { - // Cosmos client evaluation. Issue #17246. - await AssertTranslationFailed(() => base.Like_with_non_string_column_using_double_cast(async)); - - AssertSql(); - } - public override async Task Using_same_parameter_twice_in_query_generates_one_sql_parameter(bool async) { // Cosmos client evaluation. Issue #17246. @@ -2706,21 +2316,6 @@ FROM root c """); }); - public override async Task Where_Like_and_comparison(bool async) - { - await AssertTranslationFailed(() => base.Where_Like_and_comparison(async)); - - AssertSql(); - } - - public override async Task Where_Like_or_comparison(bool async) - { - await AssertTranslationFailed(() => base.Where_Like_or_comparison(async)); - - AssertSql( - ); - } - public override Task GetType_on_non_hierarchy1(bool async) => Fixture.NoSyncTest( async, async a => @@ -3145,22 +2740,6 @@ FROM root c SELECT VALUE c["id"] FROM root c WHERE (c["id"] = @entity_equality_customer_CustomerID) -"""); - }); - - public override Task Where_concat_string_string_comparison(bool async) - => Fixture.NoSyncTest( - async, async a => - { - await base.Where_concat_string_string_comparison(a); - - AssertSql( - """ -@i='A' - -SELECT VALUE c["id"] -FROM root c -WHERE ((@i || c["id"]) = "AALFKI") """); }); diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs new file mode 100644 index 00000000000..bd958a2474c --- /dev/null +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs @@ -0,0 +1,28 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class BasicTypesQueryCosmosFixture : BasicTypesQueryFixtureBase +{ + protected override ITestStoreFactory TestStoreFactory => CosmosTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + => builder.ConfigureWarnings(o => o.Ignore(CosmosEventId.NoPartitionKeyDefined)); + + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) + { + base.OnModelCreating(modelBuilder, context); + + modelBuilder.Entity().ToContainer(nameof(BasicTypesEntity)); + modelBuilder.Entity().ToContainer(nameof(NullableBasicTypesEntity)); + } + + public Task NoSyncTest(bool async, Func testCode) + => CosmosTestHelpers.Instance.NoSyncTest(async, testCode); +} diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/EnumTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/EnumTranslationsCosmosTest.cs new file mode 100644 index 00000000000..efa1de7e95f --- /dev/null +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/EnumTranslationsCosmosTest.cs @@ -0,0 +1,281 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class EnumTranslationsCosmosTest : EnumTranslationsTestBase +{ + public EnumTranslationsCosmosTest(BasicTypesQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equality + + public override Task Equality_to_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equality_to_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["Enum"] = 0) +"""); + }); + + public override Task Equality_to_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equality_to_parameter(a); + + AssertSql( + """ +@basicEnum=? + +SELECT VALUE c +FROM root c +WHERE (c["Enum"] = @basicEnum) +"""); + }); + + public override Task Equality_nullable_enum_to_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equality_nullable_enum_to_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["Enum"] = 0) +"""); + }); + + public override Task Equality_nullable_enum_to_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equality_nullable_enum_to_parameter(a); + + AssertSql( + """ +@basicEnum=? + +SELECT VALUE c +FROM root c +WHERE (c["Enum"] = @basicEnum) +"""); + }); + + public override Task Equality_nullable_enum_to_null_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equality_nullable_enum_to_null_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["Enum"] = null) +"""); + }); + + public override Task Equality_nullable_enum_to_null_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equality_nullable_enum_to_null_parameter(a); + + AssertSql( + """ +@basicEnum=? + +SELECT VALUE c +FROM root c +WHERE (c["Enum"] = @basicEnum) +"""); + }); + + public override Task Equality_nullable_enum_to_nullable_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equality_nullable_enum_to_nullable_parameter(a); + + AssertSql( + """ +@basicEnum=? + +SELECT VALUE c +FROM root c +WHERE (c["Enum"] = @basicEnum) +"""); + }); + + #endregion Equality + + public override Task Bitwise_and_enum_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_and_enum_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & 1) > 0) +""", + // + """ +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & 1) = 1) +"""); + }); + + public override async Task Bitwise_and_integral_constant(bool async) + { + // Always throws for sync. + if (async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Bitwise_and_integral_constant(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & 8) = 8) +"""); + } + } + + public override Task Bitwise_and_nullable_enum_with_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_and_nullable_enum_with_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & 8) > 0) +"""); + }); + + public override Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Where_bitwise_and_nullable_enum_with_null_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & null) > 0) +"""); + }); + + public override Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(a); + + AssertSql( + """ +@flagsEnum=? + +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & @flagsEnum) > 0) +"""); + }); + + public override Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(a); + + AssertSql( + """ +@flagsEnum=? + +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & @flagsEnum) > 0) +""", + // + """ +@flagsEnum=? + +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] & @flagsEnum) > 0) +"""); + }); + + public override Task Bitwise_or(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_or(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["FlagsEnum"] | 8) > 0) +"""); + }); + + public override Task Bitwise_projects_values_in_select(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Bitwise_projects_values_in_select(a); + + AssertSql( + """ +SELECT VALUE +{ + "BitwiseTrue" : ((c["FlagsEnum"] & 8) = 8), + "BitwiseFalse" : ((c["FlagsEnum"] & 8) = 4), + "BitwiseValue" : (c["FlagsEnum"] & 8) +} +FROM root c +WHERE ((c["FlagsEnum"] & 8) = 8) +OFFSET 0 LIMIT 1 +"""); + }); + + // #35317 + public override Task HasFlag(bool async) + => AssertTranslationFailed(() => base.HasFlag(async)); + + // #35317 + public override Task HasFlag_with_non_nullable_parameter(bool async) + => AssertTranslationFailed(() => base.HasFlag(async)); + + // #35317 + public override Task HasFlag_with_nullable_parameter(bool async) + => AssertTranslationFailed(() => base.HasFlag(async)); + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MathTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MathTranslationsCosmosTest.cs new file mode 100644 index 00000000000..eed4814b0ad --- /dev/null +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MathTranslationsCosmosTest.cs @@ -0,0 +1,901 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.Azure.Cosmos; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MathTranslationsCosmosTest : MathTranslationsTestBase +{ + public MathTranslationsCosmosTest(BasicTypesQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override Task Abs_decimal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Abs_decimal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ABS(c["Decimal"]) = 9.5) +"""); + }); + + public override Task Abs_int(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Abs_int(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ABS(c["Int"]) = 9) +"""); + }); + + public override Task Abs_double(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Abs_double(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ABS(c["Double"]) = 9.5) +"""); + }); + + public override Task Abs_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Abs_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ABS(c["Float"]) = 9.5) +"""); + }); + + public override Task Ceiling(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Ceiling_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (CEILING(c["Float"]) = 9.0) +"""); + }); + + public override Task Ceiling_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Ceiling_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (CEILING(c["Float"]) = 9.0) +"""); + }); + + public override Task Floor_decimal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Floor_decimal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (FLOOR(c["Decimal"]) = 8.0) +"""); + }); + + public override Task Floor_double(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Floor_double(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (FLOOR(c["Double"]) = 8.0) +"""); + }); + + public override Task Floor_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Floor_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (FLOOR(c["Float"]) = 8.0) +"""); + }); + + public override Task Exp(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Exp(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (EXP(c["Double"]) > 1.0) +"""); + }); + + public override Task Exp_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Exp_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (EXP(c["Float"]) > 1.0) +"""); + }); + + public override async Task Power(bool async) + { + // Convert node. Issue #25120. + await AssertTranslationFailed(() => base.Power(async)); + + AssertSql(); + } + + public override Task Power_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Power_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((POWER(c["Float"], 2.0) > 73.0) AND (POWER(c["Float"], 2.0) < 74.0)) +"""); + }); + + public override Task Round_decimal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Round_decimal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ROUND(c["Decimal"]) = 9.0) +""", + // + """ +SELECT VALUE ROUND(c["Decimal"]) +FROM root c +"""); + }); + + public override Task Round_double(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Round_double(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ROUND(c["Double"]) = 9.0) +""", + // + """ +SELECT VALUE ROUND(c["Double"]) +FROM root c +"""); + }); + + public override Task Round_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Round_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ROUND(c["Float"]) = 9.0) +""", + // + """ +SELECT VALUE ROUND(c["Float"]) +FROM root c +"""); + }); + + public override async Task Round_with_digits_decimal(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Round_with_digits_decimal(async)); + + AssertSql(); + } + + public override async Task Round_with_digits_double(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Round_with_digits_decimal(async)); + + AssertSql(); + } + + public override async Task Round_with_digits_float(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Round_with_digits_decimal(async)); + + AssertSql(); + } + + public override Task Truncate_decimal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Truncate_decimal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (TRUNC(c["Decimal"]) = 8.0) +""", + // + """ +SELECT VALUE TRUNC(c["Decimal"]) +FROM root c +"""); + }); + + public override Task Truncate_double(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Truncate_double(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (TRUNC(c["Double"]) = 8.0) +""", + // + """ +SELECT VALUE TRUNC(c["Double"]) +FROM root c +"""); + }); + + public override Task Truncate_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Truncate_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (TRUNC(c["Float"]) = 8.0) +""", + // + """ +SELECT VALUE TRUNC(c["Float"]) +FROM root c +"""); + }); + + public override async Task Truncate_project_and_order_by_it_twice(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Unsupported ORDER BY clause. ORDER BY item expression could not be mapped to a document path. + await Assert.ThrowsAsync(() => base.Truncate_project_and_order_by_it_twice(a)); + + AssertSql( + """ +SELECT VALUE TRUNC(c["Double"]) +FROM root c +ORDER BY TRUNC(c["Double"]) +"""); + }); + } + } + + public override async Task Truncate_project_and_order_by_it_twice2(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Unsupported ORDER BY clause. ORDER BY item expression could not be mapped to a document path. + await Assert.ThrowsAsync(() => base.Truncate_project_and_order_by_it_twice2(a)); + + AssertSql( + """ +SELECT VALUE TRUNC(c["Double"]) +FROM root c +ORDER BY TRUNC(c["Double"]) DESC +"""); + }); + } + } + + public override async Task Truncate_project_and_order_by_it_twice3(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Unsupported ORDER BY clause. ORDER BY item expression could not be mapped to a document path. + await Assert.ThrowsAsync(() => base.Truncate_project_and_order_by_it_twice3(a)); + + AssertSql( + """ +SELECT VALUE TRUNC(c["Double"]) +FROM root c +ORDER BY TRUNC(c["Double"]) DESC +"""); + }); + } + } + + public override Task Log(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Log(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Double"] > 0.0) AND (LOG(c["Double"]) != 0.0)) +"""); + }); + + public override Task Log_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Log_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Float"] > 0.0) AND (LOG(c["Float"]) != 0.0)) +"""); + }); + + public override Task Log_with_newBase(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Log_with_newBase(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Double"] > 0.0) AND (LOG(c["Double"], 7.0) != 0.0)) +"""); + }); + + public override Task Log_with_newBase_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Log_with_newBase_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Float"] > 0.0) AND (LOG(c["Float"], 7.0) != 0.0)) +"""); + }); + + public override Task Log10(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Log10(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Double"] > 0.0) AND (LOG10(c["Double"]) != 0.0)) +"""); + }); + + public override Task Log10_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Log10_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Float"] > 0.0) AND (LOG10(c["Float"]) != 0.0)) +"""); + }); + + public override async Task Log2(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Log2(async)); + + AssertSql(); + } + + public override Task Sqrt(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Sqrt(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Double"] > 0.0) AND (SQRT(c["Double"]) > 0.0)) +"""); + }); + + public override Task Sqrt_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Sqrt_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["Float"] > 0.0) AND (SQRT(c["Float"]) > 0.0)) +"""); + }); + + + public override Task Sign(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Sign(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (SIGN(c["Double"]) > 0) +"""); + }); + + public override Task Sign_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Sign_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (SIGN(c["Float"]) > 0) +"""); + }); + + public override async Task Max(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Max(async)); + + AssertSql(); + } + + public override async Task Max_nested(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Max(async)); + + AssertSql(); + } + + public override async Task Max_nested_twice(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Max(async)); + + AssertSql(); + } + + public override async Task Min(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Min(async)); + + AssertSql(); + } + + public override async Task Min_nested(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Min(async)); + + AssertSql(); + } + + public override async Task Min_nested_twice(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Min(async)); + + AssertSql(); + } + + public override Task Degrees(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Degrees(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DEGREES(c["Double"]) > 0.0) +"""); + }); + + public override Task Degrees_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Degrees_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DEGREES(c["Float"]) > 0.0) +"""); + }); + + public override Task Radians(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Radians(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (RADIANS(c["Double"]) > 0.0) +"""); + }); + + public override Task Radians_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Radians_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (RADIANS(c["Float"]) > 0.0) +"""); + }); + + #region Trigonometry + + public override Task Acos(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Acos(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Double"] >= -1.0) AND (c["Double"] <= 1.0)) AND (ACOS(c["Double"]) > 1.0)) +"""); + }); + + public override Task Acos_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Acos_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Float"] >= -1.0) AND (c["Float"] <= 1.0)) AND (ACOS(c["Float"]) > 0.0)) +"""); + }); + + public override async Task Acosh(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Acosh(async)); + + AssertSql(); + } + + public override Task Asin(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Asin(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Double"] >= -1.0) AND (c["Double"] <= 1.0)) AND (ASIN(c["Double"]) > -1.7976931348623157E+308)) +"""); + }); + + public override Task Asin_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Asin_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (((c["Float"] >= -1.0) AND (c["Float"] <= 1.0)) AND (ASIN(c["Float"]) > -1.7976931348623157E+308)) +"""); + }); + + public override async Task Asinh(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Asinh(async)); + + AssertSql(); + } + + public override Task Atan(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Atan(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ATAN(c["Double"]) > 0.0) +"""); + }); + + public override Task Atan_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Atan_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ATAN(c["Float"]) > 0.0) +"""); + }); + + public override async Task Atanh(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Atanh(async)); + + AssertSql(); + } + + public override Task Atan2(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Atan2(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ATN2(c["Double"], 1.0) > 0.0) +"""); + }); + + public override Task Cos(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Cos(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (COS(c["Double"]) > 0.0) +"""); + }); + + public override Task Cos_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Cos_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (COS(c["Float"]) > 0.0) +"""); + }); + + public override async Task Cosh(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Cosh(async)); + + AssertSql(); + } + + public override Task Sin(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Sin(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (SIN(c["Double"]) > 0.0) +"""); + }); + + public override Task Sin_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Sin_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (SIN(c["Float"]) > 0.0) +"""); + }); + + public override async Task Sinh(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Sinh(async)); + + AssertSql(); + } + + public override Task Tan(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Tan(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (TAN(c["Double"]) > 0.0) +"""); + }); + + public override Task Tan_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Tan_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (TAN(c["Float"]) > 0.0) +"""); + }); + + public override async Task Tanh(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Tanh(async)); + + AssertSql(); + } + + public override Task Atan2_float(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Atan2_float(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (ATN2(c["Float"], 1.0) > 0.0) +"""); + }); + + #endregion Trigonometry + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs new file mode 100644 index 00000000000..5efbf266cda --- /dev/null +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/MiscellaneousTranslationsCosmosTest.cs @@ -0,0 +1,184 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MiscellaneousTranslationsCosmosTest : MiscellaneousTranslationsTestBase +{ + public MiscellaneousTranslationsCosmosTest(BasicTypesQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Guid + + public override Task Guid_new_with_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Guid_new_with_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["Guid"] = "df36f493-463f-4123-83f9-6b135deeb7ba") +"""); + }); + + public override Task Guid_new_with_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Guid_new_with_parameter(a); + + AssertSql( + """ +@p=? + +SELECT VALUE c +FROM root c +WHERE (c["Guid"] = @p) +"""); + }); + + public override Task Guid_ToString_projection(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Guid_ToString_projection(a); + + AssertSql( + """ +SELECT VALUE c["Guid"] +FROM root c +"""); + }); + + public override async Task Guid_NewGuid(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Guid_NewGuid(async)); + + AssertSql(); + } + + #endregion Guid + + #region Byte array + + public override Task Byte_array_Length(bool async) + => AssertTranslationFailed(() => base.Byte_array_Length(async)); + + public override Task Byte_array_array_index(bool async) + => AssertTranslationFailed(() => base.Byte_array_array_index(async)); + + public override Task Byte_array_First(bool async) + => AssertTranslationFailed(() => base.Byte_array_First(async)); + + #endregion Byte array + + #region Convert + + public override async Task Convert_ToBoolean(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToBoolean(async)); + + AssertSql(); + } + + public override async Task Convert_ToByte(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToByte(async)); + + AssertSql(); + } + + public override async Task Convert_ToDecimal(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToDecimal(async)); + + AssertSql(); + } + + public override async Task Convert_ToDouble(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToDouble(async)); + + AssertSql(); + } + + public override async Task Convert_ToInt16(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToInt16(async)); + + AssertSql(); + } + + public override async Task Convert_ToInt32(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToInt32(async)); + + AssertSql(); + } + + public override async Task Convert_ToInt64(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToInt64(async)); + + AssertSql(); + } + + public override async Task Convert_ToString(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Convert_ToString(async)); + + AssertSql(); + } + + #endregion Convert + + #region Compare + + public override async Task Int_Compare_to_simple_zero(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Int_Compare_to_simple_zero(async)); + + AssertSql(); + } + + public override async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTime_Compare_to_simple_zero(async, compareTo)); + + AssertSql(); + } + + public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.TimeSpan_Compare_to_simple_zero(async, compareTo)); + + AssertSql(); + } + + #endregion Compare + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/StringTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/StringTranslationsCosmosTest.cs new file mode 100644 index 00000000000..338d8b22191 --- /dev/null +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/StringTranslationsCosmosTest.cs @@ -0,0 +1,1249 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class StringTranslationsCosmosTest : StringTranslationsTestBase +{ + public StringTranslationsCosmosTest(BasicTypesQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equals + + public override Task Equals(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equals(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["String"] = "Seattle") +"""); + }); + + public override Task Equals_with_OrdinalIgnoreCase(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equals_with_OrdinalIgnoreCase(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STRINGEQUALS(c["String"], "seattle", true) +"""); + }); + + public override Task Equals_with_Ordinal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Equals_with_Ordinal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STRINGEQUALS(c["String"], "Seattle") +"""); + }); + + public override Task Static_Equals(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Static_Equals(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["String"] = "Seattle") +"""); + }); + + public override Task Static_Equals_with_OrdinalIgnoreCase(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Static_Equals_with_OrdinalIgnoreCase(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STRINGEQUALS(c["String"], "seattle", true) +"""); + }); + + public override Task Static_Equals_with_Ordinal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Static_Equals_with_Ordinal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STRINGEQUALS(c["String"], "Seattle") +"""); + }); + + #endregion Equals + + #region Miscellaneous + + public override Task Length(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Length(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (LENGTH(c["String"]) = 7) +"""); + }); + + public override Task ToUpper(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.ToUpper(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (UPPER(c["String"]) = "SEATTLE") +"""); + }); + + public override Task ToLower(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.ToLower(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (LOWER(c["String"]) = "seattle") +"""); + }); + + #endregion Miscellaneous + + #region IndexOf + + public override Task IndexOf(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.IndexOf(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (INDEX_OF(c["String"], "eattl") != -1) +"""); + }); + + public override Task IndexOf_with_empty_string(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.IndexOf_with_empty_string(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (INDEX_OF(c["String"], "") = 0) +"""); + }); + + public override Task IndexOf_with_one_parameter_arg(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.IndexOf_with_one_parameter_arg(a); + + AssertSql( + """ +@pattern=? + +SELECT VALUE c +FROM root c +WHERE (INDEX_OF(c["String"], @pattern) = 1) +"""); + }); + + public override Task IndexOf_with_constant_starting_position(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.IndexOf_with_constant_starting_position(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) > 2) AND (INDEX_OF(c["String"], "e", 2) = 6)) +"""); + }); + + public override Task IndexOf_with_parameter_starting_position(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.IndexOf_with_parameter_starting_position(a); + + AssertSql( + """ +@start=? + +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) > 2) AND (INDEX_OF(c["String"], "e", @start) = 6)) +"""); + }); + + public override Task IndexOf_after_ToString(bool async) + => AssertTranslationFailed(() => base.IndexOf_after_ToString(async)); + + public override Task IndexOf_over_ToString(bool async) + => AssertTranslationFailed(() => base.IndexOf_over_ToString(async)); + + #endregion IndexOf + + #region Replace + + public override Task Replace(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Replace(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (REPLACE(c["String"], "Sea", "Rea") = "Reattle") +"""); + }); + + public override Task Replace_with_empty_string(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Replace_with_empty_string(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["String"] != "") AND (REPLACE(c["String"], c["String"], "") = "")) +"""); + }); + + public override async Task Replace_using_property_arguments(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Replace_using_property_arguments(async)); + + AssertSql(); + } + + #endregion Replace + + #region Substring + + public override Task Substring(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) >= 3) AND (SUBSTRING(c["String"], 1, 2) = "ea")) +"""); + }); + + public override Task Substring_with_one_arg_with_zero_startIndex(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring_with_one_arg_with_zero_startIndex(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (SUBSTRING(c["String"], 0, LENGTH(c["String"])) = "Seattle") +"""); + }); + + public override Task Substring_with_one_arg_with_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring_with_one_arg_with_constant(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) >= 1) AND (SUBSTRING(c["String"], 1, LENGTH(c["String"])) = "eattle")) +"""); + }); + + public override Task Substring_with_one_arg_with_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring_with_one_arg_with_parameter(a); + + AssertSql( + """ +@start=? + +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) >= 2) AND (SUBSTRING(c["String"], @start, LENGTH(c["String"])) = "attle")) +"""); + }); + + public override Task Substring_with_two_args_with_zero_startIndex(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring_with_two_args_with_zero_startIndex(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) >= 3) AND (LEFT(c["String"], 3) = "Sea")) +"""); + }); + + public override Task Substring_with_two_args_with_zero_length(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring_with_two_args_with_zero_length(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) >= 2) AND (SUBSTRING(c["String"], 2, 0) = "")) +"""); + }); + + public override Task Substring_with_two_args_with_parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring_with_two_args_with_parameter(a); + + AssertSql( + """ +@start=? + +SELECT VALUE c +FROM root c +WHERE ((LENGTH(c["String"]) >= 5) AND (SUBSTRING(c["String"], @start, 3) = "att")) +"""); + }); + + public override Task Substring_with_two_args_with_IndexOf(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Substring_with_two_args_with_IndexOf(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (CONTAINS(c["String"], "a") AND (SUBSTRING(c["String"], INDEX_OF(c["String"], "a"), 3) = "att")) +"""); + }); + + #endregion Substring + + #region IsNullOrEmpty/Whitespace + + public override async Task IsNullOrEmpty(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.IsNullOrEmpty(async)); + + AssertSql(); + } + + public override async Task IsNullOrEmpty_negated(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.IsNullOrEmpty_negated(async)); + + AssertSql(); + } + + public override async Task IsNullOrWhiteSpace(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.IsNullOrWhiteSpace(async)); + + AssertSql(); + } + + #endregion IsNullOrEmpty/Whitespace + + #region StartsWith + + public override Task StartsWith_Literal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.StartsWith_Literal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STARTSWITH(c["String"], "Se") +"""); + }); + + public override Task StartsWith_Parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.StartsWith_Parameter(a); + + AssertSql( + """ +@pattern=? + +SELECT VALUE c +FROM root c +WHERE STARTSWITH(c["String"], @pattern) +"""); + }); + + public override Task StartsWith_Column(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.StartsWith_Column(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STARTSWITH(c["String"], c["String"]) +"""); + }); + + public override Task StartsWith_with_StringComparison_Ordinal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.StartsWith_with_StringComparison_Ordinal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STARTSWITH(c["String"], "Se", false) +"""); + }); + + public override Task StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.StartsWith_with_StringComparison_OrdinalIgnoreCase(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE STARTSWITH(c["String"], "Se", true) +"""); + }); + + public override async Task StartsWith_with_StringComparison_unsupported(bool async) + { + // Always throws for sync. + if (async) + { + await base.StartsWith_with_StringComparison_unsupported(async); + } + } + + #endregion StartsWith + + #region EndsWith + + public override Task EndsWith_Literal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.EndsWith_Literal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ENDSWITH(c["String"], "le") +"""); + }); + + public override Task EndsWith_Parameter(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.EndsWith_Parameter(a); + + AssertSql( + """ +@pattern=? + +SELECT VALUE c +FROM root c +WHERE ENDSWITH(c["String"], @pattern) +"""); + }); + + public override Task EndsWith_Column(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.EndsWith_Column(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ENDSWITH(c["String"], c["String"]) +"""); + }); + + public override Task EndsWith_with_StringComparison_Ordinal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.EndsWith_with_StringComparison_Ordinal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ENDSWITH(c["String"], "le", false) +"""); + }); + + public override Task EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.EndsWith_with_StringComparison_OrdinalIgnoreCase(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ENDSWITH(c["String"], "LE", true) +"""); + }); + + public override async Task EndsWith_with_StringComparison_unsupported(bool async) + { + // Always throws for sync. + if (async) + { + await base.EndsWith_with_StringComparison_unsupported(async); + } + } + + #endregion EndsWith + + #region Contains + + public override Task Contains_Literal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Contains_Literal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE CONTAINS(c["String"], "eattl") +"""); + }); + + public override Task Contains_Column(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Contains_Column(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE CONTAINS(c["String"], c["String"]) +""", + // + """ +SELECT VALUE CONTAINS(c["String"], c["String"]) +FROM root c +"""); + }); + + public override Task Contains_negated(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Contains_negated(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE NOT(CONTAINS(c["String"], "eattle")) +""", + // + """ +SELECT VALUE NOT(CONTAINS(c["String"], "eattle")) +FROM root c +"""); + }); + + public override Task Contains_with_StringComparison_Ordinal(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Contains_with_StringComparison_Ordinal(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE CONTAINS(c["String"], "eattl", false) +"""); + }); + + public override Task Contains_with_StringComparison_OrdinalIgnoreCase(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Contains_with_StringComparison_OrdinalIgnoreCase(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE CONTAINS(c["String"], "EATTL", true) +"""); + }); + + public override async Task Contains_with_StringComparison_unsupported(bool async) + { + // Always throws for sync. + if (async) + { + await base.Contains_with_StringComparison_unsupported(async); + } + } + + public override Task Contains_constant_with_whitespace(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Contains_constant_with_whitespace(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE CONTAINS(c["String"], " ") +"""); + }); + + public override Task Contains_parameter_with_whitespace(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Contains_parameter_with_whitespace(a); + + AssertSql( + """ +@pattern=? + +SELECT VALUE c +FROM root c +WHERE CONTAINS(c["String"], @pattern) +"""); + }); + + #endregion Contains + + #region TrimStart + + public override Task TrimStart_without_arguments(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.TrimStart_without_arguments(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (LTRIM(c["String"]) = "Boston ") +"""); + }); + + public override async Task TrimStart_with_char_argument(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.TrimStart_with_char_argument(async)); + + AssertSql(); + } + + public override async Task TrimStart_with_char_array_argument(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.TrimStart_with_char_array_argument(async)); + + AssertSql(); + } + + #endregion TrimStart + + #region TrimEnd + + public override Task TrimEnd_without_arguments(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.TrimEnd_without_arguments(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (RTRIM(c["String"]) = " Boston") +"""); + }); + + public override async Task TrimEnd_with_char_argument(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.TrimEnd_with_char_argument(async)); + + AssertSql(); + } + + public override async Task TrimEnd_with_char_array_argument(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.TrimEnd_with_char_array_argument(async)); + + AssertSql(); + } + + #endregion TrimEnd + + #region Trim + + public override Task Trim_without_argument_in_predicate(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Trim_without_argument_in_predicate(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (TRIM(c["String"]) = "Boston") +"""); + }); + + public override async Task Trim_with_char_argument_in_predicate(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Trim_with_char_argument_in_predicate(async)); + + AssertSql(); + } + + public override async Task Trim_with_char_array_argument_in_predicate(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Trim_with_char_array_argument_in_predicate(async)); + + AssertSql(); + } + + #endregion Trim + + #region Compare + + public override async Task Compare_simple_zero(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Compare_simple_zero(async)); + + AssertSql(); + } + + public override async Task Compare_simple_one(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Compare_simple_one(async)); + + AssertSql(); + } + + public override async Task Compare_with_parameter(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Compare_with_parameter(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["String"] = "Seattle") +OFFSET 0 LIMIT 2 +"""); + } + + public override async Task Compare_simple_more_than_one(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Compare_simple_more_than_one(async)); + + AssertSql(); + } + + public override async Task Compare_nested(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Compare_nested(async)); + + AssertSql(); + } + + public override async Task Compare_multi_predicate(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Compare_multi_predicate(async)); + + AssertSql(); + } + + public override async Task CompareTo_simple_zero(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.CompareTo_simple_zero(async)); + + AssertSql(); + } + + public override async Task CompareTo_simple_one(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.CompareTo_simple_one(async)); + + AssertSql(); + } + + public override async Task CompareTo_with_parameter(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.CompareTo_with_parameter(async)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["String"] = "Seattle") +OFFSET 0 LIMIT 2 +"""); + } + + public override async Task CompareTo_simple_more_than_one(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.CompareTo_simple_more_than_one(async)); + + AssertSql(); + } + + public override async Task CompareTo_nested(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.CompareTo_nested(async)); + + AssertSql(); + } + + public override async Task Compare_to_multi_predicate(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Compare_to_multi_predicate(async)); + + AssertSql(); + } + + #endregion Compare + + #region Join + + public override Task Join_over_non_nullable_column(bool async) + => AssertTranslationFailed(() => base.Join_over_non_nullable_column(async)); + + public override Task Join_with_predicate(bool async) + => AssertTranslationFailed(() => base.Join_with_predicate(async)); + + public override Task Join_with_ordering(bool async) + => AssertTranslationFailed(() => base.Join_with_ordering(async)); + + public override Task Join_over_nullable_column(bool async) + => AssertTranslationFailed(() => base.Join_over_nullable_column(async)); + + public override Task Join_non_aggregate(bool async) + => AssertTranslationFailed(() => base.Join_non_aggregate(async)); + + #endregion Join + + #region Concatenation + + public override Task Concat_aggregate(bool async) + => AssertTranslationFailed(() => base.Concat_aggregate(async)); + + public override Task Concat_string_string_comparison(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Concat_string_string_comparison(a); + + AssertSql( + """ +@i=? + +SELECT VALUE c +FROM root c +WHERE ((@i || c["String"]) = "ASeattle") +"""); + }); + + public override async Task Concat_string_int_comparison1(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Concat_string_int_comparison1(async)); + + AssertSql(); + } + + public override async Task Concat_string_int_comparison2(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Concat_string_int_comparison2(async)); + + AssertSql(); + } + + public override async Task Concat_string_int_comparison3(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Concat_string_int_comparison3(async)); + + AssertSql(); + } + + public override async Task Concat_string_int_comparison4(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.Concat_string_int_comparison4(async)); + + AssertSql( + ); + } + + public override Task Concat_method_comparison(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Concat_method_comparison(a); + + AssertSql( + """ +@i=? + +SELECT VALUE c +FROM root c +WHERE ((@i || c["String"]) = "ASeattle") +"""); + }); + + public override Task Concat_method_comparison_2(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Concat_method_comparison_2(a); + + AssertSql( + """ +@i=? +@j=? + +SELECT VALUE c +FROM root c +WHERE ((@i || (@j || c["String"])) = "ABSeattle") +"""); + }); + + public override Task Concat_method_comparison_3(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Concat_method_comparison_3(a); + + AssertSql( + """ +@i=? +@j=? +@k=? + +SELECT VALUE c +FROM root c +WHERE ((@i || (@j || (@k || c["String"]))) = "ABCSeattle") +"""); + }); + + #endregion Concatenation + + #region LINQ Operators + + public override Task FirstOrDefault(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.FirstOrDefault(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (LEFT(c["String"], 1) = "S") +"""); + }); + + public override Task LastOrDefault(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.LastOrDefault(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (RIGHT(c["String"], 1) = "e") +"""); + }); + + #endregion LINQ Operators + + #region Regex + + public override Task Regex_IsMatch(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Regex_IsMatch(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE RegexMatch(c["String"], "^S") +"""); + }); + + public override Task Regex_IsMatch_constant_input(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Regex_IsMatch_constant_input(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE RegexMatch("Seattle", c["String"]) +"""); + }); + +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_None(bool async) +// => Fixture.NoSyncTest( +// async, async a => +// { +// await AssertQuery( +// async, +// ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.None))); +// +// AssertSql( +// """ +// SELECT VALUE c +// FROM root c +// WHERE RegexMatch(c["id"], "^T") +// """); +// }); +// +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_IgnoreCase(bool async) +// => Fixture.NoSyncTest( +// async, async a => +// { +// await AssertQuery( +// async, +// ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnoreCase))); +// +// AssertSql( +// """ +// SELECT VALUE c +// FROM root c +// WHERE RegexMatch(c["id"], "^T", "i") +// """); +// }); +// +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_Multiline(bool async) +// => Fixture.NoSyncTest( +// async, async a => +// { +// await AssertQuery( +// async, +// ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.Multiline))); +// +// AssertSql( +// """ +// SELECT VALUE c +// FROM root c +// WHERE RegexMatch(c["id"], "^T", "m") +// """); +// }); +// +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_Singleline(bool async) +// => Fixture.NoSyncTest( +// async, async a => +// { +// await AssertQuery( +// async, +// ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.Singleline))); +// +// AssertSql( +// """ +// SELECT VALUE c +// FROM root c +// WHERE RegexMatch(c["id"], "^T", "s") +// """); +// }); +// +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_IgnorePatternWhitespace(bool async) +// => Fixture.NoSyncTest( +// async, async a => +// { +// await AssertQuery( +// async, +// ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnorePatternWhitespace))); +// +// AssertSql( +// """ +// SELECT VALUE c +// FROM root c +// WHERE RegexMatch(c["id"], "^T", "x") +// """); +// }); +// +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_IgnoreCase_and_IgnorePatternWhitespace(bool async) +// => Fixture.NoSyncTest( +// async, async a => +// { +// await AssertQuery( +// async, +// ss => ss.Set().Where( +// o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace))); +// +// AssertSql( +// """ +// SELECT VALUE c +// FROM root c +// WHERE RegexMatch(c["id"], "^T", "ix") +// """); +// }); +// +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_RightToLeft(bool async) +// => AssertTranslationFailed( +// () => AssertQuery( +// async, +// ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.RightToLeft)))); +// +// [ConditionalTheory] +// [MemberData(nameof(IsAsyncData))] +// public virtual Task Regex_IsMatch_with_RegexOptions_IgnoreCase_and_RightToLeft(bool async) +// => AssertTranslationFailed( +// () => AssertQuery( +// async, +// ss => ss.Set() +// .Where(o => Regex.IsMatch(o.CustomerID, "^T", RegexOptions.IgnoreCase | RegexOptions.RightToLeft)))); + + #endregion Regex + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs new file mode 100644 index 00000000000..ebf32d99a28 --- /dev/null +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/TemporalTranslationsCosmosTest.cs @@ -0,0 +1,739 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Xunit.Sdk; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class TemporalTranslationsCosmosTest : TemporalTranslationsTestBase +{ + public TemporalTranslationsCosmosTest(BasicTypesQueryCosmosFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region DateTime + + public override async Task DateTime_Now(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTime_Now(async)); + + AssertSql(); + } + + public override Task DateTime_UtcNow(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_UtcNow(a); + + AssertSql( + """ +@myDatetime=? + +SELECT VALUE c +FROM root c +WHERE (GetCurrentDateTime() != @myDatetime) +"""); + }); + + public override async Task DateTime_Today(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTime_Today(async)); + + AssertSql(); + } + + public override async Task DateTime_Date(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTime_Date(async)); + + AssertSql(); + } + + public override Task DateTime_AddYear(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_AddYear(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("yyyy", DateTimeAdd("yyyy", 1, c["DateTime"])) = 1999) +"""); + }); + + public override Task DateTime_Year(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Year(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("yyyy", c["DateTime"]) = 1998) +"""); + }); + + public override Task DateTime_Month(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Month(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("mm", c["DateTime"]) = 5) +"""); + }); + + public override async Task DateTime_DayOfYear(bool async) + { + // DateTime.DayOfYear not supported by Cosmos + await AssertTranslationFailed(() => base.DateTime_DayOfYear(async)); + + AssertSql(); + } + + public override Task DateTime_Day(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Day(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("dd", c["DateTime"]) = 4) +"""); + }); + + public override Task DateTime_Hour(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Hour(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("hh", c["DateTime"]) = 15) +"""); + }); + + public override Task DateTime_Minute(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Minute(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("mi", c["DateTime"]) = 30) +"""); + }); + + public override Task DateTime_Second(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Second(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("ss", c["DateTime"]) = 10) +"""); + }); + + public override Task DateTime_Millisecond(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTime_Millisecond(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("ms", c["DateTime"]) = 123) +"""); + }); + + public override async Task DateTime_TimeOfDay(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTime_TimeOfDay(async)); + + AssertSql(); + } + + public override async Task DateTime_subtract_and_TotalDays(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTime_subtract_and_TotalDays(async)); + + AssertSql(); + } + + #endregion DateTime + + #region DateOnly + + public override Task DateOnly_Year(bool async) + => AssertTranslationFailed(() => base.DateOnly_Year(async)); + + public override Task DateOnly_Month(bool async) + => AssertTranslationFailed(() => base.DateOnly_Month(async)); + + public override Task DateOnly_Day(bool async) + => AssertTranslationFailed(() => base.DateOnly_Day(async)); + + public override Task DateOnly_DayOfYear(bool async) + => AssertTranslationFailed(() => base.DateOnly_DayOfYear(async)); + + public override Task DateOnly_DayOfWeek(bool async) + => AssertTranslationFailed(() => base.DateOnly_DayOfWeek(async)); + + public override Task DateOnly_AddYears(bool async) + => AssertTranslationFailed(() => base.DateOnly_AddYears(async)); + + public override Task DateOnly_AddMonths(bool async) + => AssertTranslationFailed(() => base.DateOnly_AddMonths(async)); + + public override Task DateOnly_AddDays(bool async) + => AssertTranslationFailed(() => base.DateOnly_AddDays(async)); + + public override Task DateOnly_FromDateTime(bool async) + => AssertTranslationFailed(() => base.DateOnly_FromDateTime(async)); + + public override Task DateOnly_FromDateTime_compared_to_property(bool async) + => AssertTranslationFailed(() => base.DateOnly_FromDateTime(async)); + + public override Task DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + => AssertTranslationFailed(() => base.DateOnly_FromDateTime(async)); + + #endregion DateOnly + + #region TimeOnly + + public override Task TimeOnly_Hour(bool async) + => AssertTranslationFailed(() => base.TimeOnly_Hour(async)); + + public override Task TimeOnly_Minute(bool async) + => AssertTranslationFailed(() => base.TimeOnly_Minute(async)); + + public override Task TimeOnly_Second(bool async) + => AssertTranslationFailed(() => base.TimeOnly_Second(async)); + + public override Task TimeOnly_Millisecond(bool async) + => AssertTranslationFailed(() => base.TimeOnly_Millisecond(async)); + + public override Task TimeOnly_Microsecond(bool async) + => AssertTranslationFailed(() => base.TimeOnly_Microsecond(async)); + + public override Task TimeOnly_Nanosecond(bool async) + => AssertTranslationFailed(() => base.TimeOnly_Nanosecond(async)); + + public override Task TimeOnly_AddHours(bool async) + => AssertTranslationFailed(() => base.TimeOnly_AddHours(async)); + + public override Task TimeOnly_AddMinutes(bool async) + => AssertTranslationFailed(() => base.TimeOnly_AddMinutes(async)); + + public override Task TimeOnly_Add_TimeSpan(bool async) + => AssertTranslationFailed(() => base.TimeOnly_Add_TimeSpan(async)); + + public override Task TimeOnly_IsBetween(bool async) + => AssertTranslationFailed(() => base.TimeOnly_IsBetween(async)); + + public override async Task TimeOnly_subtract_TimeOnly(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // See #35311 + await Assert.ThrowsAsync(() => base.TimeOnly_subtract_TimeOnly(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((c["TimeOnly"] - "03:00:00") = "12:30:10") +"""); + }); + } + } + + public override Task TimeOnly_FromDateTime_compared_to_property(bool async) + => AssertTranslationFailed(() => base.TimeOnly_FromDateTime_compared_to_property(async)); + + public override Task TimeOnly_FromDateTime_compared_to_parameter(bool async) + => AssertTranslationFailed(() => base.TimeOnly_FromDateTime_compared_to_parameter(async)); + + public override Task TimeOnly_FromDateTime_compared_to_constant(bool async) + => AssertTranslationFailed(() => base.TimeOnly_FromDateTime_compared_to_constant(async)); + + public override Task TimeOnly_FromTimeSpan_compared_to_property(bool async) + => AssertTranslationFailed(() => base.TimeOnly_FromTimeSpan_compared_to_property(async)); + + public override Task TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + => AssertTranslationFailed(() => base.TimeOnly_FromTimeSpan_compared_to_parameter(async)); + + public override Task Order_by_TimeOnly_FromTimeSpan(bool async) + => AssertTranslationFailed(() => base.Order_by_TimeOnly_FromTimeSpan(async)); + + #endregion TimeOnly + + #region DateTimeOffset + + public override async Task DateTimeOffset_Now(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTimeOffset_Now(async)); + + AssertSql(); + } + + public override Task DateTimeOffset_UtcNow(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTimeOffset_UtcNow(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["DateTimeOffset"] != GetCurrentDateTime()) +"""); + }); + + public override async Task DateTimeOffset_Date(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTimeOffset_Date(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Year(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Year(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("yyyy", c["DateTimeOffset"]) = 1998) +"""); + }); + } + } + + public override async Task DateTimeOffset_Month(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Month(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("mm", c["DateTimeOffset"]) = 5) +"""); + }); + } + } + + public override async Task DateTimeOffset_DayOfYear(bool async) + { + // Cosmos client evaluation. Issue #17246. + await AssertTranslationFailed(() => base.DateTimeOffset_DayOfYear(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Day(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Day(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("dd", c["DateTimeOffset"]) = 4) +"""); + }); + } + } + + public override async Task DateTimeOffset_Hour(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Hour(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("hh", c["DateTimeOffset"]) = 15) +"""); + }); + } + } + + public override async Task DateTimeOffset_Minute(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Minute(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("mi", c["DateTimeOffset"]) = 30) +"""); + }); + } + } + + public override async Task DateTimeOffset_Second(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Second(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("ss", c["DateTimeOffset"]) = 10) +"""); + }); + } + } + + + public override async Task DateTimeOffset_Millisecond(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Millisecond(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (DateTimePart("ms", c["DateTimeOffset"]) = 123) +"""); + }); + } + } + + public override async Task DateTimeOffset_Microsecond(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Microsecond(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((DateTimePart("mcs", c["DateTimeOffset"]) % 1000) = 456) +"""); + }); + } + } + + public override async Task DateTimeOffset_Nanosecond(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_Nanosecond(a)); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE ((DateTimePart("ns", c["DateTimeOffset"]) % 1000) = 400) +"""); + }); + } + } + + public override Task DateTimeOffset_TimeOfDay(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTimeOffset_TimeOfDay(a); + + AssertSql( + """ +SELECT VALUE c["DateTimeOffset"] +FROM root c +"""); + }); + + public override async Task DateTimeOffset_AddYears(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_AddYears(a)); + + AssertSql( + """ +SELECT VALUE DateTimeAdd("yyyy", 1, c["DateTimeOffset"]) +FROM root c +"""); + }); + } + } + + public override async Task DateTimeOffset_AddMonths(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_AddMonths(a)); + + AssertSql( + """ +SELECT VALUE DateTimeAdd("mm", 1, c["DateTimeOffset"]) +FROM root c +"""); + }); + } + } + + public override async Task DateTimeOffset_AddDays(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_AddSeconds(a)); + + AssertSql( + """ +SELECT VALUE DateTimeAdd("ss", 1.0, c["DateTimeOffset"]) +FROM root c +"""); + }); + } + } + + public override async Task DateTimeOffset_AddHours(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_AddHours(a)); + + AssertSql( + """ +SELECT VALUE DateTimeAdd("hh", 1.0, c["DateTimeOffset"]) +FROM root c +"""); + }); + } + } + + public override async Task DateTimeOffset_AddMinutes(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_AddMinutes(a)); + + AssertSql( + """ +SELECT VALUE DateTimeAdd("mi", 1.0, c["DateTimeOffset"]) +FROM root c +"""); + }); + } + } + + public override async Task DateTimeOffset_AddSeconds(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_AddSeconds(a)); + + AssertSql( + """ +SELECT VALUE DateTimeAdd("ss", 1.0, c["DateTimeOffset"]) +FROM root c +"""); + }); + } + } + + public override async Task DateTimeOffset_AddMilliseconds(bool async) + { + // Always throws for sync. + if (async) + { + await Fixture.NoSyncTest( + async, async a => + { + // Our persisted representation of DateTimeOffset (xxx+00:00) isn't supported by Cosmos (should be xxxZ). #35310 + await Assert.ThrowsAsync(() => base.DateTimeOffset_AddMilliseconds(a)); + + AssertSql( + """ +SELECT VALUE DateTimeAdd("ms", 300.0, c["DateTimeOffset"]) +FROM root c +"""); + }); + } + } + + public override Task DateTimeOffset_ToUnixTimeMilliseconds(bool async) + => AssertTranslationFailed(() => base.DateTimeOffset_ToUnixTimeMilliseconds(async)); + + public override Task DateTimeOffset_ToUnixTimeSecond(bool async) + => AssertTranslationFailed(() => base.DateTimeOffset_ToUnixTimeSecond(async)); + + public override Task DateTimeOffset_milliseconds_parameter_and_constant(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.DateTimeOffset_milliseconds_parameter_and_constant(a); + + AssertSql( + """ +SELECT VALUE COUNT(1) +FROM root c +WHERE (c["DateTimeOffset"] = "1902-01-02T10:00:00.1234567+01:30") +"""); + }); + + #endregion DateTimeOffset + + #region TimeSpan + + public override Task TimeSpan_Hours(bool async) + => AssertTranslationFailed(() => base.TimeSpan_Hours(async)); + + public override Task TimeSpan_Minutes(bool async) + => AssertTranslationFailed(() => base.TimeSpan_Minutes(async)); + + public override Task TimeSpan_Seconds(bool async) + => AssertTranslationFailed(() => base.TimeSpan_Seconds(async)); + + public override Task TimeSpan_Milliseconds(bool async) + => AssertTranslationFailed(() => base.TimeSpan_Milliseconds(async)); + + public override Task TimeSpan_Microseconds(bool async) + => AssertTranslationFailed(() => base.TimeSpan_Microseconds(async)); + + public override Task TimeSpan_Nanoseconds(bool async) + => AssertTranslationFailed(() => base.TimeSpan_Nanoseconds(async)); + + #endregion TimeSpan + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindFunctionsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindFunctionsQueryInMemoryTest.cs index c7e07db06c3..0debb45b4c1 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindFunctionsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindFunctionsQueryInMemoryTest.cs @@ -4,16 +4,4 @@ namespace Microsoft.EntityFrameworkCore.Query; public class NorthwindFunctionsQueryInMemoryTest(NorthwindQueryInMemoryFixture fixture) - : NorthwindFunctionsQueryTestBase>(fixture) -{ - // StringComparison.CurrentCulture{,IgnoreCase} and InvariantCulture{,IgnoreCase} are not supported in real providers, but the in-memory - // provider does support them. - public override Task String_StartsWith_with_StringComparison_unsupported(bool async) - => Task.CompletedTask; - - public override Task String_EndsWith_with_StringComparison_unsupported(bool async) - => Task.CompletedTask; - - public override Task String_Contains_with_StringComparison_unsupported(bool async) - => Task.CompletedTask; -} + : NorthwindFunctionsQueryTestBase>(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs index 4c7da207ccb..c0885c3b5b9 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/NorthwindWhereQueryInMemoryTest.cs @@ -17,10 +17,6 @@ public override async Task Where_simple_closure(bool async) return null; } - public override Task Like_with_non_string_column_using_double_cast(bool async) - // Casting int to object to string is invalid for InMemory - => Assert.ThrowsAsync(() => base.Like_with_non_string_column_using_double_cast(async)); - public override Task ElementAt_over_custom_projection_compared_to_not_null(bool async) => Task.CompletedTask; diff --git a/test/EFCore.InMemory.FunctionalTests/Query/Translations/BasicTypesQueryInMemoryFixture.cs b/test/EFCore.InMemory.FunctionalTests/Query/Translations/BasicTypesQueryInMemoryFixture.cs new file mode 100644 index 00000000000..b9f02558bf0 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/Translations/BasicTypesQueryInMemoryFixture.cs @@ -0,0 +1,10 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class BasicTypesQueryInMemoryFixture : BasicTypesQueryFixtureBase +{ + protected override ITestStoreFactory TestStoreFactory + => InMemoryTestStoreFactory.Instance; +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/Translations/EnumTranslationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/Translations/EnumTranslationsInMemoryTest.cs new file mode 100644 index 00000000000..34aa6c21eff --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/Translations/EnumTranslationsInMemoryTest.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class EnumTranslationsSqlServerTest(BasicTypesQueryInMemoryFixture fixture) + : EnumTranslationsTestBase(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/Translations/MathTranslationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/Translations/MathTranslationsInMemoryTest.cs new file mode 100644 index 00000000000..d356782a8ae --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/Translations/MathTranslationsInMemoryTest.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MathTranslationsInMemoryTest(BasicTypesQueryInMemoryFixture fixture) + : MathTranslationsTestBase(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/Translations/MiscellaneousTranslationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/Translations/MiscellaneousTranslationsInMemoryTest.cs new file mode 100644 index 00000000000..257e1b4e3cb --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/Translations/MiscellaneousTranslationsInMemoryTest.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MiscellaneousTranslationsInMemoryTest(BasicTypesQueryInMemoryFixture fixture) + : MiscellaneousTranslationsTestBase(fixture); diff --git a/test/EFCore.InMemory.FunctionalTests/Query/Translations/StringTranslationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/Translations/StringTranslationsInMemoryTest.cs new file mode 100644 index 00000000000..2bce9c144ee --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/Translations/StringTranslationsInMemoryTest.cs @@ -0,0 +1,19 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class StringTranslationsInMemoryTest(BasicTypesQueryInMemoryFixture fixture) + : StringTranslationsTestBase(fixture) +{ + // StringComparison.CurrentCulture{,IgnoreCase} and InvariantCulture{,IgnoreCase} are not supported in real providers, but the in-memory + // provider does support them. + public override Task StartsWith_with_StringComparison_unsupported(bool async) + => Task.CompletedTask; + + public override Task EndsWith_with_StringComparison_unsupported(bool async) + => Task.CompletedTask; + + public override Task Contains_with_StringComparison_unsupported(bool async) + => Task.CompletedTask; +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/Translations/TemporalTranslationsInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/Translations/TemporalTranslationsInMemoryTest.cs new file mode 100644 index 00000000000..67c13467fba --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/Translations/TemporalTranslationsInMemoryTest.cs @@ -0,0 +1,7 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class TemporalTranslationsInMemoryTest(BasicTypesQueryInMemoryFixture fixture) + : TemporalTranslationsTestBase(fixture); diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs index 1d702595038..76f765084ff 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindFunctionsQueryRelationalTestBase.cs @@ -9,36 +9,6 @@ public abstract class NorthwindFunctionsQueryRelationalTestBase(TFixtu : NorthwindFunctionsQueryTestBase(fixture) where TFixture : NorthwindQueryFixtureBase, new() { - // StartsWith with StringComparison not supported in relational databases, where the column collation is used to control comparison - // semantics. - public override Task String_StartsWith_with_StringComparison_Ordinal(bool async) - => AssertTranslationFailed(() => base.String_StartsWith_with_StringComparison_Ordinal(async)); - - // StartsWith with StringComparison not supported in relational databases, where the column collation is used to control comparison - // semantics. - public override Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - => AssertTranslationFailed(() => base.String_StartsWith_with_StringComparison_OrdinalIgnoreCase(async)); - - // EndsWith with StringComparison not supported in relational databases, where the column collation is used to control comparison - // semantics. - public override Task String_EndsWith_with_StringComparison_Ordinal(bool async) - => AssertTranslationFailed(() => base.String_EndsWith_with_StringComparison_Ordinal(async)); - - // EndsWith with StringComparison not supported in relational databases, where the column collation is used to control comparison - // semantics. - public override Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - => AssertTranslationFailed(() => base.String_EndsWith_with_StringComparison_OrdinalIgnoreCase(async)); - - // Contains with StringComparison not supported in relational databases, where the column collation is used to control comparison - // semantics. - public override Task String_Contains_with_StringComparison_Ordinal(bool async) - => AssertTranslationFailed(() => base.String_Contains_with_StringComparison_Ordinal(async)); - - // Contains with StringComparison not supported in relational databases, where the column collation is used to control comparison - // semantics. - public override Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool async) - => AssertTranslationFailed(() => base.String_Contains_with_StringComparison_OrdinalIgnoreCase(async)); - protected override QueryAsserter CreateQueryAsserter(TFixture fixture) => new RelationalQueryAsserter( fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression); diff --git a/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs index 230b3321ce4..819f1a58c67 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/NorthwindWhereQueryRelationalTestBase.cs @@ -11,9 +11,6 @@ public abstract class NorthwindWhereQueryRelationalTestBase(TFixture f public override Task Where_bool_client_side_negated(bool async) => AssertTranslationFailed(() => base.Where_bool_client_side_negated(async)); - public override Task Where_equals_method_string_with_ignore_case(bool async) - => AssertTranslationFailed(() => base.Where_equals_method_string_with_ignore_case(async)); - protected override QueryAsserter CreateQueryAsserter(TFixture fixture) => new RelationalQueryAsserter( fixture, RewriteExpectedQueryExpression, RewriteServerQueryExpression); diff --git a/test/EFCore.Relational.Specification.Tests/Query/Translations/StringTranslationsRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/Translations/StringTranslationsRelationalTestBase.cs new file mode 100644 index 00000000000..e9beda59ea9 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/Translations/StringTranslationsRelationalTestBase.cs @@ -0,0 +1,83 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class StringTranslationsRelationalTestBase(TFixture fixture) : StringTranslationsTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + #region Case sensitivity + + // All the following tests specify case sensitivity (via StringComparison), which isn't supported in relational databases, where the + // column collation is used to control comparison semantics. + + public override Task Equals_with_OrdinalIgnoreCase(bool async) + => AssertTranslationFailed(() => base.Equals_with_OrdinalIgnoreCase(async)); + + public override Task Equals_with_Ordinal(bool async) + => AssertTranslationFailed(() => base.Equals_with_OrdinalIgnoreCase(async)); + + public override Task Static_Equals_with_OrdinalIgnoreCase(bool async) + => AssertTranslationFailed(() => base.Static_Equals_with_OrdinalIgnoreCase(async)); + + public override Task Static_Equals_with_Ordinal(bool async) + => AssertTranslationFailed(() => base.Static_Equals_with_Ordinal(async)); + + public override Task StartsWith_with_StringComparison_Ordinal(bool async) + => AssertTranslationFailed(() => base.StartsWith_with_StringComparison_Ordinal(async)); + + public override Task StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + => AssertTranslationFailed(() => base.StartsWith_with_StringComparison_OrdinalIgnoreCase(async)); + + public override Task EndsWith_with_StringComparison_Ordinal(bool async) + => AssertTranslationFailed(() => base.EndsWith_with_StringComparison_Ordinal(async)); + + public override Task EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + => AssertTranslationFailed(() => base.EndsWith_with_StringComparison_OrdinalIgnoreCase(async)); + + public override Task Contains_with_StringComparison_Ordinal(bool async) + => AssertTranslationFailed(() => base.Contains_with_StringComparison_Ordinal(async)); + + public override Task Contains_with_StringComparison_OrdinalIgnoreCase(bool async) + => AssertTranslationFailed(() => base.Contains_with_StringComparison_OrdinalIgnoreCase(async)); + + #endregion Case sensitivity + + #region Like + + [ConditionalTheory] // #26661, precedence/parentheses - belongs in OperatorsQueryTestBase + [MemberData(nameof(IsAsyncData))] + public virtual Task Where_Like_and_comparison(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => EF.Functions.Like(c.String, "S%") && c.Int == 8), + ss => ss.Set().Where(c => c.String.StartsWith("S") && c.Int == 8)); + + [ConditionalTheory] // #26661, precedence/parentheses - belongs in OperatorsQueryTestBase + [MemberData(nameof(IsAsyncData))] + public virtual Task Where_Like_or_comparison(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => EF.Functions.Like(c.String, "S%") || c.Int == int.MaxValue), + ss => ss.Set().Where(c => c.String.StartsWith("S") || c.Id == int.MaxValue)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Like_with_non_string_column_using_ToString(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => EF.Functions.Like(o.Int.ToString(), "%5%")), + ss => ss.Set().Where(o => o.Int.ToString().Contains("5"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Like_with_non_string_column_using_double_cast(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => EF.Functions.Like((string)(object)o.Int, "%5%")), + ss => ss.Set().Where(o => o.Int.ToString().Contains("5"))); + + #endregion Like +} diff --git a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs index 3b1a75cc60a..1dfeefd0b55 100644 --- a/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/GearsOfWarQueryTestBase.cs @@ -51,19 +51,7 @@ public virtual Task Include_multiple_one_to_one_and_one_to_many(bool async) new ExpectedInclude(g => g.Weapons, "Gear"), new ExpectedInclude(o => o.Weapons, "Gear"))); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task ToString_guid_property_projection(bool async) - => AssertQuery( - async, - ss => ss.Set().Select( - ct => new { A = ct.GearNickName, B = ct.Id.ToString() }), - elementSorter: e => e.B, - elementAsserter: (e, a) => - { - Assert.Equal(e.A, a.A); - Assert.Equal(e.B.ToLower(), a.B.ToLower()); - }); + // TODO: Move these out [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -430,262 +418,6 @@ public virtual Task Include_with_nested_navigation_in_order_by(bool async) elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(w => w.Owner)), assertOrder: true); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_enum(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(g => g.Rank == MilitaryRank.Sergeant)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_nullable_enum_with_constant(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(w => w.AmmunitionType == AmmunitionType.Cartridge)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_nullable_enum_with_null_constant(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(w => w.AmmunitionType == null)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_nullable_enum_with_non_nullable_parameter(bool async) - { - var ammunitionType = AmmunitionType.Cartridge; - - return AssertQuery( - async, - ss => ss.Set().Where(w => w.AmmunitionType == ammunitionType)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_nullable_enum_with_nullable_parameter(bool async) - { - AmmunitionType? ammunitionType = AmmunitionType.Cartridge; - - await AssertQuery( - async, - ss => ss.Set().Where(w => w.AmmunitionType == ammunitionType)); - - ammunitionType = null; - - await AssertQuery( - async, - ss => ss.Set().Where(w => w.AmmunitionType == ammunitionType)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_bitwise_and_enum(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(g => (g.Rank & MilitaryRank.Corporal) > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(g => (g.Rank & MilitaryRank.Corporal) == MilitaryRank.Corporal)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_bitwise_and_integral(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(g => ((int)g.Rank & 1) == 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(g => ((long)g.Rank & 1L) == 1L)); - - await AssertQuery( - async, - ss => ss.Set().Where(g => ((short)g.Rank & 1) == 1)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_and_nullable_enum_with_constant(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(w => (w.AmmunitionType & AmmunitionType.Cartridge) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) - { - return AssertQuery( - async, -#pragma warning disable CS0458 // The result of the expression is always 'null' - ss => ss.Set().Where(w => (w.AmmunitionType & null) > 0), -#pragma warning restore CS0458 // The result of the expression is always 'null' - assertEmpty: true); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) - { - var ammunitionType = AmmunitionType.Cartridge; - - return AssertQuery( - async, - ss => ss.Set().Where(w => (w.AmmunitionType & ammunitionType) > 0)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) - { - AmmunitionType? ammunitionType = AmmunitionType.Cartridge; - - await AssertQuery( - async, - ss => ss.Set().Where(w => (w.AmmunitionType & ammunitionType) > 0)); - - ammunitionType = null; - - await AssertQuery( - async, - ss => ss.Set().Where(w => (w.AmmunitionType & ammunitionType) > 0), - assertEmpty: true); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_bitwise_or_enum(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(g => (g.Rank | MilitaryRank.Corporal) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Bitwise_projects_values_in_select(bool async) - => AssertFirst( - async, - ss => ss.Set() - .Where(g => (g.Rank & MilitaryRank.Corporal) == MilitaryRank.Corporal) - .Select( - b => new - { - BitwiseTrue = (b.Rank & MilitaryRank.Corporal) == MilitaryRank.Corporal, - BitwiseFalse = (b.Rank & MilitaryRank.Corporal) == MilitaryRank.Sergeant, - BitwiseValue = b.Rank & MilitaryRank.Corporal - })); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_enum_has_flag(bool async) - { - // Constant - await AssertQuery( - async, - ss => ss.Set().Where(g => g.Rank.HasFlag(MilitaryRank.Corporal))); - - // Expression - await AssertQuery( - async, - ss => ss.Set().Where(g => g.Rank.HasFlag(MilitaryRank.Corporal | MilitaryRank.Captain)), - assertEmpty: true); - - // Casting - await AssertQuery( - async, - ss => ss.Set().Where(g => g.Rank.HasFlag((MilitaryRank)1))); - - // Casting to nullable - await AssertQuery( - async, - ss => ss.Set().Where(g => g.Rank.HasFlag((MilitaryRank?)1))); - - // QuerySource - await AssertQuery( - async, - ss => ss.Set().Where(g => MilitaryRank.Corporal.HasFlag(g.Rank))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_enum_has_flag_subquery(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where( - g => g.Rank.HasFlag( - ss.Set().OrderBy(x => x.Nickname).ThenBy(x => x.SquadId).Select(x => x.Rank).FirstOrDefault()))); - - await AssertQuery( - async, - ss => ss.Set().Where( - g => MilitaryRank.Corporal.HasFlag( - ss.Set().OrderBy(x => x.Nickname).ThenBy(x => x.SquadId).Select(x => x.Rank).FirstOrDefault()))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_enum_has_flag_subquery_with_pushdown(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where( - g => g.Rank.HasFlag(ss.Set().OrderBy(x => x.Nickname).ThenBy(x => x.SquadId).FirstOrDefault().Rank))); - - await AssertQuery( - async, - ss => ss.Set().Where( - g => MilitaryRank.Corporal.HasFlag( - ss.Set().OrderBy(x => x.Nickname).ThenBy(x => x.SquadId).FirstOrDefault().Rank))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_enum_has_flag_subquery_client_eval(bool async) - => AssertQuery( - async, - ss => ss.Set().Where( - g => g.Rank.HasFlag(ss.Set().OrderBy(x => x.Nickname).ThenBy(x => x.SquadId).First().Rank))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_enum_has_flag_with_non_nullable_parameter(bool async) - { - var parameter = MilitaryRank.Corporal; - - return AssertQuery( - async, - ss => ss.Set().Where(g => g.Rank.HasFlag(parameter))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_has_flag_with_nullable_parameter(bool async) - { - MilitaryRank? parameter = MilitaryRank.Corporal; - - return AssertQuery( - async, - ss => ss.Set().Where(g => g.Rank.HasFlag(parameter))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_enum_has_flag(bool async) - => AssertFirst( - async, - ss => ss.Set() - .Where(g => g.Rank.HasFlag(MilitaryRank.Corporal)) - .Select( - b => new - { - hasFlagTrue = b.Rank.HasFlag(MilitaryRank.Corporal), hasFlagFalse = b.Rank.HasFlag(MilitaryRank.Sergeant) - })); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_count_subquery_without_collision(bool async) @@ -2100,181 +1832,6 @@ into group1 from w in group1.DefaultIfEmpty() select g); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_now(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline != DateTimeOffset.Now - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_utcnow(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline != DateTimeOffset.UtcNow - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_date_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Date > new DateTimeOffset().Date - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_year_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Year == 2 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_month_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Month == 1 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_dayofyear_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.DayOfYear == 2 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_day_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Day == 2 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_hour_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Hour == 10 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_minute_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Minute == 0 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_second_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Second == 0 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_millisecond_component(bool async) - => AssertQuery( - async, - ss => from m in ss.Set() - where m.Timeline.Millisecond == 0 - select m); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_DateAdd_AddYears(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.AddYears(1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_DateAdd_AddMonths(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.AddMonths(1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_DateAdd_AddDays(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.AddDays(1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_DateAdd_AddHours(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.AddHours(1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_DateAdd_AddMinutes(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.AddMinutes(1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_DateAdd_AddSeconds(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.AddSeconds(1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.AddMilliseconds(300)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) - { - var dateTimeOffset = new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)); - - // Literal where clause - var p = Expression.Parameter(typeof(Mission), "i"); - var dynamicWhere = Expression.Lambda>( - Expression.Equal( - Expression.Property(p, "Timeline"), - Expression.Constant(dateTimeOffset) - ), p); - - return AssertCount( - async, - ss => ss.Set().Where(dynamicWhere), - ss => ss.Set().Where(m => m.Timeline == dateTimeOffset)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(bool async) @@ -4974,14 +4531,6 @@ from m in ss.Set() }, assertOrder: true); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Time_of_day_datetimeoffset(bool async) - => AssertQueryScalar( - async, - ss => from m in ss.Set() - select m.Timeline.TimeOfDay); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task GroupBy_Property_Include_Select_Average(bool async) @@ -5208,7 +4757,7 @@ let automaticWeapons = g.Weapons .OrderByDescending(w => w.AmmunitionType) .Where(w => w.IsAutomatic) - select new { g.Nickname, WeaponName = automaticWeapons.FirstOrDefault().Name }, + select new { g.Nickname, WeaponName = Enumerable.FirstOrDefault(automaticWeapons).Name }, elementSorter: e => e.Nickname, elementAsserter: (e, a) => { @@ -5220,47 +4769,19 @@ let automaticWeapons [MemberData(nameof(IsAsyncData))] public virtual Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation( bool async) - => AssertQuery( - async, - ss => ss.Set().Where(t => t.Note.Substring(0, t.Gear.SquadId) == t.GearNickName), - ss => ss.Set().Where(t => t.Gear.Maybe(x => t.Note.Substring(0, x.SquadId)) == t.GearNickName)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task - Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(t => t.Note.Substring(0, t.Gear.Squad.Name.Length) == t.GearNickName), - ss => ss.Set().Where(t => t.Gear.Maybe(x => t.Note.Substring(0, x.Squad.Name.Length)) == t.GearNickName)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filter_with_new_Guid(bool async) - => AssertQuery( - async, - ss => from t in ss.Set() - where t.Id == new Guid("DF36F493-463F-4123-83F9-6B135DEEB7BA") - select t); - - public virtual async Task Filter_with_new_Guid_closure(bool async) - { - var guid = "DF36F493-463F-4123-83F9-6B135DEEB7BD"; - - await AssertQuery( - async, - ss => from t in ss.Set() - where t.Id == new Guid(guid) - select t); - - guid = "B39A6FBA-9026-4D69-828E-FD7068673E57"; + => AssertQuery( + async, + ss => ss.Set().Where(t => t.Note.Substring(0, t.Gear.SquadId) == t.GearNickName), + ss => ss.Set().Where(t => t.Gear.Maybe(x => t.Note.Substring(0, x.SquadId)) == t.GearNickName)); - await AssertQuery( + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) + => AssertQuery( async, - ss => from t in ss.Set() - where t.Id == new Guid(guid) - select t); - } + ss => ss.Set().Where(t => t.Note.Substring(0, t.Gear.Squad.Name.Length) == t.GearNickName), + ss => ss.Set().Where(t => t.Gear.Maybe(x => t.Note.Substring(0, x.Squad.Name.Length)) == t.GearNickName)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -6386,70 +5907,6 @@ public virtual Task Checked_context_throws_on_client_evaluation(bool isAsync) private int GetThreatLevel() => 256; - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TimeSpan_Hours(bool async) - => AssertQueryScalar( - async, - ss => ss.Set() - .Select(m => m.Duration.Hours)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TimeSpan_Minutes(bool async) - => AssertQueryScalar( - async, - ss => ss.Set() - .Select(m => m.Duration.Minutes)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TimeSpan_Seconds(bool async) - => AssertQueryScalar( - async, - ss => ss.Set() - .Select(m => m.Duration.Seconds)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TimeSpan_Milliseconds(bool async) - => AssertQueryScalar( - async, - ss => ss.Set() - .Select(m => m.Duration.Milliseconds)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeSpan_Hours(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(m => m.Duration.Hours == 1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeSpan_Minutes(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(m => m.Duration.Minutes == 2)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeSpan_Seconds(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(m => m.Duration.Seconds == 3)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeSpan_Milliseconds(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(m => m.Duration.Milliseconds == 456)); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Contains_on_collection_of_byte_subquery(bool async) @@ -6936,20 +6393,6 @@ orderby t.Id where g.Tag.IssueDate > invalidTagIssueDate select new { g.Nickname, invalidTagIssueDate }); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task First_on_byte_array(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Banner.First() == 0x02)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Array_access_on_byte_array(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Banner5[2] == 0x06)); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Project_shadow_properties(bool async) @@ -7821,202 +7264,6 @@ public virtual Task Correlated_collection_after_distinct_3_levels_without_origin }); }); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_Year(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.Year == 1990).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_Month(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.Month == 11).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_Day(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.Day == 10).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_DayOfYear(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.DayOfYear == 314).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_DayOfWeek(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.DayOfWeek == DayOfWeek.Saturday).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_AddYears(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.AddYears(3) == new DateOnly(1993, 11, 10)).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_AddMonths(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.AddMonths(3) == new DateOnly(1991, 2, 10)).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_AddDays(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.AddDays(3) == new DateOnly(1990, 11, 13)).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_Hour(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.Hour == 10).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_Minute(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.Minute == 15).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_Second(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.Second == 50).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_Millisecond(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.Millisecond == 500).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_AddHours(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.AddHours(3) == new TimeOnly(13, 15, 50, 500)).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_AddMinutes(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.AddMinutes(3) == new TimeOnly(10, 18, 50, 500)).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_Add_TimeSpan(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.Add(new TimeSpan(3, 0, 0)) == new TimeOnly(13, 15, 50, 500)).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_IsBetween(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time.IsBetween(new TimeOnly(10, 0, 0), new TimeOnly(11, 0, 0))).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_subtract_TimeOnly(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(m => m.Time - new TimeOnly(10, 0, 0) == new TimeSpan(0, 0, 15, 50, 500)).AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) - => AssertQuery( - async, - ss => from t in ss.Set() - from m in ss.Set() - where TimeOnly.FromDateTime(t.IssueDate) == m.Time - select new { TagId = t.Id, MissionId = m.Id }, - elementSorter: e => (e.TagId, e.MissionId)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) - { - var time = new TimeOnly(2, 0, 0); - - return AssertQuery( - async, - ss => ss.Set().Where(x => x.Gear != null && TimeOnly.FromDateTime(x.IssueDate.AddHours(x.Gear.SquadId)) == time)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(x => TimeOnly.FromDateTime(x.IssueDate.AddHours(x.Note.Length)) > new TimeOnly(9, 0, 0))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(x => TimeOnly.FromTimeSpan(x.Duration) < x.Time)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) - { - var time = new TimeOnly(1, 2, 3); - - return AssertQuery( - async, - ss => ss.Set().Where(x => TimeOnly.FromTimeSpan(x.Duration) == time)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Order_by_TimeOnly_FromTimeSpan(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(x => TimeOnly.FromTimeSpan(x.Duration)), - assertOrder: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_FromDateTime_compared_to_property(bool async) - => AssertQuery( - async, - ss => from t in ss.Set() - from m in ss.Set() - where DateOnly.FromDateTime(t.IssueDate) > m.Date - select new { TagId = t.Id, MissionId = m.Id }, - elementSorter: e => (e.TagId, e.MissionId)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) - { - var prm = new DateOnly(2, 10, 11); - - return AssertQuery( - async, - ss => ss.Set().Where(x => new[] { prm, new DateOnly(15, 3, 7) }.Contains(DateOnly.FromDateTime(x.IssueDate)))); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Basic_query_gears(bool async) @@ -8352,40 +7599,6 @@ public virtual Task Using_indexer_on_byte_array_and_string_in_projection(bool as Assert.Equal(e.String, a.String); }); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - var unixEpochMilliseconds = DateTimeOffset.UnixEpoch.ToUnixTimeMilliseconds(); - - return AssertQuery( - async, - ss => ss.Set() - .Include(g => g.Squad.Missions) - .Where( - s => s.Squad.Missions - .Where(m => unixEpochMilliseconds == m.Mission.Timeline.ToUnixTimeMilliseconds()) - .FirstOrDefault() - == null)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task DateTimeOffset_to_unix_time_seconds(bool async) - { - var unixEpochSeconds = DateTimeOffset.UnixEpoch.ToUnixTimeSeconds(); - - return AssertQuery( - async, - ss => ss.Set() - .Include(g => g.Squad.Missions) - .Where( - s => s.Squad.Missions - .Where(m => unixEpochSeconds == m.Mission.Timeline.ToUnixTimeSeconds()) - .FirstOrDefault() - == null)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) @@ -8659,48 +7872,6 @@ public virtual Task Non_string_concat_uses_appropriate_type_mapping(bool async) ss => ss.Set().Select(e => e.Duration + interval)); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_microsecond_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Timeline.Microsecond == 200)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_nanosecond_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Timeline.Nanosecond == 400)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_timespan_microsecond_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Duration.Microseconds == 200)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_timespan_nanosecond_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Duration.Nanoseconds == 400)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_timeonly_microsecond_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Time.Microsecond == 200)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_timeonly_nanosecond_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => e.Time.Nanosecond == 400)); - protected GearsOfWarContext CreateContext() => Fixture.CreateContext(); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs index 71e06a15bee..3202d6b0206 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindAggregateOperatorsQueryTestBase.cs @@ -447,7 +447,7 @@ public virtual Task Min_over_nested_subquery(bool async) => AssertMin( async, ss => ss.Set().OrderBy(c => c.CustomerID).Take(3), - selector: c => c.Orders.Min(o => 5 + o.OrderDetails.Min(od => od.ProductID))); + selector: c => c.Orders.Min(o => 5 + Enumerable.Min(o.OrderDetails, od => od.ProductID))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] @@ -494,7 +494,7 @@ public virtual Task Max_over_nested_subquery(bool async) => AssertMax( async, ss => ss.Set().OrderBy(c => c.CustomerID).Take(3), - selector: c => c.Orders.Max(o => 5 + o.OrderDetails.Max(od => od.ProductID))); + selector: c => c.Orders.Max(o => 5 + Enumerable.Max(o.OrderDetails, od => od.ProductID))); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] diff --git a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs index 39af9e8322f..c3dc5bae12d 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindFunctionsQueryTestBase.cs @@ -29,2023 +29,120 @@ protected virtual void ClearLog() { } - #region String.StartsWith - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_StartsWith_Literal(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.StartsWith("M"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_StartsWith_Parameter(bool async) - { - var pattern = "M"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.StartsWith(pattern))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_StartsWith_Identity(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.StartsWith(c.ContactName))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_StartsWith_Column(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.StartsWith(c.ContactName))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_StartsWith_MethodCall(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.StartsWith(LocalMethod1()))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_StartsWith_with_StringComparison_Ordinal(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CompanyName.StartsWith("Qu", StringComparison.Ordinal))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CompanyName.StartsWith("Qu", StringComparison.OrdinalIgnoreCase))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_StartsWith_with_StringComparison_unsupported(bool async) - { - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.CompanyName.StartsWith("Qu", StringComparison.CurrentCulture)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCulture)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCultureIgnoreCase)))); - } - - #endregion String.StartsWith - - #region String.EndsWith - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_EndsWith_Literal(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith("b"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_EndsWith_Parameter(bool async) - { - var pattern = "b"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith(pattern))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_EndsWith_Identity(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith(c.ContactName))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_EndsWith_Column(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith(c.ContactName))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_EndsWith_MethodCall(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith(LocalMethod2()))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_EndsWith_with_StringComparison_Ordinal(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith("DY", StringComparison.Ordinal)), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith("DY", StringComparison.OrdinalIgnoreCase))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_EndsWith_with_StringComparison_unsupported(bool async) - { - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.EndsWith("Qu", StringComparison.CurrentCulture)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCulture)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("Qu", StringComparison.InvariantCultureIgnoreCase)))); - } - - #endregion String.EndsWith - - #region String.Contains - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_Literal(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_Identity(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains(c.ContactName))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_Column(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CompanyName.Contains(c.ContactName))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_in_projection(bool async) - => AssertQuery( - async, - ss => ss.Set().Select(c => new { Id = c.CustomerID, Value = c.CompanyName.Contains(c.ContactName) }), - elementSorter: e => e.Id); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_negated_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => !c.CompanyName.Contains(c.ContactName))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_negated_in_projection(bool async) - => AssertQuery( - async, - ss => ss.Set().Select(c => new { Id = c.CustomerID, Value = !c.CompanyName.Contains(c.ContactName) }), - elementSorter: e => e.Id); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_with_StringComparison_Ordinal(bool async) + public virtual Task Client_evaluation_of_uncorrelated_method_call(bool async) => AssertQuery( async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.Ordinal))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.OrdinalIgnoreCase))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Contains_with_StringComparison_unsupported(bool async) - { - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCulture)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.CurrentCultureIgnoreCase)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.InvariantCulture)))); - - await AssertTranslationFailed( - () => - AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M", StringComparison.InvariantCultureIgnoreCase)))); - } - - #endregion String.Contains - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_FirstOrDefault_MethodCall(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.FirstOrDefault() == 'A')); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_constant_with_whitespace(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains(" ")), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_parameter_with_whitespace(bool async) - { - var pattern = " "; - return AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains(pattern)), - assertEmpty: true); - } + ss => ss.Set() + .Where(od => od.UnitPrice < 7) + .Where(od => Math.Abs(-10) < od.ProductID)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_LastOrDefault_MethodCall(bool async) + public virtual Task Order_by_length_twice(bool async) => AssertQuery( async, - ss => ss.Set().Where(c => c.ContactName.LastOrDefault() == 's')); + ss => ss.Set().OrderBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID), + assertOrder: true); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_Contains_MethodCall(bool async) + public virtual Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool async) => AssertQuery( async, - ss => ss.Set().Where(c => c.ContactName.Contains(LocalMethod1()))); + ss => ss.Set().OrderBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID) + .Select(c => c.Orders), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection(e, a)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_Join_over_non_nullable_column(bool async) + public virtual Task Sum_over_round_works_correctly_in_projection(bool async) => AssertQuery( async, - ss => ss.Set() - .GroupBy(c => c.City) - .Select(g => new { City = g.Key, Customers = string.Join("|", g.Select(e => e.CustomerID)) }), - elementSorter: x => x.City, + ss => ss.Set() + .Where(o => o.OrderID < 10300) + .Select(o => new { o.OrderID, Sum = o.OrderDetails.Sum(i => Math.Round(i.UnitPrice, 2)) }), + elementSorter: e => e.OrderID, elementAsserter: (e, a) => { - Assert.Equal(e.City, a.City); - - // Ordering inside the string isn't specified server-side, split and reorder - Assert.Equal( - e.Customers.Split("|").OrderBy(id => id).ToArray(), - a.Customers.Split("|").OrderBy(id => id).ToArray()); + Assert.Equal(e.OrderID, a.OrderID); + Assert.Equal(e.Sum, a.Sum); }); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_Join_with_predicate(bool async) + public virtual Task Sum_over_round_works_correctly_in_projection_2(bool async) => AssertQuery( async, - ss => ss.Set() - .GroupBy(c => c.City) - .Select( - g => new - { - City = g.Key, - Customers = string.Join("|", g.Where(e => e.ContactName.Length > 10).Select(e => e.CustomerID)) - }), - elementSorter: x => x.City, + ss => ss.Set() + .Where(o => o.OrderID < 10300) + .Select(o => new { o.OrderID, Sum = o.OrderDetails.Select(i => i.UnitPrice * i.UnitPrice).Sum(i => Math.Round(i, 2)) }), + elementSorter: e => e.OrderID, elementAsserter: (e, a) => { - Assert.Equal(e.City, a.City); - - // Ordering inside the string isn't specified server-side, split and reorder - Assert.Equal( - e.Customers.Split("|").OrderBy(id => id).ToArray(), - a.Customers.Split("|").OrderBy(id => id).ToArray()); + Assert.Equal(e.OrderID, a.OrderID); + Assert.Equal(e.Sum, a.Sum); }); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_Join_with_ordering(bool async) - => AssertQuery( - async, - ss => ss.Set() - .GroupBy(c => c.City) - .Select( - g => new - { - City = g.Key, Customers = string.Join("|", g.OrderByDescending(e => e.CustomerID).Select(e => e.CustomerID)) - }), - elementSorter: x => x.City); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Join_over_nullable_column(bool async) + public virtual Task Sum_over_truncate_works_correctly_in_projection(bool async) => AssertQuery( async, - ss => ss.Set() - .GroupBy(c => c.City) - .Select(g => new { City = g.Key, Regions = string.Join("|", g.Select(e => e.Region)) }), - elementSorter: x => x.City, + ss => ss.Set() + .Where(o => o.OrderID < 10300) + .Select(o => new { o.OrderID, Sum = o.OrderDetails.Sum(i => Math.Truncate(i.UnitPrice)) }), + elementSorter: e => e.OrderID, elementAsserter: (e, a) => { - Assert.Equal(e.City, a.City); - - // Ordering inside the string isn't specified server-side, split and reorder - Assert.Equal( - e.Regions.Split("|").OrderBy(id => id).ToArray(), - a.Regions.Split("|").OrderBy(id => id).ToArray()); + Assert.Equal(e.OrderID, a.OrderID); + Assert.Equal(e.Sum, a.Sum); }); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_Join_non_aggregate(bool async) - { - var foo = "foo"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => string.Join("|", new[] { c.CompanyName, foo, null, "bar" }) == "Around the Horn|foo||bar")); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task String_Concat(bool async) + public virtual Task Sum_over_truncate_works_correctly_in_projection_2(bool async) => AssertQuery( async, - ss => ss.Set() - .GroupBy(c => c.City) - .Select(g => new { City = g.Key, Customers = string.Concat(g.Select(e => e.CustomerID)) }), - elementSorter: x => x.City, + ss => ss.Set() + .Where(o => o.OrderID < 10300) + .Select(o => new { o.OrderID, Sum = o.OrderDetails.Select(i => i.UnitPrice * i.UnitPrice).Sum(i => Math.Truncate(i)) }), + elementSorter: e => e.OrderID, elementAsserter: (e, a) => { - Assert.Equal(e.City, a.City); - - // The best we can do for Concat without server-side ordering is sort the characters (concatenating without ordering - // and without a delimiter is somewhat dubious anyway). - Assert.Equal(e.Customers.OrderBy(c => c).ToArray(), a.Customers.OrderBy(c => c).ToArray()); + Assert.Equal(e.OrderID, a.OrderID); + Assert.Equal(e.Sum, a.Sum); }); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_simple_zero(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "AROUT") == 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != string.Compare(c.CustomerID, "AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "AROUT") > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= string.Compare(c.CustomerID, "AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 < string.Compare(c.CustomerID, "AROUT"))); - - await AssertQuery( + public virtual Task Where_functions_nested(bool async) + => AssertQuery( async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "AROUT") <= 0)); - } + ss => ss.Set().Where(c => Math.Pow(c.CustomerID.Length, 2) == 25)); [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_simple_one(bool async) + public virtual Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) { - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "AROUT") == 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => -1 == string.Compare(c.CustomerID, "AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "AROUT") < 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 1 > string.Compare(c.CustomerID, "AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "AROUT") > -1)); + var arg = new DateTime(1996, 7, 4); - await AssertQuery( + return AssertQuery( async, - ss => ss.Set().Where(c => -1 < string.Compare(c.CustomerID, "AROUT"))); + ss => ss.Set().Where(o => Equals(o.OrderDate, arg))); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task String_compare_with_parameter(bool async) + public virtual Task Static_equals_int_compared_to_long(bool async) { - Customer customer = null; - using (var context = CreateContext()) - { - customer = await context.Customers.SingleAsync(c => c.CustomerID == "AROUT"); - } - - ClearLog(); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, customer.CustomerID) == 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => -1 == string.Compare(c.CustomerID, customer.CustomerID))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, customer.CustomerID) < 1)); + long arg = 10248; - await AssertQuery( - async, - ss => ss.Set().Where(c => 1 > string.Compare(c.CustomerID, customer.CustomerID))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, customer.CustomerID) > -1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => -1 < string.Compare(c.CustomerID, customer.CustomerID))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_simple_more_than_one(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "ALFKI") == 42), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "ALFKI") > 42), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 42 > string.Compare(c.CustomerID, "ALFKI"))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_nested(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "M" + c.CustomerID) == 0), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != string.Compare(c.CustomerID, c.CustomerID.ToUpper())), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "ALFKI".Replace("ALF".ToUpper(), c.CustomerID)) > 0), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= string.Compare(c.CustomerID, "M" + c.CustomerID))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 1 == string.Compare(c.CustomerID, c.CustomerID.ToUpper())), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "ALFKI".Replace("ALF".ToUpper(), c.CustomerID)) == -1)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_multi_predicate(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.CustomerID, "ALFKI") > -1) - .Where(c => string.Compare(c.CustomerID, "CACTU") == -1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => string.Compare(c.ContactTitle, "Owner") == 0) - .Where(c => string.Compare(c.Country, "USA") != 0)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_to_simple_zero(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT") == 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != c.CustomerID.CompareTo("AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT") > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= c.CustomerID.CompareTo("AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 < c.CustomerID.CompareTo("AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT") <= 0)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_to_simple_one(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT") == 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => -1 == c.CustomerID.CompareTo("AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT") < 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 1 > c.CustomerID.CompareTo("AROUT"))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT") > -1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => -1 < c.CustomerID.CompareTo("AROUT"))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_compare_to_with_parameter(bool async) - { - Customer customer = null; - using (var context = CreateContext()) - { - customer = await context.Customers.SingleAsync(x => x.CustomerID == "AROUT"); - } - - ClearLog(); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo(customer.CustomerID) == 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => -1 == c.CustomerID.CompareTo(customer.CustomerID))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo(customer.CustomerID) < 1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 1 > c.CustomerID.CompareTo(customer.CustomerID))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo(customer.CustomerID) > -1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => -1 < c.CustomerID.CompareTo(customer.CustomerID))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_to_simple_more_than_one(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("ALFKI") == 42), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("ALFKI") > 42), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 42 > c.CustomerID.CompareTo("ALFKI"))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_to_nested(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("M" + c.CustomerID) != 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 == c.CustomerID.CompareTo(c.CustomerID.ToUpper()))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT".Replace("OUT".ToUpper(), c.CustomerID)) > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= c.CustomerID.CompareTo("M" + c.CustomerID))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 1 == c.CustomerID.CompareTo(c.CustomerID.ToUpper())), - assertEmpty: true); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("AROUT".Replace("OUT".ToUpper(), c.CustomerID)) == -1)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task String_Compare_to_multi_predicate(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.CompareTo("ALFKI") > -1).Where(c => c.CustomerID.CompareTo("CACTU") == -1)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.CompareTo("Owner") == 0).Where(c => c.Country.CompareTo("USA") != 0)); - } - - [ConditionalTheory] - [InlineData(false, false)] - [InlineData(true, false)] - [InlineData(false, true)] - [InlineData(true, true)] - public virtual async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) - { - var myDatetime = new DateTime(1998, 5, 4); - - if (compareTo) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderDate.Value.CompareTo(myDatetime) == 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != c.OrderDate.Value.CompareTo(myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderDate.Value.CompareTo(myDatetime) > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= c.OrderDate.Value.CompareTo(myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 < c.OrderDate.Value.CompareTo(myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderDate.Value.CompareTo(myDatetime) <= 0)); - } - else - { - await AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.Compare(c.OrderDate.Value, myDatetime) == 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != DateTime.Compare(c.OrderDate.Value, myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.Compare(c.OrderDate.Value, myDatetime) > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= DateTime.Compare(c.OrderDate.Value, myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 < DateTime.Compare(c.OrderDate.Value, myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.Compare(c.OrderDate.Value, myDatetime) <= 0)); - } - } - - [ConditionalTheory] - [InlineData(false, false)] - [InlineData(true, false)] - [InlineData(false, true)] - [InlineData(true, true)] - public virtual async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) - { - var myDatetime = new DateTime(1998, 5, 4); - - if (compareTo) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderDate.Value.CompareTo(myDatetime) == 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != c.OrderDate.Value.CompareTo(myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderDate.Value.CompareTo(myDatetime) > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= c.OrderDate.Value.CompareTo(myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 < c.OrderDate.Value.CompareTo(myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderDate.Value.CompareTo(myDatetime) <= 0)); - } - else - { - await AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.Compare(c.OrderDate.Value, myDatetime) == 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != DateTime.Compare(c.OrderDate.Value, myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.Compare(c.OrderDate.Value, myDatetime) > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= DateTime.Compare(c.OrderDate.Value, myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 < DateTime.Compare(c.OrderDate.Value, myDatetime))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.Compare(c.OrderDate.Value, myDatetime) <= 0)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Int_Compare_to_simple_zero(bool async) - { - var orderId = 10250; - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderID.CompareTo(orderId) == 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 != c.OrderID.CompareTo(orderId))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderID.CompareTo(orderId) > 0)); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 >= c.OrderID.CompareTo(orderId))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => 0 < c.OrderID.CompareTo(orderId))); - - await AssertQuery( - async, - ss => ss.Set().Where(c => c.OrderID.CompareTo(orderId) <= 0)); - } - - protected static string LocalMethod1() - => "M"; - - protected static string LocalMethod2() - => "m"; - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_abs1(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => Math.Abs(od.ProductID) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_abs2(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.UnitPrice < 7) - .Where(od => Math.Abs(od.Quantity) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_abs3(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Where(od => Math.Abs(od.UnitPrice) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_abs_uncorrelated(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.UnitPrice < 7) - .Where(od => Math.Abs(-10) < od.ProductID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_ceiling1(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.UnitPrice < 7) - .Where(od => Math.Ceiling(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_ceiling2(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Where(od => Math.Ceiling(od.UnitPrice) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_floor(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Where(od => Math.Floor(od.UnitPrice) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_power(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => Math.Pow(od.Discount, 3) > 0.005f)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_square(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => Math.Pow(od.Discount, 2) > 0.05f)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_round(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Where(od => Math.Round(od.UnitPrice) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Sum_over_round_works_correctly_in_projection(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(o => o.OrderID < 10300) - .Select(o => new { o.OrderID, Sum = o.OrderDetails.Sum(i => Math.Round(i.UnitPrice, 2)) }), - elementSorter: e => e.OrderID, - elementAsserter: (e, a) => - { - Assert.Equal(e.OrderID, a.OrderID); - Assert.Equal(e.Sum, a.Sum); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Sum_over_round_works_correctly_in_projection_2(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(o => o.OrderID < 10300) - .Select(o => new { o.OrderID, Sum = o.OrderDetails.Select(i => i.UnitPrice * i.UnitPrice).Sum(i => Math.Round(i, 2)) }), - elementSorter: e => e.OrderID, - elementAsserter: (e, a) => - { - Assert.Equal(e.OrderID, a.OrderID); - Assert.Equal(e.Sum, a.Sum); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Sum_over_truncate_works_correctly_in_projection(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(o => o.OrderID < 10300) - .Select(o => new { o.OrderID, Sum = o.OrderDetails.Sum(i => Math.Truncate(i.UnitPrice)) }), - elementSorter: e => e.OrderID, - elementAsserter: (e, a) => - { - Assert.Equal(e.OrderID, a.OrderID); - Assert.Equal(e.Sum, a.Sum); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Sum_over_truncate_works_correctly_in_projection_2(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(o => o.OrderID < 10300) - .Select(o => new { o.OrderID, Sum = o.OrderDetails.Select(i => i.UnitPrice * i.UnitPrice).Sum(i => Math.Truncate(i)) }), - elementSorter: e => e.OrderID, - elementAsserter: (e, a) => - { - Assert.Equal(e.OrderID, a.OrderID); - Assert.Equal(e.Sum, a.Sum); - }); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_math_round_int(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(o => o.OrderID < 10250) - .Select(o => new { A = Math.Round((double)o.OrderID) }), - e => e.A); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_math_truncate_int(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(o => o.OrderID < 10250) - .Select(o => new { A = Math.Truncate((double)o.OrderID) }), - e => e.A); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_round2(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => Math.Round(od.UnitPrice, 2) > 100)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_truncate(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Where(od => Math.Truncate(od.UnitPrice) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_exp(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Exp(od.Discount) > 1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_log10(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077 && od.Discount > 0).Where(od => Math.Log10(od.Discount) < 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_log(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077 && od.Discount > 0).Where(od => Math.Log(od.Discount) < 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_log_new_base(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077 && od.Discount > 0).Where(od => Math.Log(od.Discount, 7) < -1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_sqrt(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Sqrt(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_acos(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Acos(od.Discount) > 1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_asin(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Asin(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_atan(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Atan(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_atan2(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Atan2(od.Discount, 1) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_cos(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Cos(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_sin(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Sin(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_tan(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Tan(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_sign(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Sign(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_max(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Max(od.OrderID, od.ProductID) == od.OrderID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_max_nested(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077) - .Where(od => Math.Max(od.OrderID, Math.Max(od.ProductID, 1)) == od.OrderID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_max_nested_twice(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077) - .Where(od => Math.Max(Math.Max(1, Math.Max(od.OrderID, 2)), od.ProductID) == od.OrderID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_min(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077) - .Where(od => Math.Min(od.OrderID, od.ProductID) == od.ProductID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_min_nested(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077) - .Where(od => Math.Min(od.OrderID, Math.Min(od.ProductID, 99999)) == od.ProductID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_min_nested_twice(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077) - .Where(od => Math.Min(Math.Min(99999, Math.Min(od.OrderID, 99998)), od.ProductID) == od.ProductID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_degrees(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => double.RadiansToDegrees(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_math_radians(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => double.DegreesToRadians(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_abs1(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => MathF.Abs(od.ProductID) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_ceiling1(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.UnitPrice < 7) - .Where(od => MathF.Ceiling(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_floor(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Where(od => MathF.Floor((float)od.UnitPrice) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_power(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => MathF.Pow(od.Discount, 3) > 0.005f)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_square(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => MathF.Pow(od.Discount, 2) > 0.05f)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_round2(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => MathF.Round((float)od.UnitPrice, 2) > 100)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_mathf_round(bool async) - => AssertQueryScalar( - async, - ss => ss.Set() - .Where(o => o.OrderID < 10250) - .Select(o => MathF.Round(o.OrderID))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_mathf_round2(bool async) - => AssertQueryScalar( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Select(od => MathF.Round((float)od.UnitPrice, 2))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_truncate(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Where(od => MathF.Truncate((float)od.UnitPrice) > 10)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_mathf_truncate(bool async) - => AssertQueryScalar( - async, - ss => ss.Set() - .Where(od => od.Quantity < 5) - .Select(od => MathF.Truncate((float)od.UnitPrice))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_exp(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Exp(od.Discount) > 1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_log10(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077 && od.Discount > 0).Where(od => MathF.Log10(od.Discount) < 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_log(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077 && od.Discount > 0).Where(od => MathF.Log(od.Discount) < 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_log_new_base(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077 && od.Discount > 0).Where(od => MathF.Log(od.Discount, 7) < -1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_sqrt(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Sqrt(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_acos(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Acos(od.Discount) > 1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_asin(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Asin(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_atan(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Atan(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_atan2(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Atan2(od.Discount, 1) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_cos(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Cos(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_sin(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Sin(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_tan(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Tan(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_sign(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => MathF.Sign(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_degrees(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => float.RadiansToDegrees(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_mathf_radians(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => float.DegreesToRadians(od.Discount) > 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_guid_newguid(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(od => Guid.NewGuid() != default)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_to_upper(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.ToUpper() == "ALFKI")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_to_lower(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID.ToLower() == "alfki")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_functions_nested(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => Math.Pow(c.CustomerID.Length, 2) == 25)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToBoolean(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToBoolean(Convert.ToBoolean(o.OrderID % 3)), - o => Convert.ToBoolean(Convert.ToByte(o.OrderID % 3)), - o => Convert.ToBoolean(Convert.ToDecimal(o.OrderID % 3)), - o => Convert.ToBoolean(Convert.ToDouble(o.OrderID % 3)), - o => Convert.ToBoolean((float)Convert.ToDouble(o.OrderID % 3)), - o => Convert.ToBoolean(Convert.ToInt16(o.OrderID % 3)), - o => Convert.ToBoolean(Convert.ToInt32(o.OrderID % 3)), - o => Convert.ToBoolean(Convert.ToInt64(o.OrderID % 3)), - o => Convert.ToBoolean((object)Convert.ToInt32(o.OrderID % 3)) - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToByte(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToByte(Convert.ToBoolean(o.OrderID % 1)) >= 0, - o => Convert.ToByte(Convert.ToByte(o.OrderID % 1)) >= 0, - o => Convert.ToByte(Convert.ToDecimal(o.OrderID % 1)) >= 0, - o => Convert.ToByte(Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToByte((float)Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToByte(Convert.ToInt16(o.OrderID % 1)) >= 0, - o => Convert.ToByte(Convert.ToInt32(o.OrderID % 1)) >= 0, - o => Convert.ToByte(Convert.ToInt64(o.OrderID % 1)) >= 0, - o => Convert.ToByte(Convert.ToString(o.OrderID % 1)) >= 0, - o => Convert.ToByte((object)Convert.ToString(o.OrderID % 1)) >= 0 - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToDecimal(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToDecimal(Convert.ToBoolean(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal(Convert.ToByte(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal(Convert.ToDecimal(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal(Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal((float)Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal(Convert.ToInt16(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal(Convert.ToInt32(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal(Convert.ToInt64(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal(Convert.ToString(o.OrderID % 1)) >= 0, - o => Convert.ToDecimal((object)Convert.ToString(o.OrderID % 1)) >= 0 - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToDouble(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToDouble(Convert.ToBoolean(o.OrderID % 1)) >= 0, - o => Convert.ToDouble(Convert.ToByte(o.OrderID % 1)) >= 0, - o => Convert.ToDouble(Convert.ToDecimal(o.OrderID % 1)) >= 0, - o => Convert.ToDouble(Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToDouble((float)Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToDouble(Convert.ToInt16(o.OrderID % 1)) >= 0, - o => Convert.ToDouble(Convert.ToInt32(o.OrderID % 1)) >= 0, - o => Convert.ToDouble(Convert.ToInt64(o.OrderID % 1)) >= 0, - o => Convert.ToDouble(Convert.ToString(o.OrderID % 1)) >= 0, - o => Convert.ToDouble((object)Convert.ToString(o.OrderID % 1)) >= 0 - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToInt16(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToInt16(Convert.ToBoolean(o.OrderID % 1)) >= 0, - o => Convert.ToInt16(Convert.ToByte(o.OrderID % 1)) >= 0, - o => Convert.ToInt16(Convert.ToDecimal(o.OrderID % 1)) >= 0, - o => Convert.ToInt16(Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToInt16((float)Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToInt16(Convert.ToInt16(o.OrderID % 1)) >= 0, - o => Convert.ToInt16(Convert.ToInt32(o.OrderID % 1)) >= 0, - o => Convert.ToInt16(Convert.ToInt64(o.OrderID % 1)) >= 0, - o => Convert.ToInt16(Convert.ToString(o.OrderID % 1)) >= 0, - o => Convert.ToInt16((object)Convert.ToString(o.OrderID % 1)) >= 0 - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToInt32(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToInt32(Convert.ToBoolean(o.OrderID % 1)) >= 0, - o => Convert.ToInt32(Convert.ToByte(o.OrderID % 1)) >= 0, - o => Convert.ToInt32(Convert.ToDecimal(o.OrderID % 1)) >= 0, - o => Convert.ToInt32(Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToInt32((float)Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToInt32(Convert.ToInt16(o.OrderID % 1)) >= 0, - o => Convert.ToInt32(Convert.ToInt32(o.OrderID % 1)) >= 0, - o => Convert.ToInt32(Convert.ToInt64(o.OrderID % 1)) >= 0, - o => Convert.ToInt32(Convert.ToString(o.OrderID % 1)) >= 0, - o => Convert.ToInt32((object)Convert.ToString(o.OrderID % 1)) >= 0 - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToInt64(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToInt64(Convert.ToBoolean(o.OrderID % 1)) >= 0, - o => Convert.ToInt64(Convert.ToByte(o.OrderID % 1)) >= 0, - o => Convert.ToInt64(Convert.ToDecimal(o.OrderID % 1)) >= 0, - o => Convert.ToInt64(Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToInt64((float)Convert.ToDouble(o.OrderID % 1)) >= 0, - o => Convert.ToInt64(Convert.ToInt16(o.OrderID % 1)) >= 0, - o => Convert.ToInt64(Convert.ToInt32(o.OrderID % 1)) >= 0, - o => Convert.ToInt64(Convert.ToInt64(o.OrderID % 1)) >= 0, - o => Convert.ToInt64(Convert.ToString(o.OrderID % 1)) >= 0, - o => Convert.ToInt64((object)Convert.ToString(o.OrderID % 1)) >= 0 - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Convert_ToString(bool async) - { - var convertMethods = new List>> - { - o => Convert.ToString(Convert.ToBoolean(o.OrderID % 1)) != "10", - o => Convert.ToString(Convert.ToByte(o.OrderID % 1)) != "10", - o => Convert.ToString(Convert.ToDecimal(o.OrderID % 1)) != "10", - o => Convert.ToString(Convert.ToDouble(o.OrderID % 1)) != "10", - o => Convert.ToString((float)Convert.ToDouble(o.OrderID % 1)) != "10", - o => Convert.ToString(Convert.ToInt16(o.OrderID % 1)) != "10", - o => Convert.ToString(Convert.ToInt32(o.OrderID % 1)) != "10", - o => Convert.ToString(Convert.ToInt64(o.OrderID % 1)) != "10", - o => Convert.ToString(Convert.ToString(o.OrderID % 1)) != "10", - o => Convert.ToString((object)Convert.ToString(o.OrderID % 1)) != "10", - o => Convert.ToString(o.OrderDate.Value).Contains("1997") || Convert.ToString(o.OrderDate.Value).Contains("1998") - }; - - foreach (var convertMethod in convertMethods) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => o.CustomerID == "ALFKI") - .Where(convertMethod)); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Indexof_with_emptystring(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.Region.IndexOf(string.Empty) == 0), - ss => ss.Set().Where(c => c.Region != null && c.Region.IndexOf(string.Empty) == 0) - ); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Indexof_with_one_constant_arg(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.IndexOf("a") == 1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Indexof_with_one_parameter_arg(bool async) - { - var pattern = "a"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.IndexOf(pattern) == 1)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Indexof_with_constant_starting_position(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.IndexOf("a", 2) == 4)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Indexof_with_parameter_starting_position(bool async) - { - var start = 2; - - return AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.IndexOf("a", start) == 4)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Replace_with_emptystring(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Replace("ia", string.Empty) == "Mar Anders")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Replace_using_property_arguments(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Replace(c.ContactName, c.CustomerID) == c.CustomerID)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_one_arg_with_zero_startindex(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(c => c.CustomerID.Substring(0) == "ALFKI") - .Select(c => c.ContactName)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_one_arg_with_constant(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(c => c.CustomerID.Substring(1) == "LFKI") - .Select(c => c.ContactName)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_one_arg_with_closure(bool async) - { - var start = 2; - - return AssertQuery( - async, - ss => ss.Set() - .Where(c => c.CustomerID.Substring(start) == "FKI") - .Select(c => c.ContactName)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_two_args_with_zero_startindex(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI").Select(c => c.ContactName.Substring(0, 3))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_two_args_with_zero_length(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI").Select(c => c.ContactName.Substring(2, 0))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_two_args_with_constant(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI").Select(c => c.ContactName.Substring(1, 3))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_two_args_with_closure(bool async) - { - var start = 2; - - return AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI").Select(c => c.ContactName.Substring(start, 3))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Substring_with_two_args_with_Index_of(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID == "ALFKI") - .Select(c => c.ContactName.Substring(c.ContactName.IndexOf("a"), 3))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task IsNullOrEmpty_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => string.IsNullOrEmpty(c.Region))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task IsNullOrEmpty_in_projection(bool async) - => AssertQuery( - async, - ss => ss.Set().Select(c => new { Id = c.CustomerID, Value = string.IsNullOrEmpty(c.Region) }), - elementSorter: e => e.Id); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task IsNullOrEmpty_negated_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => !string.IsNullOrEmpty(c.Region))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task IsNullOrEmpty_negated_in_projection(bool async) - => AssertQuery( - async, - ss => ss.Set().Select(c => new { Id = c.CustomerID, Value = !string.IsNullOrEmpty(c.Region) }), - elementSorter: e => e.Id); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task IsNullOrWhiteSpace_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => string.IsNullOrWhiteSpace(c.Region))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => string.IsNullOrWhiteSpace(c.CustomerID)), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TrimStart_without_arguments_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.TrimStart() == "Owner")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TrimStart_with_char_argument_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.TrimStart('O') == "wner")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TrimStart_with_char_array_argument_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.TrimStart(new [] {'O', 'w'}) == "ner")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TrimEnd_without_arguments_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.TrimEnd() == "Owner")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TrimEnd_with_char_argument_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.TrimEnd('r') == "Owne")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task TrimEnd_with_char_array_argument_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.TrimEnd(new [] {'e', 'r'}) == "Own")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Trim_without_argument_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.Trim() == "Owner")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Trim_with_char_argument_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.Trim('O') == "wner")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Trim_with_char_array_argument_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactTitle.Trim(new [] {'O', 'r'}) == "wne")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Order_by_length_twice(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID), - assertOrder: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool async) - => AssertQuery( - async, - ss => ss.Set().OrderBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID.Length).ThenBy(c => c.CustomerID) - .Select(c => c.Orders), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e, a)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Static_string_equals_in_predicate(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => string.Equals(c.CustomerID, "ANATR"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) - { - var arg = new DateTime(1996, 7, 4); - - return AssertQuery( - async, - ss => ss.Set().Where(o => Equals(o.OrderDate, arg))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Static_equals_int_compared_to_long(bool async) - { - long arg = 10248; - - return AssertQuery( + return AssertQuery( async, ss => ss.Set().Where(o => Equals(o.OrderID, arg)), assertEmpty: true); } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID < 10250).Select(o => new { A = Math.Truncate((double)o.OrderID) }) - .OrderBy(r => r.A) - .OrderBy(r => r.A), - assertOrder: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID < 10250).Select(o => new { A = Math.Truncate((double)o.OrderID) }) - .OrderBy(r => r.A) - .OrderByDescending(r => r.A), - assertOrder: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID < 10250).Select(o => new { A = Math.Truncate((double)o.OrderID) }) - .OrderByDescending(r => r.A) - .ThenBy(r => r.A), - assertOrder: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch(o.CustomerID, "^T"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Regex_IsMatch_MethodCall_constant_input(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => Regex.IsMatch("ALFKI", o.CustomerID))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Datetime_subtraction_TotalDays(bool async) - { - var date = new DateTime(1997, 1, 1); - return AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.HasValue && (o.OrderDate.Value - date).TotalDays > 365)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_DateOnly_FromDateTime(bool async) - => AssertQuery( - async, - ss => ss.Set() - .Where(o => o.OrderDate.HasValue && DateOnly.FromDateTime(o.OrderDate.Value) == new DateOnly(1996, 9, 16)) - .AsTracking()); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_ToString_IndexOf(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(x => x.OrderID.ToString().IndexOf("123") == -1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_IndexOf_ToString(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(x => "123".IndexOf(x.OrderID.ToString()) == -1)); } diff --git a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs index 057c2b0a5c6..d23184ec337 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindNavigationsQueryTestBase.cs @@ -687,7 +687,7 @@ public virtual Task Collection_select_nav_prop_first_or_default_then_nav_prop_ne "City")), ss => ss.Set().Where(c => c.CustomerID.StartsWith("A")) .Select( - c => ss.Set().FirstOrDefault(o => o.CustomerID == "ALFKI").Customer != null + c => Queryable.FirstOrDefault(ss.Set(), o => o.CustomerID == "ALFKI").Customer != null ? ss.Set().FirstOrDefault(o => o.CustomerID == "ALFKI").Customer.City : null) ); diff --git a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs index f7c619d7c6d..80b469918a5 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindSelectQueryTestBase.cs @@ -2337,7 +2337,7 @@ public virtual Task Client_projection_with_string_initialization_with_scalar_sub c => new { c.CustomerID, - Order = c.Orders.FirstOrDefault(o => o.OrderID < 11000).MaybeScalar(e => e.OrderDate), + Order = Enumerable.FirstOrDefault(c.Orders, o => o.OrderID < 11000).MaybeScalar(e => e.OrderDate), InterpolatedString = $"test{c.City}", NonInterpolatedString = "test" + c.City, Collection = new List diff --git a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs index d9cdbbaa7ee..c0ab9606117 100644 --- a/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/NorthwindWhereQueryTestBase.cs @@ -553,20 +553,6 @@ public virtual Task Where_client_deep_inside_predicate_and_server_top_level(bool .Where(c => c.CustomerID != "ALFKI" && (c.CustomerID == "MAUMAR" || (c.CustomerID != "AROUT" && c.IsLondon)))), CoreStrings.QueryUnableToTranslateMember(nameof(Customer.IsLondon), nameof(Customer))); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_equals_method_string(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.City.Equals("London"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_equals_method_string_with_ignore_case(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.City.Equals("London", StringComparison.OrdinalIgnoreCase))); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_equals_method_int(bool async) @@ -692,162 +678,6 @@ public virtual Task Where_comparison_nullable_type_null(bool async) async, ss => ss.Set().Where(e => e.ReportsTo == null)); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_length(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.City.Length == 6)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_indexof(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.City.IndexOf("Sea") != -1)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_replace(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.City.Replace("Sea", "Rea") == "Reattle")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_substring(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => c.City.Substring(1, 2) == "ea")); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_now(bool async) - { - var myDatetime = new DateTime(2015, 4, 10); - - return AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.Now != myDatetime)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_utcnow(bool async) - { - var myDatetime = new DateTime(2015, 4, 10); - - return AssertQuery( - async, - ss => ss.Set().Where(c => DateTime.UtcNow != myDatetime)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_utcnow(bool async) - { - var myDatetimeOffset = new DateTimeOffset(2015, 4, 10, 0, 0, 0, new TimeSpan(-8, 0, 0)); - - return AssertQuery( - async, - ss => ss.Set().Where(c => DateTimeOffset.UtcNow != myDatetimeOffset)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_today(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(e => DateTime.Now.Date == DateTime.Today)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_date_component(bool async) - { - var myDatetime = new DateTime(1998, 5, 4); - - return AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Date == myDatetime)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_date_add_year_constant_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.AddYears(-1).Year == 1997)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_year_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Year == 1998)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_month_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Month == 4)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_dayOfYear_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.DayOfYear == 68)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_day_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Day == 4)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_hour_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Hour == 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_minute_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Minute == 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_second_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Second == 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetime_millisecond_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate.Value.Millisecond == 0)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_now_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate < DateTimeOffset.Now)); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_datetimeoffset_utcnow_component(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderDate != DateTimeOffset.UtcNow)); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_simple_reversed(bool async) @@ -1306,102 +1136,6 @@ public virtual Task Where_expression_invoke_3(bool async) ss => ss.Set().Where(lambda)); } - //see issue #31917 - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_concat_string_int_comparison1(bool async) - { - var i = 10; - - return AssertQuery( - async, - ss => ss.Set().Where(c => c.CustomerID + i == c.CompanyName).Select(c => c.CustomerID), - assertEmpty: true); - } - - //see issue #31917 - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_concat_string_int_comparison2(bool async) - { - var i = 10; - - return AssertQuery( - async, - ss => ss.Set().Where(c => i + c.CustomerID == c.CompanyName).Select(c => c.CustomerID), - assertEmpty: true); - } - - //see issue #31917 - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_concat_string_int_comparison3(bool async) - { - var i = 10; - var j = 21; - - return AssertQuery( - async, - ss => ss.Set().Where(c => i + 20 + c.CustomerID + j + 42 == c.CompanyName).Select(c => c.CustomerID), - assertEmpty: true); - } - - //see issue #31917 - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_concat_string_int_comparison4(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => o.OrderID + o.CustomerID == o.CustomerID).Select(c => c.CustomerID), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_concat_string_string_comparison(bool async) - { - var i = "A"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => i + c.CustomerID == "AALFKI").Select(c => c.CustomerID)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_concat_method_comparison(bool async) - { - var i = "A"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => string.Concat(i, c.CustomerID) == "AAROUT").Select(c => c.CustomerID)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_concat_method_comparison_2(bool async) - { - var i = "A"; - var j = "B"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => string.Concat(i, j, c.CustomerID) == "ABANATR").Select(c => c.CustomerID)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_string_concat_method_comparison_3(bool async) - { - var i = "A"; - var j = "B"; - var k = "C"; - - return AssertQuery( - async, - ss => ss.Set().Where(c => string.Concat(i, j, k, c.CustomerID) == "ABCANTON").Select(c => c.CustomerID)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Where_ternary_boolean_condition_true(bool async) @@ -1653,13 +1387,6 @@ public virtual Task Where_subquery_FirstOrDefault_compared_to_entity(bool async) ss => ss.Set().Where( c => c.Orders.OrderBy(o => o.OrderID).FirstOrDefault().OrderID == 10276)); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Time_of_day_datetime(bool async) - => AssertQueryScalar( - async, - ss => ss.Set().Select(o => o.OrderDate.Value.TimeOfDay)); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task TypeBinary_short_circuit(bool async) @@ -1754,22 +1481,6 @@ public virtual Task Filter_non_nullable_value_after_FirstOrDefault_on_empty_coll ss => ss.Set().Where(c => false), assertEmpty: true); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Like_with_non_string_column_using_ToString(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => EF.Functions.Like(o.OrderID.ToString(), "%20%")), - ss => ss.Set().Where(o => o.OrderID.ToString().Contains("20"))); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Like_with_non_string_column_using_double_cast(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(o => EF.Functions.Like((string)(object)o.OrderID, "%20%")), - ss => ss.Set().Where(o => o.OrderID.ToString().Contains("20"))); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Using_same_parameter_twice_in_query_generates_one_sql_parameter(bool async) @@ -2308,23 +2019,6 @@ public virtual Task Where_Contains_or_comparison(bool async) ss => ss.Set().Where(c => customerIds.Contains(c.CustomerID) || c.City == "Seattle")); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_Like_and_comparison(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => EF.Functions.Like(c.CustomerID, "F%") && c.City == "Seattle"), - ss => ss.Set().Where(c => c.CustomerID.StartsWith("F") && c.City == "Seattle"), - assertEmpty: true); - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Where_Like_or_comparison(bool async) - => AssertQuery( - async, - ss => ss.Set().Where(c => EF.Functions.Like(c.CustomerID, "F%") || c.City == "Seattle"), - ss => ss.Set().Where(c => c.CustomerID.StartsWith("F") || c.City == "Seattle")); - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task GetType_on_non_hierarchy1(bool async) diff --git a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs index 51f16b590f5..6c62e859c7a 100644 --- a/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/OwnedQueryTestBase.cs @@ -987,7 +987,7 @@ public virtual Task FirstOrDefault_over_owned_collection(bool async) async, ss => ss.Set().Where(p => ((DateTime)p.Orders.FirstOrDefault(o => o.Id > -20)["OrderDate"]).Year == 2018), ss => ss.Set().Where( - p => p.Orders.FirstOrDefault(o => o.Id > -20) != null + p => Enumerable.FirstOrDefault(p.Orders, o => o.Id > -20) != null && ((DateTime)p.Orders.FirstOrDefault(o => o.Id > -20)["OrderDate"]).Year == 2018)); [ConditionalTheory] diff --git a/test/EFCore.Specification.Tests/Query/Translations/BasicTypesQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/Translations/BasicTypesQueryFixtureBase.cs new file mode 100644 index 00000000000..a1d77db06ab --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/Translations/BasicTypesQueryFixtureBase.cs @@ -0,0 +1,112 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class BasicTypesQueryFixtureBase : SharedStoreFixtureBase, IQueryFixtureBase +{ + private BasicTypesData? _expectedData; + + protected override string StoreName + => "BasicTypesTest"; + + public Func GetContextCreator() + => () => CreateContext(); + + protected override Task SeedAsync(BasicTypesContext context) + { + var data = new BasicTypesData(); + context.AddRange(data.BasicTypesEntities); + context.AddRange(data.NullableBasicTypesEntities); + return context.SaveChangesAsync(); + } + + public virtual ISetSource GetExpectedData() + => _expectedData ??= new BasicTypesData(); + + public IReadOnlyDictionary EntitySorters { get; } = new Dictionary> + { + { typeof(BasicTypesEntity), e => ((BasicTypesEntity?)e)?.Id }, + { typeof(NullableBasicTypesEntity), e => ((NullableBasicTypesEntity?)e)?.Id } + }.ToDictionary(e => e.Key, e => (object)e.Value); + + public IReadOnlyDictionary EntityAsserters { get; } = new Dictionary> + { + { + typeof(BasicTypesEntity), (e, a) => + { + Assert.Equal(e == null, a == null); + + if (a != null) + { + var ee = (BasicTypesEntity)e!; + var aa = (BasicTypesEntity)a; + + Assert.Equal(ee.Id, aa.Id); + + Assert.Equal(ee.Byte, aa.Byte); + Assert.Equal(ee.Short, aa.Short); + Assert.Equal(ee.Int, aa.Int); + Assert.Equal(ee.Long, aa.Long); + Assert.Equal(ee.Float, aa.Float); + Assert.Equal(ee.Double, aa.Double); + Assert.Equal(ee.Decimal, aa.Decimal); + + Assert.Equal(ee.String, aa.String); + + Assert.Equal(ee.DateTime, aa.DateTime); + Assert.Equal(ee.DateOnly, aa.DateOnly); + Assert.Equal(ee.TimeOnly, aa.TimeOnly); + Assert.Equal(ee.DateTimeOffset, aa.DateTimeOffset); + Assert.Equal(ee.TimeSpan, aa.TimeSpan); + + Assert.Equal(ee.Bool, aa.Bool); + Assert.Equal(ee.Guid, aa.Guid); + Assert.Equivalent(ee.ByteArray, aa.ByteArray); + + Assert.Equal(ee.Enum, aa.Enum); + Assert.Equal(ee.FlagsEnum, aa.FlagsEnum); + } + } + }, + { + typeof(NullableBasicTypesEntity), (e, a) => + { + Assert.Equal(e == null, a == null); + + if (a != null) + { + var ee = (NullableBasicTypesEntity)e!; + var aa = (NullableBasicTypesEntity)a; + + Assert.Equal(ee.Id, aa.Id); + + Assert.Equal(ee.Byte, aa.Byte); + Assert.Equal(ee.Short, aa.Short); + Assert.Equal(ee.Int, aa.Int); + Assert.Equal(ee.Long, aa.Long); + Assert.Equal(ee.Float, aa.Float); + Assert.Equal(ee.Double, aa.Double); + Assert.Equal(ee.Decimal, aa.Decimal); + + Assert.Equal(ee.String, aa.String); + + Assert.Equal(ee.DateTime, aa.DateTime); + Assert.Equal(ee.DateOnly, aa.DateOnly); + Assert.Equal(ee.TimeOnly, aa.TimeOnly); + Assert.Equal(ee.DateTimeOffset, aa.DateTimeOffset); + Assert.Equal(ee.TimeSpan, aa.TimeSpan); + + Assert.Equal(ee.Bool, aa.Bool); + Assert.Equal(ee.Guid, aa.Guid); + Assert.Equivalent(ee.ByteArray, aa.ByteArray); + + Assert.Equal(ee.Enum, aa.Enum); + Assert.Equal(ee.FlagsEnum, aa.FlagsEnum); + } + } + } + }.ToDictionary(e => e.Key, e => (object)e.Value); +} diff --git a/test/EFCore.Specification.Tests/Query/Translations/EnumTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/EnumTranslationsTestBase.cs new file mode 100644 index 00000000000..5520689a725 --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/Translations/EnumTranslationsTestBase.cs @@ -0,0 +1,252 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class EnumTranslationsTestBase(TFixture fixture) : QueryTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + #region Equality + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equality_to_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Enum == BasicEnum.One)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equality_to_parameter(bool async) + { + var basicEnum = BasicEnum.One; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.Enum == basicEnum)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equality_nullable_enum_to_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Enum == BasicEnum.One)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equality_nullable_enum_to_parameter(bool async) + { + var basicEnum = BasicEnum.One; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.Enum == basicEnum)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equality_nullable_enum_to_null_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Enum == null)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equality_nullable_enum_to_null_parameter(bool async) + { + BasicEnum? basicEnum = null; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.Enum == basicEnum)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equality_nullable_enum_to_nullable_parameter(bool async) + { + BasicEnum? basicEnum = BasicEnum.One; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.Enum == basicEnum)); + } + + #endregion Equality + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Bitwise_and_enum_constant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(g => (g.FlagsEnum & BasicFlagsEnum.One) > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(g => (g.FlagsEnum & BasicFlagsEnum.One) == BasicFlagsEnum.One)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Bitwise_and_integral_constant(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(g => ((int)g.FlagsEnum & 8) == 8)); + + await AssertQuery( + async, + ss => ss.Set().Where(g => ((long)g.FlagsEnum & 8L) == 8L)); + + await AssertQuery( + async, + ss => ss.Set().Where(g => ((short)g.FlagsEnum & 8) == 8)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_and_nullable_enum_with_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(w => (w.FlagsEnum & BasicFlagsEnum.Eight) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) + { + return AssertQuery( + async, +#pragma warning disable CS0458 // The result of the expression is always 'null' + ss => ss.Set().Where(w => (w.FlagsEnum & null) > 0), +#pragma warning restore CS0458 // The result of the expression is always 'null' + assertEmpty: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) + { + var flagsEnum = BasicFlagsEnum.Eight; + + return AssertQuery( + async, + ss => ss.Set().Where(w => (w.FlagsEnum & flagsEnum) > 0)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) + { + BasicFlagsEnum? flagsEnum = BasicFlagsEnum.Eight; + + await AssertQuery( + async, + ss => ss.Set().Where(w => (w.FlagsEnum & flagsEnum) > 0)); + + flagsEnum = null; + + await AssertQuery( + async, + ss => ss.Set().Where(w => (w.FlagsEnum & flagsEnum) > 0), + assertEmpty: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_or(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(g => (g.FlagsEnum | BasicFlagsEnum.Eight) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Bitwise_projects_values_in_select(bool async) + => AssertFirst( + async, + ss => ss.Set() + .Where(g => (g.FlagsEnum & BasicFlagsEnum.Eight) == BasicFlagsEnum.Eight) + .Select( + b => new + { + BitwiseTrue = (b.FlagsEnum & BasicFlagsEnum.Eight) == BasicFlagsEnum.Eight, + // ReSharper disable once NonConstantEqualityExpressionHasConstantResult + BitwiseFalse = (b.FlagsEnum & BasicFlagsEnum.Eight) == BasicFlagsEnum.Four, + BitwiseValue = b.FlagsEnum & BasicFlagsEnum.Eight + })); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task HasFlag(bool async) + { + // Constant + await AssertQuery( + async, + ss => ss.Set().Where(b => b.FlagsEnum.HasFlag(BasicFlagsEnum.Eight))); + + // Expression + await AssertQuery( + async, + ss => ss.Set().Where(b => b.FlagsEnum.HasFlag(BasicFlagsEnum.Eight | BasicFlagsEnum.Four)), + assertEmpty: true); + + // Casting + await AssertQuery( + async, + ss => ss.Set().Where(b => b.FlagsEnum.HasFlag((BasicFlagsEnum)8))); + + // Casting to nullable + await AssertQuery( + async, + ss => ss.Set().Where(b => b.FlagsEnum.HasFlag((BasicFlagsEnum?)8))); + + // QuerySource + await AssertQuery( + async, + ss => ss.Set().Where(b => BasicFlagsEnum.Eight.HasFlag(b.FlagsEnum))); + + // Project out + await AssertFirst( + async, + ss => ss.Set() + .Where(b => b.FlagsEnum.HasFlag(BasicFlagsEnum.Eight)) + .Select( + b => new + { + hasFlagTrue = b.FlagsEnum.HasFlag(BasicFlagsEnum.Eight), + hasFlagFalse = b.FlagsEnum.HasFlag(BasicFlagsEnum.Four) + })); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task HasFlag_with_non_nullable_parameter(bool async) + { + var flagsEnum = BasicFlagsEnum.Eight; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.FlagsEnum.HasFlag(flagsEnum))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task HasFlag_with_nullable_parameter(bool async) + { + BasicFlagsEnum? flagsEnum = BasicFlagsEnum.Eight; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.FlagsEnum.HasFlag(flagsEnum))); + } + + protected BasicTypesContext CreateContext() + => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } +} diff --git a/test/EFCore.Specification.Tests/Query/Translations/MathTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/MathTranslationsTestBase.cs new file mode 100644 index 00000000000..9616ba4113f --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/Translations/MathTranslationsTestBase.cs @@ -0,0 +1,532 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class MathTranslationsTestBase(TFixture fixture) : QueryTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Abs_decimal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(od => Math.Abs(od.Decimal) == 9.5m)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Abs_int(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Abs(b.Int) == 9)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Abs_double(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Abs(b.Double) == 9.5)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Abs_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Abs(b.Float) == 9.5)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Ceiling(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Ceiling(b.Double) == 9)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Ceiling_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Ceiling(b.Float) == 9)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Floor_decimal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Floor(b.Decimal) == 8)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Floor_double(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Floor(b.Double) == 8)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Floor_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Floor(b.Float) == 8)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Exp(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Exp(b.Double) > 1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Exp_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Exp(b.Float) > 1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Power(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Pow(b.Int, 2) == 64)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Power_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Pow(b.Float, 2) > 73 && MathF.Pow(b.Float, 2) < 74)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Round_decimal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => Math.Round(b.Decimal) == 9)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => Math.Round(b.Decimal))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Round_double(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => Math.Round(b.Double) == 9)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => Math.Round(b.Double))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Round_float(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Round(b.Float) == 9)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => MathF.Round(b.Float))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Round_with_digits_decimal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Round(b.Decimal, 1) == 255.1m)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Round_with_digits_double(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Round(b.Double, 1) == 255.1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Round_with_digits_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Round(b.Float, 1) == 255.1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Truncate_decimal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => Math.Truncate(b.Decimal) == 8)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => Math.Truncate(b.Decimal))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Truncate_double(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => Math.Truncate(b.Double) == 8)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => Math.Truncate(b.Double))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Truncate_float(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Truncate(b.Float) == 8)); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => MathF.Truncate(b.Float))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Truncate_project_and_order_by_it_twice(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Select(b => new { A = Math.Truncate(b.Double) }) + .OrderBy(r => r.A) + // ReSharper disable once MultipleOrderBy + .OrderBy(r => r.A), + assertOrder: true); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Truncate_project_and_order_by_it_twice2(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Select(b => new { A = Math.Truncate(b.Double) }) + .OrderBy(r => r.A) + // ReSharper disable once MultipleOrderBy + .OrderByDescending(r => r.A), + assertOrder: true); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Truncate_project_and_order_by_it_twice3(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Select(b => new { A = Math.Truncate(b.Double) }) + .OrderByDescending(r => r.A) + .ThenBy(r => r.A), + assertOrder: true); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Log(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Double > 0 && Math.Log(b.Double) != 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Log_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Float > 0 && MathF.Log(b.Float) != 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Log_with_newBase(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Double > 0 && Math.Log(b.Double, 7) != 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Log_with_newBase_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Float > 0 && MathF.Log(b.Float, 7) != 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Log10(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Double > 0 && Math.Log10(b.Double) != 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Log10_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Float > 0 && MathF.Log10(b.Float) != 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Log2(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Double > 0 && Math.Log2(b.Double) != 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Sqrt(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Double > 0 && Math.Sqrt(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Sqrt_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Float > 0 && MathF.Sqrt(b.Float) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Sign(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Sign(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Sign_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Sign(b.Float) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Max(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Max(b.Int, b.Short - 3) == b.Int)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Max_nested(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Where(b => Math.Max(b.Short - 3, Math.Max(b.Int, 1)) == b.Int)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Max_nested_twice(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Where(b => Math.Max(Math.Max(1, Math.Max(b.Int, 2)), b.Short - 3) == b.Int)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Min(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Where(b => Math.Min(b.Int, b.Short + 3) == b.Int)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Min_nested(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Where(b => Math.Min(b.Short + 3, Math.Min(b.Int, 99999)) == b.Int)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Min_nested_twice(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Where(b => Math.Min(Math.Min(99999, Math.Min(b.Int, 99998)), b.Short + 3) == b.Int)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Degrees(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => double.RadiansToDegrees(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Degrees_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => float.RadiansToDegrees(b.Float) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Radians(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => double.DegreesToRadians(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Radians_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => float.DegreesToRadians(b.Float) > 0)); + + #region Trigonometry + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Acos(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Double >= -1 && b.Double <= 1 && Math.Acos(b.Double) > 1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Acos_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Float >= -1 && b.Float <= 1 && MathF.Acos(b.Float) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Acosh(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Acosh(b.Double + 1) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Asin(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Double >= -1 && b.Double <= 1 && Math.Asin(b.Double) > double.MinValue)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Asin_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Float >= -1 && b.Float <= 1 && MathF.Asin(b.Float) > double.MinValue)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Asinh(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Asinh(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Atan(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Atan(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Atan_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Atan(b.Float) > 0)); + + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Atanh(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Atanh(b.Double) > double.MinValue)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Atan2(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Atan2(b.Double, 1) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Atan2_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Atan2(b.Float, 1) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Cos(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Cos(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Cos_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Cos(b.Float) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Cosh(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Cosh(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Sin(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Sin(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Sin_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Sin(b.Float) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Sinh(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Sinh(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Tan(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Tan(b.Double) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Tan_float(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => MathF.Tan(b.Float) > 0)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Tanh(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => Math.Tanh(b.Double) > 0)); + + #endregion Trigonometry +} diff --git a/test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs new file mode 100644 index 00000000000..d3b98d701f3 --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/Translations/MiscellaneousTranslationsTestBase.cs @@ -0,0 +1,432 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class MiscellaneousTranslationsTestBase(TFixture fixture) : QueryTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + #region Guid + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Guid_new_with_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.Guid == new Guid("DF36F493-463F-4123-83F9-6B135DEEB7BA"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Guid_new_with_parameter(bool async) + { + var guid = "DF36F493-463F-4123-83F9-6B135DEEB7BA"; + + await AssertQuery( + async, + ss => ss.Set().Where(b => b.Guid == new Guid(guid))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Guid_ToString_projection(bool async) + => AssertQuery( + async, + ss => ss.Set().Select(b => b.Guid.ToString()), + elementAsserter: (e, a) => Assert.Equal(e.ToLower(), a.ToLower())); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Guid_NewGuid(bool async) + => AssertQuery( + async, + ss => ss.Set() + .Where(od => Guid.NewGuid() != default)); + + #endregion Guid + + #region Byte array + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Byte_array_Length(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.ByteArray.Length == 4)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Byte_array_array_index(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.ByteArray.Length >= 3 && e.ByteArray[2] == 0xBE)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Byte_array_First(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.ByteArray.Length >= 1 && e.ByteArray.First() == 0xDE)); + + #endregion Byte array + + #region Convert + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToBoolean(bool async) + { + var convertMethods = new List>> + { + o => Convert.ToBoolean(o.Bool), + o => Convert.ToBoolean(o.Byte), + o => Convert.ToBoolean(o.Decimal), + o => Convert.ToBoolean(o.Double), + o => Convert.ToBoolean(o.Float), + o => Convert.ToBoolean(o.Short), + o => Convert.ToBoolean(o.Int), + o => Convert.ToBoolean(o.Long), + o => Convert.ToBoolean((object)o.Int) + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToByte(bool async) + { + var convertMethods = new List>> + { + o => Convert.ToByte(o.Bool) == 1, + o => Convert.ToByte(o.Byte) == 8, + o => o.Decimal >= 0 && o.Decimal <= 255 && Convert.ToByte(o.Decimal) == 12, + o => o.Double >= 0 && o.Double <= 255 && Convert.ToByte(o.Double) == 12, + o => o.Float >= 0 && o.Float <= 255 && Convert.ToByte(o.Float) == 12, + o => o.Short >= 0 && o.Short <= 255 && Convert.ToByte(o.Short) == 12, + o => o.Int >= 0 && o.Int <= 255 && Convert.ToByte(o.Int) == 12, + o => o.Long >= 0 && o.Long <= 255 && Convert.ToByte(o.Long) == 12, + o => o.Int >= 0 && o.Int <= 255 && Convert.ToByte(Convert.ToString(o.Int)) == 12, + o => o.Int >= 0 && o.Int <= 255 && Convert.ToByte((object)o.Int) == 12 + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToDecimal(bool async) + { + var convertMethods = new List>> + { + o => Convert.ToDecimal(o.Bool) == 1, + o => Convert.ToDecimal(o.Byte) == 8, + o => Convert.ToDecimal(o.Decimal) == 8.6m, + o => Convert.ToDecimal(o.Double) == 8.6m, + o => Convert.ToDecimal(o.Float) == 8.6m, + o => Convert.ToDecimal(o.Short) == 8, + o => Convert.ToDecimal(o.Int) == 8, + o => Convert.ToDecimal(o.Long) == 8, + o => Convert.ToDecimal(Convert.ToString(o.Int)) == 8, + o => Convert.ToDecimal((object)o.Int) == 8 + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToDouble(bool async) + { + var convertMethods = new List>> + { + o => Convert.ToDouble(o.Bool) == 1, + o => Convert.ToDouble(o.Byte) == 8, + o => Convert.ToDouble(o.Decimal) == 8.6d, + o => Convert.ToDouble(o.Double) > 8d && Convert.ToDouble(o.Double) < 9d, + o => Convert.ToDouble(o.Float) > 8d && Convert.ToDouble(o.Float) < 9d, + o => Convert.ToDouble(o.Short) == 8, + o => Convert.ToDouble(o.Int) == 8, + o => Convert.ToDouble(o.Long) == 8, + o => Convert.ToDouble(Convert.ToString(o.Int)) == 8, + o => Convert.ToDouble((object)o.Int) == 8 + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToInt16(bool async) + { + var convertMethods = new List>> + { + o => Convert.ToInt16(o.Bool) == 1, + o => Convert.ToInt16(o.Byte) == 12, + o => Convert.ToInt16(o.Decimal) == 12, + o => Convert.ToInt16(o.Double) == 12, + o => Convert.ToInt16(o.Float) == 12, + o => Convert.ToInt16(o.Short) == 12, + o => Convert.ToInt16(o.Int) == 12, + o => Convert.ToInt16(o.Long) == 12, + o => Convert.ToInt16(Convert.ToString(o.Int)) == 12, + o => Convert.ToInt16((object)o.Int) == 12 + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToInt32(bool async) + { + var convertMethods = new List>> + { + o => Convert.ToInt32(o.Bool) == 1, + o => Convert.ToInt32(o.Byte) == 12, + o => Convert.ToInt32(o.Decimal) == 12, + o => Convert.ToInt32(o.Double) == 12, + o => Convert.ToInt32(o.Float) == 12, + o => Convert.ToInt32(o.Short) == 12, + o => Convert.ToInt32(o.Int) == 12, + o => Convert.ToInt32(o.Long) == 12, + o => Convert.ToInt32(Convert.ToString(o.Int)) == 12, + o => Convert.ToInt32((object)o.Int) == 12 + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToInt64(bool async) + { + var convertMethods = new List>> + { + o => Convert.ToInt64(o.Bool) == 1, + o => Convert.ToInt64(o.Byte) == 12, + o => Convert.ToInt64(o.Decimal) == 12, + o => Convert.ToInt64(o.Double) == 12, + o => Convert.ToInt64(o.Float) == 12, + o => Convert.ToInt64(o.Short) == 12, + o => Convert.ToInt64(o.Int) == 12, + o => Convert.ToInt64(o.Long) == 12, + o => Convert.ToInt64(Convert.ToString(o.Int)) == 12, + o => Convert.ToInt64((object)o.Int) == 12 + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Convert_ToString(bool async) + { + // Actual convert-to-string behavior varies across databases for most types and cannot be asserted upon here + // (e.g. boolean converts to 1/0 on SQL Server, true/false on PG). + var convertMethods = new List>> + { + o => Convert.ToString(o.Bool) != "", + o => Convert.ToString(o.Byte) == "8", + o => Convert.ToString(o.Decimal) != "", + o => Convert.ToString(o.Double) != "", + o => Convert.ToString(o.Float) != "", + o => Convert.ToString(o.Short) == "8", + o => Convert.ToString(o.Int) == "8", + o => Convert.ToString(o.Long) == "8", + o => Convert.ToString(o.String) == "Seattle", + o => Convert.ToString((object)o.String) == "Seattle", + o => Convert.ToString(o.DateTime).Contains("1998") + }; + + foreach (var convertMethod in convertMethods) + { + await AssertQuery(async, ss => ss.Set().Where(convertMethod)); + } + } + + #endregion Convert + + #region Compare + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Int_Compare_to_simple_zero(bool async) + { + var orderId = 8; + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.Int.CompareTo(orderId) == 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != c.Int.CompareTo(orderId))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.Int.CompareTo(orderId) > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= c.Int.CompareTo(orderId))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 < c.Int.CompareTo(orderId))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.Int.CompareTo(orderId) <= 0)); + } + + [ConditionalTheory] + [InlineData(false, false)] + [InlineData(true, false)] + [InlineData(false, true)] + [InlineData(true, true)] + public virtual async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) + { + var dateTime = new DateTime(1998, 5, 4, 15, 30, 10); + + if (compareTo) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.DateTime.CompareTo(dateTime) == 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != c.DateTime.CompareTo(dateTime))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.DateTime.CompareTo(dateTime) > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= c.DateTime.CompareTo(dateTime))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 < c.DateTime.CompareTo(dateTime))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.DateTime.CompareTo(dateTime) <= 0)); + } + else + { + await AssertQuery( + async, + ss => ss.Set().Where(c => DateTime.Compare(c.DateTime, dateTime) == 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != DateTime.Compare(c.DateTime, dateTime))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => DateTime.Compare(c.DateTime, dateTime) > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= DateTime.Compare(c.DateTime, dateTime))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 < DateTime.Compare(c.DateTime, dateTime))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => DateTime.Compare(c.DateTime, dateTime) <= 0)); + } + } + + [ConditionalTheory] + [InlineData(false, false)] + [InlineData(true, false)] + [InlineData(false, true)] + [InlineData(true, true)] + public virtual async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) + { + var timeSpan = new TimeSpan(1, 2, 3); + + if (compareTo) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.TimeSpan.CompareTo(timeSpan) == 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != c.TimeSpan.CompareTo(timeSpan))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.TimeSpan.CompareTo(timeSpan) > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= c.TimeSpan.CompareTo(timeSpan))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 < c.TimeSpan.CompareTo(timeSpan))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.TimeSpan.CompareTo(timeSpan) <= 0)); + } + else + { + await AssertQuery( + async, + ss => ss.Set().Where(c => TimeSpan.Compare(c.TimeSpan, timeSpan) == 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != TimeSpan.Compare(c.TimeSpan, timeSpan))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => TimeSpan.Compare(c.TimeSpan, timeSpan) > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= TimeSpan.Compare(c.TimeSpan, timeSpan))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 < TimeSpan.Compare(c.TimeSpan, timeSpan))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => TimeSpan.Compare(c.TimeSpan, timeSpan) <= 0)); + } + } + + #endregion +} diff --git a/test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs new file mode 100644 index 00000000000..60c6cbe37e1 --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/Translations/StringTranslationsTestBase.cs @@ -0,0 +1,1157 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.RegularExpressions; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +// See additional string tests for special values in FunkyDataQueryTestBase +public abstract class StringTranslationsTestBase(TFixture fixture) : QueryTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + #region Equals + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equals(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Equals("Seattle"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equals_with_OrdinalIgnoreCase(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Equals("seattle", StringComparison.OrdinalIgnoreCase))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Equals_with_Ordinal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Equals("Seattle", StringComparison.Ordinal))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Static_Equals(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => string.Equals(b.String, "Seattle"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Static_Equals_with_OrdinalIgnoreCase(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => string.Equals(b.String, "seattle", StringComparison.OrdinalIgnoreCase))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Static_Equals_with_Ordinal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => string.Equals(b.String, "Seattle", StringComparison.Ordinal))); + + #endregion Equals + + #region Miscellaneous + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Length(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length == 7)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task ToUpper(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.ToUpper() == "SEATTLE")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task ToLower(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.ToLower() == "seattle")); + + #endregion Miscellaneous + + #region IndexOf + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IndexOf(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.IndexOf("eattl") != -1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IndexOf_with_empty_string(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.IndexOf(string.Empty) == 0), + ss => ss.Set().Where(b => b.String != null && b.String.IndexOf(string.Empty) == 0) + ); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IndexOf_with_one_parameter_arg(bool async) + { + var pattern = "eattl"; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.String.IndexOf(pattern) == 1)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IndexOf_with_constant_starting_position(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length > 2 && b.String.IndexOf("e", 2) == 6)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IndexOf_with_parameter_starting_position(bool async) + { + var start = 2; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length > 2 && b.String.IndexOf("e", start) == 6)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IndexOf_after_ToString(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(x => x.Int.ToString().IndexOf("55") == 1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IndexOf_over_ToString(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(x => "12559".IndexOf(x.Int.ToString()) == 1)); + + #endregion IndexOf + + #region Replace + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Replace(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Replace("Sea", "Rea") == "Reattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Replace_with_empty_string(bool async) + => AssertQuery( + async, + ss => ss + .Set() + .Where(c => c.String != "" && c.String.Replace(c.String, string.Empty) == "")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Replace_using_property_arguments(bool async) + => AssertQuery( + async, + ss => ss + .Set() + .Where(c => c.String != "" && c.String.Replace(c.String, c.Int.ToString()) == c.Int.ToString())); + + #endregion Replace + + #region Substring + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length >= 3 && b.String.Substring(1, 2) == "ea")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring_with_one_arg_with_zero_startIndex(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Substring(0) == "Seattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring_with_one_arg_with_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length >= 1 && b.String.Substring(1) == "eattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring_with_one_arg_with_parameter(bool async) + { + var start = 2; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length >= 2 && b.String.Substring(start) == "attle")); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring_with_two_args_with_zero_startIndex(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length >= 3 && b.String.Substring(0, 3) == "Sea")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring_with_two_args_with_zero_length(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length >= 2 && b.String.Substring(2, 0) == "")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring_with_two_args_with_parameter(bool async) + { + var start = 2; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Length >= 5 && b.String.Substring(start, 3) == "att")); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Substring_with_two_args_with_IndexOf(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => + c.String.Contains("a") && c.String.Substring(c.String.IndexOf("a"), 3) == "att")); + + #endregion Substring + + #region IsNullOrEmpty/Whitespace + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task IsNullOrEmpty(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(n => string.IsNullOrEmpty(n.String))); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(n => string.IsNullOrEmpty(n.String))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task IsNullOrEmpty_negated(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(n => !string.IsNullOrEmpty(n.String))); + + await AssertQuery( + async, + ss => ss.Set().Select(n => !string.IsNullOrEmpty(n.String))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IsNullOrWhiteSpace(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => string.IsNullOrWhiteSpace(c.String))); + + #endregion IsNullOrEmpty/Whitespace + + #region StartsWith + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task StartsWith_Literal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith("Se"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task StartsWith_Parameter(bool async) + { + var pattern = "Se"; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith(pattern))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task StartsWith_Column(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith(b.String))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task StartsWith_with_StringComparison_Ordinal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith("Se", StringComparison.Ordinal))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith("Se", StringComparison.OrdinalIgnoreCase))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task StartsWith_with_StringComparison_unsupported(bool async) + { + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith("Se", StringComparison.CurrentCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith("Se", StringComparison.CurrentCultureIgnoreCase)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith("Se", StringComparison.InvariantCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.StartsWith("Se", StringComparison.InvariantCultureIgnoreCase)))); + } + + #endregion StartsWith + + #region EndsWith + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task EndsWith_Literal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith("le"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task EndsWith_Parameter(bool async) + { + var pattern = "le"; + + return AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith(pattern))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task EndsWith_Column(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith(b.String))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task EndsWith_with_StringComparison_Ordinal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith("le", StringComparison.Ordinal))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith("LE", StringComparison.OrdinalIgnoreCase))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task EndsWith_with_StringComparison_unsupported(bool async) + { + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith("le", StringComparison.CurrentCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith("le", StringComparison.CurrentCultureIgnoreCase)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith("le", StringComparison.InvariantCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(b => b.String.EndsWith("le", StringComparison.InvariantCultureIgnoreCase)))); + } + + #endregion EndsWith + + #region Contains + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Contains_Literal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Contains("eattl"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Contains_Column(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(b => b.String.Contains(b.String))); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.String.Contains(b.String))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Contains_negated(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => !c.String.Contains("eattle"))); + + await AssertQueryScalar( + async, + ss => ss.Set().Select(c => !c.String.Contains("eattle"))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Contains_with_StringComparison_Ordinal(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains("eattl", StringComparison.Ordinal))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Contains_with_StringComparison_OrdinalIgnoreCase(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains("EATTL", StringComparison.OrdinalIgnoreCase))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Contains_with_StringComparison_unsupported(bool async) + { + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains("eattl", StringComparison.CurrentCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains("eattl", StringComparison.CurrentCultureIgnoreCase)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains("eattl", StringComparison.InvariantCulture)))); + + await AssertTranslationFailed( + () => + AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains("eattl", StringComparison.InvariantCultureIgnoreCase)))); + } + + [ConditionalTheory] // Probably belongs in FunkyDataQueryTestBase + [MemberData(nameof(IsAsyncData))] + public virtual Task Contains_constant_with_whitespace(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains(" ")), + assertEmpty: true); + + [ConditionalTheory] // Probably belongs in FunkyDataQueryTestBase + [MemberData(nameof(IsAsyncData))] + public virtual Task Contains_parameter_with_whitespace(bool async) + { + var pattern = " "; + return AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains(pattern)), + assertEmpty: true); + } + + #endregion Contains + + #region TrimStart + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TrimStart_without_arguments(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.TrimStart() == "Boston ")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TrimStart_with_char_argument(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.TrimStart('S') == "eattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TrimStart_with_char_array_argument(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.TrimStart(new [] { 'S', 'e' }) == "attle")); + + #endregion TrimStart + + #region TrimEnd + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TrimEnd_without_arguments(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.TrimEnd() == " Boston")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TrimEnd_with_char_argument(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.TrimEnd('e') == "Seattl")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TrimEnd_with_char_array_argument(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.TrimEnd(new [] { 'l', 'e' }) == "Seatt")); + + #endregion TrimEnd + + #region Trim + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Trim_without_argument_in_predicate(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Trim() == "Boston")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Trim_with_char_argument_in_predicate(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Trim('S') == "eattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Trim_with_char_array_argument_in_predicate(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Trim(new [] { 'S', 'e' }) == "attl")); + + #endregion Trim + + #region Compare + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Compare_simple_zero(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") == 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != string.Compare(c.String, "Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= string.Compare(c.String, "Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 < string.Compare(c.String, "Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") <= 0)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Compare_simple_one(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") == 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 == string.Compare(c.String, "Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") < 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 1 > string.Compare(c.String, "Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") > -1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 < string.Compare(c.String, "Seattle"))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Compare_with_parameter(bool async) + { + BasicTypesEntity? basicTypeEntity; + await using (var context = CreateContext()) + { + basicTypeEntity = await context.BasicTypesEntities.SingleAsync(c => c.String == "Seattle"); + } + + ClearLog(); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, basicTypeEntity.String) == 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 == string.Compare(c.String, basicTypeEntity.String))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, basicTypeEntity.String) < 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 1 > string.Compare(c.String, basicTypeEntity.String))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, basicTypeEntity.String) > -1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 < string.Compare(c.String, basicTypeEntity.String))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Compare_simple_more_than_one(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") == 42), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle") > 42), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 42 > string.Compare(c.String, "Seattle"))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Compare_nested(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "M" + c.String) == 0), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != string.Compare(c.String, c.String.Substring(0, 0)))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle".Replace("Sea", c.String)) > 0), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= string.Compare(c.String, "M" + c.String))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 1 == string.Compare(c.String, c.String.Substring(0, 0)))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => string.Compare(c.String, "Seattle".Replace("Sea", c.String)) == -1)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Compare_multi_predicate(bool async) + => await AssertQuery( + async, + ss => ss.Set() + .Where(c => string.Compare(c.String, "Seattle") > -1) + .Where(c => string.Compare(c.String, "Toronto") == -1)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task CompareTo_simple_zero(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") == 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != c.String.CompareTo("Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") > 0)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= c.String.CompareTo("Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 < c.String.CompareTo("Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") <= 0)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task CompareTo_simple_one(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") == 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 == c.String.CompareTo("Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") < 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 1 > c.String.CompareTo("Seattle"))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") > -1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 < c.String.CompareTo("Seattle"))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task CompareTo_with_parameter(bool async) + { + BasicTypesEntity? basicTypesEntity; + using (var context = CreateContext()) + { + basicTypesEntity = await context.BasicTypesEntities.SingleAsync(x => x.String == "Seattle"); + } + + ClearLog(); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo(basicTypesEntity.String) == 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 == c.String.CompareTo(basicTypesEntity.String))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo(basicTypesEntity.String) < 1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 1 > c.String.CompareTo(basicTypesEntity.String))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo(basicTypesEntity.String) > -1)); + + await AssertQuery( + async, + ss => ss.Set().Where(c => -1 < c.String.CompareTo(basicTypesEntity.String))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task CompareTo_simple_more_than_one(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") == 42), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle") > 42), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 42 > c.String.CompareTo("Seattle"))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task CompareTo_nested(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("M" + c.String) == 0), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 != c.String.CompareTo(c.String.Substring(0, 0)))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle".Replace("Sea", c.String)) > 0), + assertEmpty: true); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 0 >= c.String.CompareTo("M" + c.String))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => 1 == c.String.CompareTo(c.String.Substring(0, 0)))); + + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.CompareTo("Seattle".Replace("Sea", c.String)) == -1)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Compare_to_multi_predicate(bool async) + => await AssertQuery( + async, + ss => ss.Set() + .Where(c => c.String.CompareTo("Seattle") > -1) + .Where(c => c.String.CompareTo("Toronto") == -1)); + + #endregion Compare + + #region Join + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Join_over_non_nullable_column(bool async) + => AssertQuery( + async, + ss => ss.Set() + .GroupBy(c => c.Int) + .Select(g => new { g.Key, Strings = string.Join("|", g.Select(e => e.String)) }), + elementSorter: x => x.Key, + elementAsserter: (e, a) => + { + Assert.Equal(e.Key, a.Key); + + // Ordering inside the string isn't specified server-side, split and reorder + Assert.Equal( + e.Strings.Split("|").OrderBy(id => id).ToArray(), + a.Strings.Split("|").OrderBy(id => id).ToArray()); + }); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Join_over_nullable_column(bool async) + => AssertQuery( + async, + ss => ss.Set() + .GroupBy(c => c.Int ?? 0) + .Select(g => new { g.Key, Regions = string.Join("|", g.Select(e => e.String)) }), + elementSorter: x => x.Key, + elementAsserter: (e, a) => + { + Assert.Equal(e.Key, a.Key); + + // Ordering inside the string isn't specified server-side, split and reorder + Assert.Equal( + e.Regions.Split("|").OrderBy(id => id).ToArray(), + a.Regions.Split("|").OrderBy(id => id).ToArray()); + }); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Join_with_predicate(bool async) + => AssertQuery( + async, + ss => ss.Set() + .GroupBy(c => c.Int) + .Select( + g => new + { + g.Key, + Strings = string.Join("|", g.Where(e => e.String.Length > 6).Select(e => e.String)) + }), + elementSorter: x => x.Key, + elementAsserter: (e, a) => + { + Assert.Equal(e.Key, a.Key); + + // Ordering inside the string isn't specified server-side, split and reorder + Assert.Equal( + e.Strings.Split("|").OrderBy(id => id).ToArray(), + a.Strings.Split("|").OrderBy(id => id).ToArray()); + }); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Join_with_ordering(bool async) + => AssertQuery( + async, + ss => ss.Set() + .GroupBy(c => c.Int) + .Select( + g => new + { + g.Key, Strings = string.Join("|", g.OrderByDescending(e => e.Id).Select(e => e.String)) + }), + elementSorter: x => x.Key); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Join_non_aggregate(bool async) + { + var foo = "foo"; + + return AssertQuery( + async, + ss => ss.Set().Where(c => string.Join("|", new[] { c.String, foo, null, "bar" }) == "Seattle|foo||bar")); + } + + #endregion Join + + #region Concatenation + + // TODO: Possibly move to aggregate-specific test suite, not sure. Also Join above. + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_aggregate(bool async) + => AssertQuery( + async, + ss => ss.Set() + .GroupBy(c => c.Int) + .Select(g => new { g.Key, BasicTypesEntitys = string.Concat(g.Select(e => e.String)) }), + elementSorter: x => x.Key, + elementAsserter: (e, a) => + { + Assert.Equal(e.Key, a.Key); + + // The best we can do for Concat without server-side ordering is sort the characters (concatenating without ordering + // and without a delimiter is somewhat dubious anyway). + Assert.Equal(e.BasicTypesEntitys.OrderBy(c => c).ToArray(), a.BasicTypesEntitys.OrderBy(c => c).ToArray()); + }); + + [ConditionalTheory] // #31917 + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_string_int_comparison1(bool async) + { + var i = 10; + + return AssertQuery( + async, + ss => ss.Set().Where(c => c.String + i == "Seattle10")); + } + + [ConditionalTheory] // #31917 + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_string_int_comparison2(bool async) + { + var i = 10; + + return AssertQuery( + async, + ss => ss.Set().Where(c => i + c.String == "10Seattle")); + } + + [ConditionalTheory] // #31917 + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_string_int_comparison3(bool async) + { + var i = 10; + var j = 21; + + return AssertQuery( + async, + ss => ss.Set().Where(c => i + 20 + c.String + j + 42 == "30Seattle2142")); + } + + [ConditionalTheory] // #31917 + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_string_int_comparison4(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.Int + o.String == "8Seattle")); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_string_string_comparison(bool async) + { + var i = "A"; + + return AssertQuery( + async, + ss => ss.Set().Where(c => i + c.String == "ASeattle")); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_method_comparison(bool async) + { + var i = "A"; + + return AssertQuery( + async, + ss => ss.Set().Where(c => string.Concat(i, c.String) == "ASeattle")); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_method_comparison_2(bool async) + { + var i = "A"; + var j = "B"; + + return AssertQuery( + async, + ss => ss.Set().Where(c => string.Concat(i, j, c.String) == "ABSeattle")); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Concat_method_comparison_3(bool async) + { + var i = "A"; + var j = "B"; + var k = "C"; + + return AssertQuery( + async, + ss => ss.Set().Where(c => string.Concat(i, j, k, c.String) == "ABCSeattle")); + } + + #endregion Concatenation + + #region LINQ Operators + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task FirstOrDefault(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.FirstOrDefault() == 'S')); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task LastOrDefault(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(c => c.String.LastOrDefault() == 'e')); + + #endregion LINQ Operators + + #region Regex + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Regex_IsMatch(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => Regex.IsMatch(o.String, "^S"))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Regex_IsMatch_constant_input(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => Regex.IsMatch("Seattle", o.String))); + + #endregion Regex + + protected BasicTypesContext CreateContext() + => Fixture.CreateContext(); + + protected virtual void ClearLog() + { + } +} diff --git a/test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs b/test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs new file mode 100644 index 00000000000..6fb849a460b --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/Translations/TemporalTranslationsTestBase.cs @@ -0,0 +1,595 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public abstract class TemporalTranslationsTestBase(TFixture fixture) : QueryTestBase(fixture) + where TFixture : BasicTypesQueryFixtureBase, new() +{ + #region DateTime + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Now(bool async) + { + var myDatetime = new DateTime(2015, 4, 10); + + return AssertQuery( + async, + ss => ss.Set().Where(c => DateTime.Now != myDatetime)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_UtcNow(bool async) + { + var myDatetime = new DateTime(2015, 4, 10); + + return AssertQuery( + async, + ss => ss.Set().Where(c => DateTime.UtcNow != myDatetime)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Today(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.DateTime == DateTime.Today), + assertEmpty: true); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Date(bool async) + { + var myDatetime = new DateTime(1998, 5, 4); + + return AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Date == myDatetime)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_AddYear(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.AddYears(1).Year == 1999)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Year(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Year == 1998)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Month(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Month == 5)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_DayOfYear(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.DayOfYear == 124)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Day(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Day == 4)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Hour(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Hour == 15)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Minute(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Minute == 30)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Second(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Second == 10)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_Millisecond(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.Millisecond == 123)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_TimeOfDay(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => o.DateTime.TimeOfDay == TimeSpan.Zero)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTime_subtract_and_TotalDays(bool async) + { + var date = new DateTime(1997, 1, 1); + + return AssertQuery( + async, + ss => ss.Set().Where(o => (o.DateTime - date).TotalDays > 365)); + } + + #endregion DateTime + + #region DateOnly + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_Year(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.Year == 1990)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_Month(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.Month == 11)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_Day(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.Day == 10)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_DayOfYear(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.DayOfYear == 314)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_DayOfWeek(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.DayOfWeek == DayOfWeek.Saturday)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_AddYears(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.AddYears(3) == new DateOnly(1993, 11, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_AddMonths(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.AddMonths(3) == new DateOnly(1991, 2, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_AddDays(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateOnly.AddDays(3) == new DateOnly(1990, 11, 13))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_FromDateTime(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => DateOnly.FromDateTime(o.DateTime) == new DateOnly(1998, 5, 4))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_FromDateTime_compared_to_property(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(o => DateOnly.FromDateTime(o.DateTime) == o.DateOnly)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + { + var dateOnly = new DateOnly(2, 10, 11); + + return AssertQuery( + async, + ss => ss.Set() + .Where(x => new[] { dateOnly, new DateOnly(1998, 5, 4) }.Contains(DateOnly.FromDateTime(x.DateTime)))); + } + + #endregion DateOnly + + #region TimeOnly + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_Hour(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.Hour == 15)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_Minute(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.Minute == 30)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_Second(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.Second == 10)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_Millisecond(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.Millisecond == 123)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_Microsecond(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.TimeOnly.Microsecond == 456)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_Nanosecond(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.TimeOnly.Nanosecond == 400)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_AddHours(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.AddHours(3) == new TimeOnly(18, 30, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_AddMinutes(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.AddMinutes(3) == new TimeOnly(15, 33, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_Add_TimeSpan(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.Add(new TimeSpan(3, 0, 0)) == new TimeOnly(18, 30, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_IsBetween(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly.IsBetween(new TimeOnly(14, 0, 0), new TimeOnly(16, 0, 0)))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_subtract_TimeOnly(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeOnly - new TimeOnly(3, 0, 0) == new TimeSpan(12, 30, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_FromDateTime_compared_to_property(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => TimeOnly.FromDateTime(b.DateTime) == b.TimeOnly)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_FromDateTime_compared_to_parameter(bool async) + { + var time = new TimeOnly(15, 30, 10); + + return AssertQuery( + async, + ss => ss.Set().Where(b => TimeOnly.FromDateTime(b.DateTime) == time)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_FromDateTime_compared_to_constant(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => TimeOnly.FromDateTime(b.DateTime) == new TimeOnly(15, 30, 10))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_FromTimeSpan_compared_to_property(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => TimeOnly.FromTimeSpan(b.TimeSpan) < b.TimeOnly)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + { + var time = new TimeOnly(1, 2, 3); + + return AssertQuery( + async, + ss => ss.Set().Where(x => TimeOnly.FromTimeSpan(x.TimeSpan) == time)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Order_by_TimeOnly_FromTimeSpan(bool async) + => AssertQuery( + async, + ss => ss.Set().OrderBy(x => TimeOnly.FromTimeSpan(x.TimeSpan)), + assertOrder: true); + + #endregion TimeOnly + + #region DateTimeOffset + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Now(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset != DateTimeOffset.Now)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_UtcNow(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset != DateTimeOffset.UtcNow)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Date(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Date > new DateTimeOffset().Date)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Year(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Year == 1998)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Month(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Month == 5)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_DayOfYear(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.DayOfYear == 124)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Day(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Day == 4)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Hour(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Hour == 15)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Minute(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Minute == 30)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Second(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Second == 10)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Millisecond(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.DateTimeOffset.Millisecond == 123)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Microsecond(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.DateTimeOffset.Microsecond == 456)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_Nanosecond(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(e => e.DateTimeOffset.Nanosecond == 400)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_TimeOfDay(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.TimeOfDay)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_AddYears(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.AddYears(1))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_AddMonths(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.AddMonths(1))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_AddDays(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.AddDays(1))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_AddHours(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.AddHours(1))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_AddMinutes(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.AddMinutes(1))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_AddSeconds(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.AddSeconds(1))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_AddMilliseconds(bool async) + => AssertQueryScalar( + async, + ss => ss.Set().Select(b => b.DateTimeOffset.AddMilliseconds(300))); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_ToUnixTimeMilliseconds(bool async) + { + var unixEpochMilliseconds = new DateTimeOffset(1998, 5, 4, 15, 30, 10, TimeSpan.Zero).ToUnixTimeMilliseconds(); + + return AssertQuery( + async, + ss => ss.Set() + .Where(b => b.DateTimeOffset.ToUnixTimeMilliseconds() == unixEpochMilliseconds)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_ToUnixTimeSecond(bool async) + { + var unixEpochSeconds = new DateTimeOffset(1998, 5, 4, 15, 30, 10, TimeSpan.Zero).ToUnixTimeSeconds(); + + return AssertQuery( + async, + ss => ss.Set() + .Where(b => b.DateTimeOffset.ToUnixTimeSeconds() == unixEpochSeconds)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task DateTimeOffset_milliseconds_parameter_and_constant(bool async) + { + var dateTimeOffset = new DateTimeOffset(599898024001234567, new TimeSpan(1, 30, 0)); + + // Literal where clause + var p = Expression.Parameter(typeof(BasicTypesEntity), "i"); + var dynamicWhere = Expression.Lambda>( + Expression.Equal( + Expression.Property(p, "DateTimeOffset"), + Expression.Constant(dateTimeOffset) + ), p); + + return AssertCount( + async, + ss => ss.Set().Where(dynamicWhere), + ss => ss.Set().Where(m => m.DateTimeOffset == dateTimeOffset)); + } + + #endregion DateTimeOffset + + #region TimeSpan + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeSpan_Hours(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeSpan.Hours == 3)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeSpan_Minutes(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeSpan.Minutes == 4)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeSpan_Seconds(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeSpan.Seconds == 5)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeSpan_Milliseconds(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeSpan.Milliseconds == 678)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeSpan_Microseconds(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeSpan.Microseconds == 912)); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task TimeSpan_Nanoseconds(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(b => b.TimeSpan.Nanoseconds == 400)); + + #endregion TimeSpan +} diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicEnum.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicEnum.cs new file mode 100644 index 00000000000..9b530e3c478 --- /dev/null +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicEnum.cs @@ -0,0 +1,11 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +public enum BasicEnum +{ + One, + Two, + Three +} diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs new file mode 100644 index 00000000000..304a627bffe --- /dev/null +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs @@ -0,0 +1,16 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +[Flags] +public enum BasicFlagsEnum +{ + Zero = 0, + One = 1, + Two = 2, + Four = 4, + Eight = 8, + Sixteen = 16, + ThirtyTwo = 32, +} diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesContext.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesContext.cs new file mode 100644 index 00000000000..d6778986a5d --- /dev/null +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesContext.cs @@ -0,0 +1,24 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +public class BasicTypesContext(DbContextOptions options) : PoolableDbContext(options) +{ + public DbSet BasicTypesEntities { get; set; } = null!; + public DbSet NullableBasicTypesEntities { get; set; } = null!; + + protected override void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().Property(b => b.Id).ValueGeneratedNever(); + modelBuilder.Entity().Property(b => b.Id).ValueGeneratedNever(); + } + + public static Task SeedAsync(BasicTypesContext context, bool useGeneratedKeys) + { + context.BasicTypesEntities.AddRange(BasicTypesData.CreateBasicTypesEntities()); + context.NullableBasicTypesEntities.AddRange(BasicTypesData.CreateNullableBasicTypesEntities()); + + return context.SaveChangesAsync(); + } +} diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs new file mode 100644 index 00000000000..87b16dd7f8c --- /dev/null +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesData.cs @@ -0,0 +1,265 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +public class BasicTypesData : ISetSource +{ + public IReadOnlyList BasicTypesEntities { get; } = CreateBasicTypesEntities(); + public IReadOnlyList NullableBasicTypesEntities { get; } = CreateNullableBasicTypesEntities(); + + public IQueryable Set() + where TEntity : class + { + if (typeof(TEntity) == typeof(BasicTypesEntity)) + { + return (IQueryable)BasicTypesEntities.AsQueryable(); + } + + if (typeof(TEntity) == typeof(NullableBasicTypesEntity)) + { + return (IQueryable)NullableBasicTypesEntities.AsQueryable(); + } + + throw new InvalidOperationException("Invalid entity type: " + typeof(TEntity)); + } + + public static IReadOnlyList CreateBasicTypesEntities() + => + [ + // TODO: min, max, some more "regular values" + // TODO: go over, clean this up and make sure it makes sense + new() + { + Id = 0, + + Byte = 0, + Short = 0, + Int = 0, + Long = 0, + Float = 0, + Double = 0, + Decimal = 0, + + String = string.Empty, + + DateTime = new DateTime(2000, 1, 1, 0, 0, 0), + DateOnly = new DateOnly(2000, 1, 1), + TimeOnly = new TimeOnly(0, 0, 0), + DateTimeOffset = new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero), + // TODO: Need to test non-zero days (not supported on SQL Server so need to tweak seeding data, which is currently hard) + TimeSpan = TimeSpan.Zero, + + Bool = false, + Guid = Guid.Empty, + ByteArray = [], + + Enum = 0, + FlagsEnum = BasicFlagsEnum.Zero, + }, + new() + { + Id = 1, + + Byte = 8, + Short = 8, + Int = 8, + Long = 8, + Float = 8.6f, + Double = 8.6, + Decimal = 8.6m, + + String = "Seattle", + + DateTime = new DateTime(1998, 5, 4, 15, 30, 10), + DateOnly = new DateOnly(2020, 1, 1), + TimeOnly = new TimeOnly(15, 30, 10), + // Note: we use a zero offset for the default seeded entity since a few providers don't support non-zero offsets; this + // allows them to remove the non-zero-offset data from the seeding dataset, while leaving most tests - which don't care + // about the offset - working. + DateTimeOffset = new DateTimeOffset(1998, 5, 4, 15, 30, 10, TimeSpan.Zero), + TimeSpan = new TimeSpan(1, 2, 3), + + Bool = true, + Guid = new Guid("DF36F493-463F-4123-83F9-6B135DEEB7BA"), + ByteArray = [0xDE, 0xAD, 0xBE, 0xEF], + + Enum = BasicEnum.One, + FlagsEnum = BasicFlagsEnum.Eight, + }, + new() + { + Id = 2, + + Byte = 8, + Short = 8, + Int = 8, + Long = 8, + Float = 8.6f, + Double = 8.6, + Decimal = 8.6m, + + String = "London", + + DateTime = new DateTime(1998, 5, 4, 15, 30, 10, 123, 456).AddTicks(400), + DateOnly = new DateOnly(1990, 11, 10), + TimeOnly = new TimeOnly(15, 30, 10, 123, 456), + DateTimeOffset = new DateTimeOffset(1998, 5, 4, 15, 30, 10, 123, 456, TimeSpan.Zero) + .Add(TimeSpan.FromTicks(4)), /* 400 nanoseconds */ + TimeSpan = new TimeSpan(0, 3, 4, 5, 678, 912).Add(TimeSpan.FromTicks(4)), /* 400 nanoseconds */ + + Bool = false, + Guid = new Guid("B39A6FBA-9026-4D69-828E-FD7068673E57"), + ByteArray = [1, 2, 3, 4, 5, 6, 7, 8, 9], + + Enum = BasicEnum.Two, + FlagsEnum = BasicFlagsEnum.Eight | BasicFlagsEnum.One, + }, + new() + { + Id = 3, + + Byte = 255, + Short = 255, + Int = 255, + Long = 255, + Float = 255.12f, + Double = 255.12, + Decimal = 255.12m, + + String = "Toronto", + + DateTime = new DateTime(1, 1, 1, 0, 0, 0), + DateOnly = new DateOnly(1, 1, 1), + TimeOnly = new TimeOnly(0, 0, 0), + DateTimeOffset = new DateTimeOffset(1998, 5, 4, 15, 30, 10, 123, 456, new TimeSpan(1, 30, 0)) + .Add(TimeSpan.FromTicks(4)), /* 400 nanoseconds */ + TimeSpan = new TimeSpan(0, 1, 0, 15, 456), + + // Bool = false, + // Guid = new Guid("088ca6e6-c756-42f8-a298-8c28e63fdba6"), + ByteArray = [], + + Enum = BasicEnum.Three, + FlagsEnum = BasicFlagsEnum.Sixteen | BasicFlagsEnum.Four | BasicFlagsEnum.One, + }, + new() + { + Id = 4, + + Byte = 9, + Short = -9, + Int = -9, + Long = -9, + Float = -9.5f, + Double = -9.5, + Decimal = -9.5m, + + // String = " Boston ", + String = " Boston ", + + DateTime = new DateTime(1, 1, 1, 0, 0, 0, 10, 200).AddTicks(4), /* 400 nanoseconds */ + DateOnly = new DateOnly(1, 1, 1), + TimeOnly = new TimeOnly(0, 0, 0, 10, 200).Add(TimeSpan.FromTicks(4)), /* 400 nanoseconds */ + DateTimeOffset = new DateTimeOffset(11, 5, 3, 12, 0, 0, 0, 200, new TimeSpan()).Add(TimeSpan.FromTicks(4)), /* 400 nanoseconds */ + TimeSpan = new TimeSpan(0, 2, 0, 15, 456, 200).Add(TimeSpan.FromTicks(4)), /* 400 nanoseconds */ + + Bool = true, + // Guid = new Guid("088ca6e6-c756-42f8-a298-8c28e63fdba6"), + ByteArray = [], + + // Enum = BasicEnum.One, + // FlagsEnum = BasicFlagsEnum.Eight, + }, + new() + { + Id = 5, + + Byte = 12, + Short = 12, + Int = 12, + Long = 12, + Float = 12, + Double = 12, + Decimal = 12, + + String = "", + + // DateTime = DateTime.MinValue, + // DateOnly = DateOnly.MinValue, + // TimeOnly = TimeOnly.MinValue, + // DateTimeOffset = DateTimeOffset.MinValue, + // TimeSpan = TimeSpan.MinValue, + + Bool = false, + // Guid = new Guid("088ca6e6-c756-42f8-a298-8c28e63fdba6"), + ByteArray = [], + + // Enum = BasicEnum.One, + } + ]; + + public static IReadOnlyList CreateNullableBasicTypesEntities() + { + // Convert the non-nullable data to nullable (so we have parity between the non-nullable and nullable seeding sets), and add another + // entity instance with all-nulls. + return CreateBasicTypesEntities() + .Select(ConvertToNullable) + .Append(new() + { + Id = -1, + + Byte = null, + Short = null, + Int = null, + Long = null, + Float = null, + Double = null, + Decimal = null, + + String = null, + + DateTime = null, + DateOnly = null, + TimeOnly = null, + DateTimeOffset = null, + + Bool = null, + Guid = null, + ByteArray = null, + + Enum = null, + FlagsEnum = null + }) + .ToArray(); + + NullableBasicTypesEntity ConvertToNullable(BasicTypesEntity b) + => new() + { + Id = b.Id, + + Byte = b.Byte, + Short = b.Short, + Int = b.Int, + Long = b.Long, + Float = b.Float, + Double = b.Double, + Decimal = b.Decimal, + + String = b.String, + + DateTime = b.DateTime, + DateOnly = b.DateOnly, + TimeOnly = b.TimeOnly, + DateTimeOffset = b.DateTimeOffset, + TimeSpan = b.TimeSpan, + + Bool = b.Bool, + Guid = b.Guid, + ByteArray = b.ByteArray, + + Enum = b.Enum, + FlagsEnum = b.FlagsEnum, + }; + } +} diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesEntity.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesEntity.cs new file mode 100644 index 00000000000..06a0db5979d --- /dev/null +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicTypesEntity.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +public class BasicTypesEntity +{ + public required int Id { get; set; } + + public byte Byte { get; set; } + public short Short { get; set; } + public int Int { get; set; } + public long Long { get; set; } + public float Float { get; set; } + public double Double { get; set; } + public decimal Decimal { get; set; } + + public required string String { get; set; } + + public DateTime DateTime { get; set; } + public DateOnly DateOnly { get; set; } + public TimeOnly TimeOnly { get; set; } + public DateTimeOffset DateTimeOffset { get; set; } + public TimeSpan TimeSpan { get; set; } + + public bool Bool { get; set; } + public Guid Guid { get; set; } + public required byte[] ByteArray { get; set; } + + public BasicEnum Enum { get; set; } + public BasicFlagsEnum FlagsEnum { get; set; } +} diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/NullableBasicTypesEntity.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/NullableBasicTypesEntity.cs new file mode 100644 index 00000000000..31d2ee81570 --- /dev/null +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/NullableBasicTypesEntity.cs @@ -0,0 +1,32 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +public class NullableBasicTypesEntity +{ + public required int Id { get; set; } + + public byte? Byte { get; set; } + public short? Short { get; set; } + public int? Int { get; set; } + public long? Long { get; set; } + public float? Float { get; set; } + public double? Double { get; set; } + public decimal? Decimal { get; set; } + + public string? String { get; set; } + + public DateTime? DateTime { get; set; } + public DateOnly? DateOnly { get; set; } + public TimeOnly? TimeOnly { get; set; } + public DateTimeOffset? DateTimeOffset { get; set; } + public TimeSpan? TimeSpan { get; set; } + + public bool? Bool { get; set; } + public Guid? Guid { get; set; } + public byte[]? ByteArray { get; set; } + + public BasicEnum? Enum { get; set; } + public BasicFlagsEnum? FlagsEnum { get; set; } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs index 223a350b08e..d12c45997f3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs @@ -365,8993 +365,7963 @@ WHERE [g].[Nickname] <> N'Paduk' OR [g].[Nickname] IS NULL """); } - public override async Task Where_enum(bool async) + public override async Task Where_count_subquery_without_collision(bool async) { - await base.Where_enum(async); + await base.Where_count_subquery_without_collision(async); AssertSql( """ 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 [g].[Rank] = 4 +WHERE ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) = 2 """); } - public override async Task Where_nullable_enum_with_constant(bool async) + public override async Task Where_any_subquery_without_collision(bool async) { - await base.Where_nullable_enum_with_constant(async); + await base.Where_any_subquery_without_collision(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = 1 +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 EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) """); } - public override async Task Where_nullable_enum_with_null_constant(bool async) + public override async Task Select_inverted_boolean(bool async) { - await base.Where_nullable_enum_with_null_constant(async); + await base.Select_inverted_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], ~[w].[IsAutomatic] AS [Manual] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL +WHERE [w].[IsAutomatic] = CAST(1 AS bit) """); } - public override async Task Where_nullable_enum_with_non_nullable_parameter(bool async) + public override async Task Select_inverted_nullable_boolean(bool async) { - await base.Where_nullable_enum_with_non_nullable_parameter(async); + await base.Select_inverted_nullable_boolean(async); AssertSql( """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType +SELECT [f].[Id], ~[f].[Eradicated] AS [Alive] +FROM [Factions] AS [f] """); } - public override async Task Where_nullable_enum_with_nullable_parameter(bool async) + public override async Task Select_comparison_with_null(bool async) { - await base.Where_nullable_enum_with_nullable_parameter(async); + await base.Select_comparison_with_null(async); AssertSql( """ @ammunitionType='1' (Nullable = true) -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] = @ammunitionType AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] = @ammunitionType """, // """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL """); } - public override async Task Where_bitwise_and_enum(bool async) + public override async Task Select_null_parameter(bool async) { - await base.Where_bitwise_and_enum(async); + await base.Select_null_parameter(async); AssertSql( """ -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 [g].[Rank] & 2 > 0 +@ammunitionType='1' (Nullable = true) + +SELECT [w].[Id], @ammunitionType AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -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 [g].[Rank] & 2 = 2 -"""); - } - - public override async Task Where_bitwise_and_integral(bool async) - { - await base.Where_bitwise_and_integral(async); - - AssertSql( - """ -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 [g].[Rank] & 1 = 1 +SELECT [w].[Id], NULL AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -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 CAST([g].[Rank] AS bigint) & CAST(1 AS bigint) = CAST(1 AS bigint) +@ammunitionType='2' (Nullable = true) + +SELECT [w].[Id], @ammunitionType AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -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 CAST([g].[Rank] AS smallint) & CAST(1 AS smallint) = CAST(1 AS smallint) +SELECT [w].[Id], NULL AS [AmmoType] +FROM [Weapons] AS [w] """); } - public override async Task Where_bitwise_and_nullable_enum_with_constant(bool async) + public override async Task Select_ternary_operation_with_boolean(bool async) { - await base.Where_bitwise_and_nullable_enum_with_constant(async); + await base.Select_ternary_operation_with_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 + ELSE 0 +END AS [Num] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & 1 > 0 """); } - public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) + public override async Task Select_ternary_operation_with_inverted_boolean(bool async) { - await base.Where_bitwise_and_nullable_enum_with_null_constant(async); + await base.Select_ternary_operation_with_inverted_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN 1 + ELSE 0 +END AS [Num] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 """); } - public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) + public override async Task Select_ternary_operation_with_has_value_not_null(bool async) { - await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); + await base.Select_ternary_operation_with_has_value_not_null(async); AssertSql( """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 +WHERE [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 """); } - public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) + public override async Task Select_ternary_operation_multiple_conditions(bool async) { - await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); + await base.Select_ternary_operation_multiple_conditions(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] = 2 AND [w].[SynergyWithId] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 -""", - // +"""); + } + + public override async Task Select_ternary_operation_multiple_conditions_2(bool async) + { + await base.Select_ternary_operation_multiple_conditions_2(async); + + AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 """); } - public override async Task Where_bitwise_or_enum(bool async) + public override async Task Select_multiple_conditions(bool async) { - await base.Where_bitwise_or_enum(async); + await base.Select_multiple_conditions(async); AssertSql( """ -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 [g].[Rank] | 2 > 0 +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [IsCartridge] +FROM [Weapons] AS [w] """); } - public override async Task Bitwise_projects_values_in_select(bool async) + public override async Task Select_nested_ternary_operations(bool async) { - await base.Bitwise_projects_values_in_select(async); + await base.Select_nested_ternary_operations(async); AssertSql( """ -SELECT TOP(1) ~CAST(([g].[Rank] & 2) ^ 2 AS bit) AS [BitwiseTrue], ~CAST(([g].[Rank] & 2) ^ 4 AS bit) AS [BitwiseFalse], [g].[Rank] & 2 AS [BitwiseValue] -FROM [Gears] AS [g] -WHERE [g].[Rank] & 2 = 2 +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CASE + WHEN [w].[AmmunitionType] = 1 THEN N'ManualCartridge' + ELSE N'Manual' + END + ELSE N'Auto' +END AS [IsManualCartridge] +FROM [Weapons] AS [w] """); } - public override async Task Where_enum_has_flag(bool async) + public override async Task Null_propagation_optimization1(bool async) { - await base.Where_enum_has_flag(async); + await base.Null_propagation_optimization1(async); AssertSql( """ 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 [g].[Rank] & 2 = 2 -""", - // - """ -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 [g].[Rank] & 18 = 18 -""", - // - """ -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 [g].[Rank] & 1 = 1 -""", - // - """ -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 [g].[Rank] & 1 = 1 -""", - // - """ -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 2 & [g].[Rank] = [g].[Rank] +WHERE [g].[LeaderNickname] = N'Marcus' """); } - public override async Task Where_enum_has_flag_subquery(bool async) + public override async Task Null_propagation_optimization2(bool async) { - await base.Where_enum_has_flag_subquery(async); + await base.Null_propagation_optimization2(async); + // issue #16050 AssertSql( """ 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 [g].[Rank] & COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) -""", - // - """ -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 2 & COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) +WHERE CASE + WHEN [g].[LeaderNickname] IS NULL THEN NULL + WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async) + public override async Task Null_propagation_optimization3(bool async) { - await base.Where_enum_has_flag_subquery_with_pushdown(async); + await base.Null_propagation_optimization3(async); + // issue #16050 AssertSql( """ 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 [g].[Rank] & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL -""", - // - """ -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 2 & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL +WHERE CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE + WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END +END = CAST(1 AS bit) """); } - public override async Task Where_enum_has_flag_subquery_client_eval(bool async) + public override async Task Null_propagation_optimization4(bool async) { - await base.Where_enum_has_flag_subquery_client_eval(async); + await base.Null_propagation_optimization4(async); + // issue #16050 AssertSql( """ 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 [g].[Rank] & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL +WHERE CASE + WHEN [g].[LeaderNickname] IS NULL THEN NULL + ELSE CAST(LEN([g].[LeaderNickname]) AS int) +END = 5 """); } - public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool async) + public override async Task Null_propagation_optimization5(bool async) { - await base.Where_enum_has_flag_with_non_nullable_parameter(async); + await base.Null_propagation_optimization5(async); + // issue #16050 AssertSql( """ -@parameter='2' - 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 [g].[Rank] & @parameter = @parameter +WHERE CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) +END = 5 """); } - public override async Task Where_has_flag_with_nullable_parameter(bool async) + public override async Task Null_propagation_optimization6(bool async) { - await base.Where_has_flag_with_nullable_parameter(async); + await base.Null_propagation_optimization6(async); + // issue #16050 AssertSql( """ -@parameter='2' (Nullable = true) - 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 [g].[Rank] & @parameter = @parameter +WHERE CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) +END = 5 """); } - public override async Task Select_enum_has_flag(bool async) + public override async Task Select_null_propagation_optimization7(bool async) { - await base.Select_enum_has_flag(async); + await base.Select_null_propagation_optimization7(async); + // issue #16050 AssertSql( """ -SELECT TOP(1) ~CAST(([g].[Rank] & 2) ^ 2 AS bit) AS [hasFlagTrue], ~CAST(([g].[Rank] & 4) ^ 4 AS bit) AS [hasFlagFalse] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] +END FROM [Gears] AS [g] -WHERE [g].[Rank] & 2 = 2 """); } - public override async Task Where_count_subquery_without_collision(bool async) + public override async Task Select_null_propagation_optimization8(bool async) { - await base.Where_count_subquery_without_collision(async); + await base.Select_null_propagation_optimization8(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT COALESCE([g].[LeaderNickname], N'') + COALESCE([g].[LeaderNickname], N'') FROM [Gears] AS [g] -WHERE ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) = 2 """); } - public override async Task Where_any_subquery_without_collision(bool async) + public override async Task Select_null_propagation_optimization9(bool async) { - await base.Where_any_subquery_without_collision(async); + await base.Select_null_propagation_optimization9(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT CAST(LEN([g].[FullName]) AS int) FROM [Gears] AS [g] -WHERE EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) """); } - public override async Task Select_inverted_boolean(bool async) + public override async Task Select_null_propagation_negative1(bool async) { - await base.Select_inverted_boolean(async); + await base.Select_null_propagation_negative1(async); AssertSql( """ -SELECT [w].[Id], ~[w].[IsAutomatic] AS [Manual] -FROM [Weapons] AS [w] -WHERE [w].[IsAutomatic] = CAST(1 AS bit) +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_inverted_nullable_boolean(bool async) + public override async Task Select_null_propagation_negative2(bool async) { - await base.Select_inverted_nullable_boolean(async); + await base.Select_null_propagation_negative2(async); AssertSql( """ -SELECT [f].[Id], ~[f].[Eradicated] AS [Alive] -FROM [Factions] AS [f] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN [g0].[LeaderNickname] +END +FROM [Gears] AS [g] +CROSS JOIN [Gears] AS [g0] """); } - public override async Task Select_comparison_with_null(bool async) + public override async Task Select_null_propagation_negative3(bool async) { - await base.Select_comparison_with_null(async); + await base.Select_null_propagation_negative3(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = @ammunitionType AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Cartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType -""", - // - """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Cartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL +SELECT [g0].[Nickname], CASE + WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CASE + WHEN [g0].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END +END AS [Condition] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g0].[Nickname] """); } - public override async Task Select_null_parameter(bool async) + public override async Task Select_null_propagation_negative4(bool async) { - await base.Select_null_parameter(async); + await base.Select_null_propagation_negative4(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], @ammunitionType AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -SELECT [w].[Id], NULL AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -@ammunitionType='2' (Nullable = true) - -SELECT [w].[Id], @ammunitionType AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -SELECT [w].[Id], NULL AS [AmmoType] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g0].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g0].[Nickname] """); } - public override async Task Select_ternary_operation_with_boolean(bool async) + public override async Task Select_null_propagation_negative5(bool async) { - await base.Select_ternary_operation_with_boolean(async); + await base.Select_null_propagation_negative5(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 - ELSE 0 -END AS [Num] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g0].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g0].[Nickname] """); } - public override async Task Select_ternary_operation_with_inverted_boolean(bool async) + public override async Task Select_null_propagation_negative6(bool async) { - await base.Select_ternary_operation_with_inverted_boolean(async); + await base.Select_null_propagation_negative6(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN 1 - ELSE 0 -END AS [Num] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(0 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_ternary_operation_with_has_value_not_null(bool async) + public override async Task Select_null_propagation_negative7(bool async) { - await base.Select_ternary_operation_with_has_value_not_null(async); + await base.Select_null_propagation_negative7(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_ternary_operation_multiple_conditions(bool async) + public override async Task Select_null_propagation_negative8(bool async) { - await base.Select_ternary_operation_multiple_conditions(async); + await base.Select_null_propagation_negative8(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = 2 AND [w].[SynergyWithId] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [s].[Id] IS NOT NULL THEN [c].[Name] +END +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] """); } - public override async Task Select_ternary_operation_multiple_conditions_2(bool async) + public override async Task Select_null_propagation_negative9(bool async) { - await base.Select_ternary_operation_multiple_conditions_2(async); + await base.Select_null_propagation_negative9(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_multiple_conditions(bool async) + public override async Task Select_null_propagation_works_for_navigations_with_composite_keys(bool async) { - await base.Select_multiple_conditions(async); + await base.Select_null_propagation_works_for_navigations_with_composite_keys(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT [g].[Nickname] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Select_nested_ternary_operations(bool async) + public override async Task Select_null_propagation_works_for_multiple_navigations_with_composite_keys(bool async) { - await base.Select_nested_ternary_operations(async); + await base.Select_null_propagation_works_for_multiple_navigations_with_composite_keys(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CASE - WHEN [w].[AmmunitionType] = 1 THEN N'ManualCartridge' - ELSE N'Manual' - END - ELSE N'Auto' -END AS [IsManualCartridge] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [c].[Name] IS NOT NULL THEN [c].[Name] +END +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)) +LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] +LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] """); } - public override async Task Null_propagation_optimization1(bool async) + public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) { - await base.Null_propagation_optimization1(async); + await base.Select_conditional_with_anonymous_type_and_null_constant(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g].[HasSoulPatch] FROM [Gears] AS [g] -WHERE [g].[LeaderNickname] = N'Marcus' +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization2(bool async) + public override async Task Select_conditional_with_anonymous_types(bool async) { - await base.Null_propagation_optimization2(async); + await base.Select_conditional_with_anonymous_types(async); - // issue #16050 AssertSql( """ -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 - WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +END, [g].[Nickname], [g].[FullName] +FROM [Gears] AS [g] +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization3(bool async) + public override async Task Where_conditional_equality_1(bool async) { - await base.Null_propagation_optimization3(async); + await base.Where_conditional_equality_1(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname] FROM [Gears] AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE - WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END -END = CAST(1 AS bit) +WHERE [g].[LeaderNickname] IS NULL +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization4(bool async) + public override async Task Where_conditional_equality_2(bool async) { - await base.Null_propagation_optimization4(async); + await base.Where_conditional_equality_2(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname] FROM [Gears] AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NULL THEN NULL - ELSE CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +WHERE [g].[LeaderNickname] IS NULL +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization5(bool async) + public override async Task Where_conditional_equality_3(bool async) { - await base.Null_propagation_optimization5(async); + await base.Where_conditional_equality_3(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname] FROM [Gears] AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization6(bool async) + public override async Task Select_coalesce_with_anonymous_types(bool async) { - await base.Null_propagation_optimization6(async); + await base.Select_coalesce_with_anonymous_types(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[LeaderNickname], [g].[FullName] FROM [Gears] AS [g] -WHERE CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) -END = 5 +ORDER BY [g].[Nickname] """); } - public override async Task Select_null_propagation_optimization7(bool async) + public override async Task Where_compare_anonymous_types(bool async) { - await base.Select_null_propagation_optimization7(async); + await base.Where_compare_anonymous_types(async); - // issue #16050 - AssertSql( - """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] -END -FROM [Gears] AS [g] -"""); + AssertSql(); } - public override async Task Select_null_propagation_optimization8(bool async) + public override async Task Where_member_access_on_anonymous_type(bool async) { - await base.Select_null_propagation_optimization8(async); + await base.Where_member_access_on_anonymous_type(async); AssertSql( """ -SELECT COALESCE([g].[LeaderNickname], N'') + COALESCE([g].[LeaderNickname], N'') +SELECT [g].[Nickname] FROM [Gears] AS [g] +WHERE [g].[LeaderNickname] = N'Marcus' """); } - public override async Task Select_null_propagation_optimization9(bool async) + public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) { - await base.Select_null_propagation_optimization9(async); + await base.Where_compare_anonymous_types_with_uncorrelated_members(async); AssertSql( """ -SELECT CAST(LEN([g].[FullName]) AS int) +SELECT [g].[Nickname] FROM [Gears] AS [g] +WHERE 0 = 1 """); } - public override async Task Select_null_propagation_negative1(bool async) + public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool async) { - await base.Select_null_propagation_negative1(async); + await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) -END -FROM [Gears] AS [g] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] +WHERE [g].[Nickname] = [g0].[Nickname] OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL) """); } - public override async Task Select_null_propagation_negative2(bool async) + public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) { - await base.Select_null_propagation_negative2(async); + await base.Select_Singleton_Navigation_With_Member_Access(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN [g0].[LeaderNickname] -END -FROM [Gears] AS [g] -CROSS JOIN [Gears] AS [g0] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) """); } - public override async Task Select_null_propagation_negative3(bool async) + public override async Task Select_Where_Navigation(bool async) { - await base.Select_null_propagation_negative3(async); + await base.Select_Where_Navigation(async); AssertSql( """ -SELECT [g0].[Nickname], CASE - WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CASE - WHEN [g0].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END -END AS [Condition] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g0].[Nickname] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[Nickname] = N'Marcus' """); } - public override async Task Select_null_propagation_negative4(bool async) + public override async Task Select_Where_Navigation_Equals_Navigation(bool async) { - await base.Select_null_propagation_negative4(async); + await base.Select_Where_Navigation_Equals_Navigation(async); AssertSql( """ -SELECT CASE - WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g0].[Nickname] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g0].[Nickname] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] +WHERE ([g].[Nickname] = [g0].[Nickname] OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL)) AND ([g].[SquadId] = [g0].[SquadId] OR ([g].[SquadId] IS NULL AND [g0].[SquadId] IS NULL)) """); } - public override async Task Select_null_propagation_negative5(bool async) + public override async Task Select_Where_Navigation_Null(bool async) { - await base.Select_null_propagation_negative5(async); + await base.Select_Where_Navigation_Null(async); AssertSql( """ -SELECT CASE - WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g0].[Nickname] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g0].[Nickname] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[Nickname] IS NULL OR [g].[SquadId] IS NULL """); } - public override async Task Select_null_propagation_negative6(bool async) + public override async Task Select_Where_Navigation_Null_Reverse(bool async) { - await base.Select_null_propagation_negative6(async); + await base.Select_Where_Navigation_Null_Reverse(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(0 AS bit) -END -FROM [Gears] AS [g] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[Nickname] IS NULL OR [g].[SquadId] IS NULL """); } - public override async Task Select_null_propagation_negative7(bool async) + public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool async) { - await base.Select_null_propagation_negative7(async); + await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) -END -FROM [Gears] AS [g] +SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] +WHERE [g].[Nickname] = [g0].[Nickname] OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL) """); } - public override async Task Select_null_propagation_negative8(bool async) + public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool async) { - await base.Select_null_propagation_negative8(async); + await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(async); AssertSql( """ -SELECT CASE - WHEN [s].[Id] IS NOT NULL THEN [c].[Name] -END -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +SELECT TOP(1) COALESCE([w0].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w].[Id] """); } - public override async Task Select_null_propagation_negative9(bool async) + public override async Task Where_subquery_boolean(bool async) { - await base.Select_null_propagation_negative9(async); + await base.Where_subquery_boolean(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) -END +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 COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_works_for_navigations_with_composite_keys(bool async) + public override async Task Where_subquery_boolean_with_pushdown(bool async) { - await base.Select_null_propagation_works_for_navigations_with_composite_keys(async); + await base.Where_subquery_boolean_with_pushdown(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +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 ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_works_for_multiple_navigations_with_composite_keys(bool async) + public override async Task Where_subquery_distinct_firstordefault_boolean(bool async) { - await base.Select_null_propagation_works_for_multiple_navigations_with_composite_keys(async); + await base.Where_subquery_distinct_firstordefault_boolean(async); AssertSql( """ -SELECT CASE - WHEN [c].[Name] IS NOT NULL THEN [c].[Name] -END -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)) -LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] -LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] +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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) + public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) { - await base.Select_conditional_with_anonymous_type_and_null_constant(async); + await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[HasSoulPatch] +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] -ORDER BY [g].[Nickname] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_conditional_with_anonymous_types(bool async) + public override async Task Where_subquery_distinct_first_boolean(bool async) { - await base.Select_conditional_with_anonymous_types(async); + await base.Where_subquery_distinct_first_boolean(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[Nickname], [g].[FullName] +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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Where_conditional_equality_1(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean1(bool async) { - await base.Where_conditional_equality_1(async); + await base.Where_subquery_distinct_singleordefault_boolean1(async); AssertSql( """ -SELECT [g].[Nickname] +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 [g].[LeaderNickname] IS NULL +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]), CAST(0 AS bit)) = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Where_conditional_equality_2(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean2(bool async) { - await base.Where_conditional_equality_2(async); + await base.Where_subquery_distinct_singleordefault_boolean2(async); AssertSql( """ -SELECT [g].[Nickname] +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 [g].[LeaderNickname] IS NULL -ORDER BY [g].[Nickname] -"""); - } +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) = CAST(1 AS bit) +ORDER BY [g].[Nickname] +"""); + } - public override async Task Where_conditional_equality_3(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { - await base.Where_conditional_equality_3(async); + await base.Where_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [g].[Nickname] +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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]) = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Select_coalesce_with_anonymous_types(bool async) + public override async Task Where_subquery_distinct_lastordefault_boolean(bool async) { - await base.Select_coalesce_with_anonymous_types(async); + await base.Where_subquery_distinct_lastordefault_boolean(async); AssertSql( """ -SELECT [g].[LeaderNickname], [g].[FullName] +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 ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id] DESC) = CAST(0 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Where_compare_anonymous_types(bool async) - { - await base.Where_compare_anonymous_types(async); - - AssertSql(); - } - - public override async Task Where_member_access_on_anonymous_type(bool async) + public override async Task Where_subquery_distinct_last_boolean(bool async) { - await base.Where_member_access_on_anonymous_type(async); + await base.Where_subquery_distinct_last_boolean(async); AssertSql( """ -SELECT [g].[Nickname] +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 [g].[LeaderNickname] = N'Marcus' +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id] DESC) = CAST(1 AS bit) +ORDER BY [g].[Nickname] """); } - public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) + public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool async) { - await base.Where_compare_anonymous_types_with_uncorrelated_members(async); + await base.Where_subquery_distinct_orderby_firstordefault_boolean(async); AssertSql( """ -SELECT [g].[Nickname] +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 0 = 1 +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool async) + public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool async) { - await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(async); + await base.Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] -WHERE [g].[Nickname] = [g0].[Nickname] OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL) +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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) + public override async Task Where_subquery_union_firstordefault_boolean(bool async) { - await base.Select_Singleton_Navigation_With_Member_Access(async); + await base.Where_subquery_union_firstordefault_boolean(async); AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [u].[IsAutomatic] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + UNION + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u] + ORDER BY [u].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation(bool async) + public override async Task Where_subquery_join_firstordefault_boolean(bool async) { - await base.Select_Where_Navigation(async); + await base.Where_subquery_join_firstordefault_boolean(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] = N'Marcus' +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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + INNER JOIN ( + SELECT [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [w1] ON [w].[Id] = [w1].[Id] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Equals_Navigation(bool async) + public override async Task Where_subquery_left_join_firstordefault_boolean(bool async) { - await base.Select_Where_Navigation_Equals_Navigation(async); + await base.Where_subquery_left_join_firstordefault_boolean(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] -WHERE ([g].[Nickname] = [g0].[Nickname] OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL)) AND ([g].[SquadId] = [g0].[SquadId] OR ([g].[SquadId] IS NULL AND [g0].[SquadId] IS NULL)) +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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [w1] ON [w].[Id] = [w1].[Id] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Null(bool async) + public override async Task Where_subquery_concat_firstordefault_boolean(bool async) { - await base.Select_Where_Navigation_Null(async); + await base.Where_subquery_concat_firstordefault_boolean(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] IS NULL OR [g].[SquadId] IS NULL +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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [u].[IsAutomatic] + FROM ( + SELECT [w].[Id], [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + UNION ALL + SELECT [w0].[Id], [w0].[IsAutomatic] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u] + ORDER BY [u].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Null_Reverse(bool async) + public override async Task Concat_with_count(bool async) { - await base.Select_Where_Navigation_Null_Reverse(async); + await base.Concat_with_count(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] IS NULL OR [g].[SquadId] IS NULL +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty + FROM [Gears] AS [g] + UNION ALL + SELECT 1 AS empty + FROM [Gears] AS [g0] +) AS [u] """); } - public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool async) + public override async Task Concat_scalars_with_count(bool async) { - await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(async); + await base.Concat_scalars_with_count(async); AssertSql( """ -SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON [t0].[GearNickName] = [g0].[Nickname] AND [t0].[GearSquadId] = [g0].[SquadId] -WHERE [g].[Nickname] = [g0].[Nickname] OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL) +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty + FROM [Gears] AS [g] + UNION ALL + SELECT 1 AS empty + FROM [Gears] AS [g0] +) AS [u] """); } - public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool async) + public override async Task Concat_anonymous_with_count(bool async) { - await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(async); + await base.Concat_anonymous_with_count(async); AssertSql( """ -SELECT TOP(1) COALESCE([w0].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w].[Id] +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty + FROM [Gears] AS [g] + UNION ALL + SELECT 1 AS empty + FROM [Gears] AS [g0] +) AS [u] """); } - public override async Task Where_subquery_boolean(bool async) + public override async Task Concat_with_scalar_projection(bool async) { - await base.Where_subquery_boolean(async); + await base.Concat_with_scalar_projection(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname] FROM [Gears] AS [g] -WHERE COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +UNION ALL +SELECT [g0].[Nickname] +FROM [Gears] AS [g0] """); } - public override async Task Where_subquery_boolean_with_pushdown(bool async) + public override async Task Select_navigation_with_concat_and_count(bool async) { - await base.Where_subquery_boolean_with_pushdown(async); + await base.Select_navigation_with_concat_and_count(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT ( + SELECT COUNT(*) + FROM ( + SELECT 1 AS empty + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + UNION ALL + SELECT 1 AS empty + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u]) FROM [Gears] AS [g] -WHERE ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Where_subquery_distinct_firstordefault_boolean(bool async) + public override async Task Concat_with_collection_navigations(bool async) { - await base.Where_subquery_distinct_firstordefault_boolean(async); + await base.Concat_with_collection_navigations(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] +SELECT ( + SELECT COUNT(*) FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) + UNION + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u]) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) + public override async Task Union_with_collection_navigations(bool async) { - await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); + await base.Union_with_collection_navigations(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] +SELECT ( + SELECT COUNT(*) FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] + UNION + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] + FROM [Gears] AS [g1] + WHERE [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] + ) AS [u]) +FROM [Gears] AS [g] +WHERE [g].[Discriminator] = N'Officer' """); } - public override async Task Where_subquery_distinct_first_boolean(bool async) + public override async Task Select_subquery_distinct_firstordefault(bool async) { - await base.Where_subquery_distinct_first_boolean(async); + await base.Select_subquery_distinct_firstordefault(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] +SELECT ( + SELECT TOP(1) [w0].[Name] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) -ORDER BY [g].[Nickname] + ORDER BY [w0].[Id]) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Where_subquery_distinct_singleordefault_boolean1(bool async) + public override async Task Singleton_Navigation_With_Member_Access(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean1(async); + await base.Singleton_Navigation_With_Member_Access(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]), CAST(0 AS bit)) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +SELECT [g].[CityOfBirthName] AS [B] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) """); } - public override async Task Where_subquery_distinct_singleordefault_boolean2(bool async) + public override async Task GroupJoin_Composite_Key(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean2(async); + await base.GroupJoin_Composite_Key(async); AssertSql( """ 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +FROM [Tags] AS [t] +INNER JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Where_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) + public override async Task Join_navigation_translated_to_subquery_composite_key(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean_with_pushdown(async); + await base.Join_navigation_translated_to_subquery_composite_key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[FullName], [s].[Note] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +INNER JOIN ( + SELECT [t].[Note], [g0].[FullName] + FROM [Tags] AS [t] + LEFT JOIN [Gears] AS [g0] ON [t].[GearNickName] = [g0].[Nickname] AND [t].[GearSquadId] = [g0].[SquadId] +) AS [s] ON [g].[FullName] = [s].[FullName] """); } - public override async Task Where_subquery_distinct_lastordefault_boolean(bool async) + public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) { - await base.Where_subquery_distinct_lastordefault_boolean(async); + await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[FullName], [s].[Note] FROM [Gears] AS [g] -WHERE ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id] DESC) = CAST(0 AS bit) -ORDER BY [g].[Nickname] +INNER JOIN ( + SELECT [t].[Note], [g0].[FullName] + FROM [Tags] AS [t] + LEFT JOIN [Gears] AS [g0] ON [t].[GearNickName] = [g0].[Nickname] AND [t].[GearSquadId] = [g0].[SquadId] +) AS [s] ON [g].[FullName] = [s].[FullName] """); } - public override async Task Where_subquery_distinct_last_boolean(bool async) + public override async Task Join_with_order_by_without_skip_or_take(bool async) { - await base.Where_subquery_distinct_last_boolean(async); + await base.Join_with_order_by_without_skip_or_take(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [w].[Name], [g].[FullName] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id] DESC) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] """); } - public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool async) + public override async Task Join_with_order_by_without_skip_or_take_nested(bool async) { - await base.Where_subquery_distinct_orderby_firstordefault_boolean(async); + await base.Join_with_order_by_without_skip_or_take_nested(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [w].[Name], [g].[FullName] +FROM [Squads] AS [s] +INNER JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] +INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] """); } - public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool async) + public override async Task Collection_with_inheritance_and_join_include_joined(bool async) { - await base.Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(async); + await base.Collection_with_inheritance_and_join_include_joined(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +INNER JOIN ( + 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 [g].[Discriminator] = N'Officer' +) AS [g0] ON [t].[GearSquadId] = [g0].[SquadId] AND [t].[GearNickName] = [g0].[Nickname] +LEFT JOIN [Tags] AS [t0] ON [g0].[Nickname] = [t0].[GearNickName] AND [g0].[SquadId] = [t0].[GearSquadId] """); } - public override async Task Where_subquery_union_firstordefault_boolean(bool async) + public override async Task Collection_with_inheritance_and_join_include_source(bool async) { - await base.Where_subquery_union_firstordefault_boolean(async); + await base.Collection_with_inheritance_and_join_include_source(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [u].[IsAutomatic] - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u] - ORDER BY [u].[Id]) = CAST(1 AS bit) +INNER JOIN [Tags] AS [t] ON [g].[SquadId] = [t].[GearSquadId] AND [g].[Nickname] = [t].[GearNickName] +LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] +WHERE [g].[Discriminator] = N'Officer' """); } - public override async Task Where_subquery_join_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_join_firstordefault_boolean(async); + await base.Non_unicode_string_literal_is_used_for_non_unicode_column(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - INNER JOIN ( - SELECT [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [w1] ON [w].[Id] = [w1].[Id] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' """); } - public override async Task Where_subquery_left_join_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column_right(bool async) { - await base.Where_subquery_left_join_firstordefault_boolean(async); + await base.Non_unicode_string_literal_is_used_for_non_unicode_column_right(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [w1] ON [w].[Id] = [w1].[Id] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE 'Unknown' = [c].[Location] """); } - public override async Task Where_subquery_concat_firstordefault_boolean(bool async) + public override async Task Non_unicode_parameter_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_concat_firstordefault_boolean(async); + await base.Non_unicode_parameter_is_used_for_non_unicode_column(async); AssertSql( """ -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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [u].[IsAutomatic] - FROM ( - SELECT [w].[Id], [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION ALL - SELECT [w0].[Id], [w0].[IsAutomatic] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u] - ORDER BY [u].[Id]) = CAST(1 AS bit) +@value='Unknown' (Size = 100) (DbType = AnsiString) + +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = @value """); } - public override async Task Concat_with_count(bool async) + public override async Task Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(bool async) { - await base.Concat_with_count(async); + await base.Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(async); AssertSql( """ -SELECT COUNT(*) -FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Gears] AS [g0] -) AS [u] +@cities='["Unknown","Jacinto\u0027s location","Ephyra\u0027s location"]' (Size = 4000) + +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] IN ( + SELECT [c0].[value] + FROM OPENJSON(@cities) WITH ([value] varchar(100) '$') AS [c0] +) """); } - public override async Task Concat_scalars_with_count(bool async) + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(bool async) { - await base.Concat_scalars_with_count(async); + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(async); AssertSql( """ -SELECT COUNT(*) -FROM ( - SELECT 1 AS empty +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' AND ( + SELECT COUNT(*) FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Gears] AS [g0] -) AS [u] + WHERE [c].[Name] = [g].[CityOfBirthName] AND [g].[Nickname] = N'Paduk') = 1 """); } - public override async Task Concat_anonymous_with_count(bool async) + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(bool async) { - await base.Concat_anonymous_with_count(async); + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(async); AssertSql( """ -SELECT COUNT(*) -FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Gears] AS [g0] -) AS [u] +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] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +WHERE [g].[Nickname] = N'Marcus' AND [c].[Location] = 'Jacinto''s location' """); } - public override async Task Concat_with_scalar_projection(bool async) + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(bool async) { - await base.Concat_with_scalar_projection(async); + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -UNION ALL -SELECT [g0].[Nickname] -FROM [Gears] AS [g0] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] LIKE '%Jacinto%' """); } - public override async Task Select_navigation_with_concat_and_count(bool async) + public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) { - await base.Select_navigation_with_concat_and_count(async); + await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT 1 AS empty - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION ALL - SELECT 1 AS empty - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u]) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE COALESCE([c].[Location], N'') + N'Added' LIKE N'%Add%' """); } - public override async Task Concat_with_collection_navigations(bool async) + public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() { - await base.Concat_with_collection_navigations(async); + base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); + // Issue#16897 AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u]) +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId] """); } - public override async Task Union_with_collection_navigations(bool async) + public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() { - await base.Union_with_collection_navigations(async); + base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); + // Issue#16897 AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] - UNION - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] - FROM [Gears] AS [g1] - WHERE [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] - ) AS [u]) +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -WHERE [g].[Discriminator] = N'Officer' +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId] """); } - public override async Task Select_subquery_distinct_firstordefault(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) { - await base.Select_subquery_distinct_firstordefault(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(async); + // Issue#16897 AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[Name] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id] """); } - public override async Task Singleton_Navigation_With_Member_Access(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) { - await base.Singleton_Navigation_With_Member_Access(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async); + // Issue#16897 AssertSql( """ -SELECT [g].[CityOfBirthName] AS [B] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] = N'Marcus' AND ([g].[CityOfBirthName] <> N'Ephyra' OR [g].[CityOfBirthName] IS NULL) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Weapons] AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] +LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id] """); } - public override async Task GroupJoin_Composite_Key(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) { - await base.GroupJoin_Composite_Key(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); + // Issue#16897 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [Tags] AS [t] -INNER JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[Discriminator] = N'Officer' +) AS [g1] ON [g].[LeaderNickname] = [g1].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g1].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[SquadId], [w].[Id] """); } - public override async Task Join_navigation_translated_to_subquery_composite_key(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) { - await base.Join_navigation_translated_to_subquery_composite_key(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(async); + // Issue#16897 AssertSql( """ -SELECT [g].[FullName], [s].[Note] +SELECT CASE + WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] -INNER JOIN ( - SELECT [t].[Note], [g0].[FullName] - FROM [Tags] AS [t] - LEFT JOIN [Gears] AS [g0] ON [t].[GearNickName] = [g0].[Nickname] AND [t].[GearSquadId] = [g0].[SquadId] -) AS [s] ON [g].[FullName] = [s].[FullName] +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id] """); } - public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async) { - await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async); AssertSql( """ -SELECT [g].[FullName], [s].[Note] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId], CASE + WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w3].[Id], [w3].[AmmunitionType], [w3].[IsAutomatic], [w3].[Name], [w3].[OwnerFullName], [w3].[SynergyWithId], [w4].[Id], [w4].[AmmunitionType], [w4].[IsAutomatic], [w4].[Name], [w4].[OwnerFullName], [w4].[SynergyWithId] FROM [Gears] AS [g] -INNER JOIN ( - SELECT [t].[Note], [g0].[FullName] - FROM [Tags] AS [t] - LEFT JOIN [Gears] AS [g0] ON [t].[GearNickName] = [g0].[Nickname] AND [t].[GearSquadId] = [g0].[SquadId] -) AS [s] ON [g].[FullName] = [s].[FullName] +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Weapons] AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] +LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +LEFT JOIN [Weapons] AS [w3] ON [g0].[FullName] = [w3].[OwnerFullName] +LEFT JOIN [Weapons] AS [w4] ON [g].[FullName] = [w4].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id], [w2].[Id], [w3].[Id] """); } - public override async Task Join_with_order_by_without_skip_or_take(bool async) + public override async Task Coalesce_operator_in_predicate(bool async) { - await base.Join_with_order_by_without_skip_or_take(async); + await base.Coalesce_operator_in_predicate(async); AssertSql( """ -SELECT [w].[Name], [g].[FullName] -FROM [Gears] AS [g] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Join_with_order_by_without_skip_or_take_nested(bool async) + public override async Task Coalesce_operator_in_predicate_with_other_conditions(bool async) { - await base.Join_with_order_by_without_skip_or_take_nested(async); + await base.Coalesce_operator_in_predicate_with_other_conditions(async); AssertSql( """ -SELECT [w].[Name], [g].[FullName] -FROM [Squads] AS [s] -INNER JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Collection_with_inheritance_and_join_include_joined(bool async) + public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) { - await base.Collection_with_inheritance_and_join_include_joined(async); + await base.Coalesce_operator_in_projection_with_other_conditions(async); AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +SELECT CASE + WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END FROM [Tags] AS [t] -INNER JOIN ( - 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 [g].[Discriminator] = N'Officer' -) AS [g0] ON [t].[GearSquadId] = [g0].[SquadId] AND [t].[GearNickName] = [g0].[Nickname] -LEFT JOIN [Tags] AS [t0] ON [g0].[Nickname] = [t0].[GearNickName] AND [g0].[SquadId] = [t0].[GearSquadId] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Collection_with_inheritance_and_join_include_source(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate(bool async) { - await base.Collection_with_inheritance_and_join_include_source(async); + await base.Optional_navigation_type_compensation_works_with_predicate(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Gears] AS [g] -INNER JOIN [Tags] AS [t] ON [g].[SquadId] = [t].[GearSquadId] AND [g].[Nickname] = [t].[GearNickName] -LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE [g].[Discriminator] = N'Officer' +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate2(bool async) { - await base.Non_unicode_string_literal_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_predicate2(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column_right(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated(bool async) { - await base.Non_unicode_string_literal_is_used_for_non_unicode_column_right(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE 'Unknown' = [c].[Location] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Non_unicode_parameter_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool async) { - await base.Non_unicode_parameter_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(async); AssertSql( """ -@value='Unknown' (Size = 100) (DbType = AnsiString) - -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = @value +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE [g].[HasSoulPatch] +END = CAST(0 AS bit) """); } - public override async Task Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool async) { - await base.Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(async); AssertSql( """ -@cities='["Unknown","Jacinto\u0027s location","Ephyra\u0027s location"]' (Size = 4000) - -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] IN ( - SELECT [c0].[value] - FROM OPENJSON(@cities) WITH ([value] varchar(100) '$') AS [c0] -) +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [g].[HasSoulPatch] = CAST(0 AS bit) THEN CAST(0 AS bit) + ELSE [g].[HasSoulPatch] +END = CAST(0 AS bit) """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(bool async) + public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(async); + await base.Optional_navigation_type_compensation_works_with_conditional_expression(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' AND ( - SELECT COUNT(*) - FROM [Gears] AS [g] - WHERE [c].[Name] = [g].[CityOfBirthName] AND [g].[Nickname] = N'Paduk') = 1 +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(bool async) + public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(async); + await base.Optional_navigation_type_compensation_works_with_binary_expression(async); AssertSql( """ -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] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -WHERE [g].[Nickname] = N'Marcus' AND [c].[Location] = 'Jacinto''s location' +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) OR [t].[Note] LIKE N'%Cole%' """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(bool async) + public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(async); + await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] LIKE '%Jacinto%' +SELECT CASE + WHEN [g].[HasSoulPatch] = CAST(1 AS bit) AND [t].[Note] LIKE N'%Cole%' AND [t].[Note] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) + public override async Task Optional_navigation_type_compensation_works_with_projection(bool async) { - await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); + await base.Optional_navigation_type_compensation_works_with_projection(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE COALESCE([c].[Location], N'') + N'Added' LIKE N'%Add%' +SELECT [g].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() + public override async Task Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(bool async) { - base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); + await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(async); - // Issue#16897 AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId] +SELECT [g].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() + public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) { - base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); + await base.Optional_navigation_type_compensation_works_with_DTOs(async); - // Issue#16897 AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId] +SELECT [g].[SquadId] AS [Id] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) + public override async Task Optional_navigation_type_compensation_works_with_list_initializers(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(async); + await base.Optional_navigation_type_compensation_works_with_list_initializers(async); - // Issue#16897 AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id] +SELECT [g].[SquadId], [g].[SquadId] + 1 +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +ORDER BY [t].[Note] """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) + public override async Task Optional_navigation_type_compensation_works_with_array_initializers(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async); + await base.Optional_navigation_type_compensation_works_with_array_initializers(async); - // Issue#16897 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] -LEFT JOIN [Weapons] AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] -LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id] +SELECT [g].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) + public override async Task Optional_navigation_type_compensation_works_with_orderby(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); + await base.Optional_navigation_type_compensation_works_with_orderby(async); - // Issue#16897 AssertSql( """ -SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - WHERE [g0].[Discriminator] = N'Officer' -) AS [g1] ON [g].[LeaderNickname] = [g1].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g1].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[SquadId], [w].[Id] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +ORDER BY [g].[SquadId] """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) + public override async Task Optional_navigation_type_compensation_works_with_all(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(async); + await base.Optional_navigation_type_compensation_works_with_all(async); - // Issue#16897 AssertSql( """ SELECT CASE - WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + WHEN NOT EXISTS ( + SELECT 1 + FROM [Tags] AS [t] + LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] + WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END, [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id] +END """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async) + public override async Task Optional_navigation_type_compensation_works_with_negated_predicate(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId], CASE - WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w3].[Id], [w3].[AmmunitionType], [w3].[IsAutomatic], [w3].[Name], [w3].[OwnerFullName], [w3].[SynergyWithId], [w4].[Id], [w4].[AmmunitionType], [w4].[IsAutomatic], [w4].[Name], [w4].[OwnerFullName], [w4].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] -LEFT JOIN [Weapons] AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] -LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -LEFT JOIN [Weapons] AS [w3] ON [g0].[FullName] = [w3].[OwnerFullName] -LEFT JOIN [Weapons] AS [w4] ON [g].[FullName] = [w4].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id], [w2].[Id], [w3].[Id] -"""); - } - - public override async Task Coalesce_operator_in_predicate(bool async) - { - await base.Coalesce_operator_in_predicate(async); + await base.Optional_navigation_type_compensation_works_with_negated_predicate(async); AssertSql( """ SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Coalesce_operator_in_predicate_with_other_conditions(bool async) + public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) { - await base.Coalesce_operator_in_predicate_with_other_conditions(async); + await base.Optional_navigation_type_compensation_works_with_contains(async); AssertSql( """ SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[SquadId] IN ( + SELECT [g0].[SquadId] + FROM [Gears] AS [g0] +) """); } - public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) + public override async Task Optional_navigation_type_compensation_works_with_skip(bool async) { - await base.Coalesce_operator_in_projection_with_other_conditions(async); + await base.Optional_navigation_type_compensation_works_with_skip(async); - AssertSql( - """ -SELECT CASE - WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -"""); + AssertSql(); } - public override async Task Optional_navigation_type_compensation_works_with_predicate(bool async) + public override async Task Optional_navigation_type_compensation_works_with_take(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate(async); + await base.Optional_navigation_type_compensation_works_with_take(async); - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(1 AS bit) -"""); + AssertSql(); } - public override async Task Optional_navigation_type_compensation_works_with_predicate2(bool async) + public override async Task Select_correlated_filtered_collection(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate2(async); + await base.Select_correlated_filtered_collection(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [c].[Name] IN (N'Ephyra', N'Hanover') +ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated(bool async) + public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated(async); + await base.Select_correlated_filtered_collection_with_composite_key(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[Nickname] <> N'Dom' +) AS [g1] ON [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool async) + public override async Task Select_correlated_filtered_collection_works_with_caching(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(async); + await base.Select_correlated_filtered_collection_works_with_caching(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE [g].[HasSoulPatch] -END = CAST(0 AS bit) +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] +ORDER BY [t].[Note], [t].[Id], [g].[Nickname] """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool async) + public override async Task Join_predicate_value_equals_condition(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(async); + await base.Join_predicate_value_equals_condition(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [g].[HasSoulPatch] = CAST(0 AS bit) THEN CAST(0 AS bit) - ELSE [g].[HasSoulPatch] -END = CAST(0 AS bit) +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] +INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool async) + public override async Task Join_predicate_value(bool async) { - await base.Optional_navigation_type_compensation_works_with_conditional_expression(async); + await base.Join_predicate_value(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +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] +INNER JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) + public override async Task Join_predicate_condition_equals_condition(bool async) { - await base.Optional_navigation_type_compensation_works_with_binary_expression(async); + await base.Join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) OR [t].[Note] LIKE N'%Cole%' +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] +INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) + public override async Task Left_join_predicate_value_equals_condition(bool async) { - await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); + await base.Left_join_predicate_value_equals_condition(async); AssertSql( """ -SELECT CASE - WHEN [g].[HasSoulPatch] = CAST(1 AS bit) AND [t].[Note] LIKE N'%Cole%' AND [t].[Note] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +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] +LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_projection(bool async) + public override async Task Left_join_predicate_value(bool async) { - await base.Optional_navigation_type_compensation_works_with_projection(async); + await base.Left_join_predicate_value(async); AssertSql( """ -SELECT [g].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +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] +LEFT JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(bool async) + public override async Task Left_join_predicate_condition_equals_condition(bool async) { - await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(async); + await base.Left_join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT [g].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +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] +LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + [SqlServerCondition(SqlServerCondition.SupportsSqlClr)] + public virtual async Task Where_AtTimeZone_datetime_constant(bool async) { - await base.Optional_navigation_type_compensation_works_with_DTOs(async); + using var context = CreateContext(); - AssertSql( - """ -SELECT [g].[SquadId] AS [Id] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -"""); - } + var query = context.Set().Where(m => m.Timeline == EF.Functions.AtTimeZone(new DateTime(10, 5, 3, 12, 0, 0), "UTC")); - public override async Task Optional_navigation_type_compensation_works_with_list_initializers(bool async) - { - await base.Optional_navigation_type_compensation_works_with_list_initializers(async); + var missions = async + ? await query.ToListAsync() + : query.ToList(); + + var mission = Assert.Single(missions); + Assert.Equal(3, mission.Id); AssertSql( """ -SELECT [g].[SquadId], [g].[SquadId] + 1 -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -ORDER BY [t].[Note] +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE [m].[Timeline] = CAST('0010-05-03T12:00:00.0000000' AS datetime2) AT TIME ZONE 'UTC' """); } - public override async Task Optional_navigation_type_compensation_works_with_array_initializers(bool async) + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + [SqlServerCondition(SqlServerCondition.SupportsSqlClr)] + public virtual async Task Where_AtTimeZone_datetime_parameter(bool async) { - await base.Optional_navigation_type_compensation_works_with_array_initializers(async); + using var context = CreateContext(); + + var dateTime = new DateTime(10, 5, 3, 12, 0, 0); + var timeZone = "UTC"; + var query = context.Set().Where(m => m.Timeline == EF.Functions.AtTimeZone(dateTime, timeZone)); + + var missions = async + ? await query.ToListAsync() + : query.ToList(); + + var mission = Assert.Single(missions); + Assert.Equal(3, mission.Id); AssertSql( """ -SELECT [g].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +@dateTime='0010-05-03T12:00:00.0000000' +@timeZone='UTC' (Size = 8000) (DbType = AnsiString) + +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE [m].[Timeline] = @dateTime AT TIME ZONE @timeZone """); } - public override async Task Optional_navigation_type_compensation_works_with_orderby(bool async) + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + [SqlServerCondition(SqlServerCondition.SupportsSqlClr)] + public virtual async Task Where_AtTimeZone_datetime_column(bool async) { - await base.Optional_navigation_type_compensation_works_with_orderby(async); + using var context = CreateContext(); + + var query = context.Set() + .Where(ct => EF.Functions.AtTimeZone(ct.IssueDate, "UTC") == new DateTimeOffset(15, 3, 7, 0, 0, 0, TimeSpan.Zero)); + + var missions = async + ? await query.ToListAsync() + : query.ToList(); + + var mission = Assert.Single(missions); + Assert.Equal(Guid.Parse("A7BE028A-0CF2-448F-AB55-CE8BC5D8CF69"), mission.Id); AssertSql( """ SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -ORDER BY [g].[SquadId] +WHERE [t].[IssueDate] AT TIME ZONE 'UTC' = '0015-03-07T00:00:00.0000000+00:00' """); } - public override async Task Optional_navigation_type_compensation_works_with_all(bool async) + public override async Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( + bool async) { - await base.Optional_navigation_type_compensation_works_with_all(async); + await base.Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(async); - AssertSql( - """ -SELECT CASE - WHEN NOT EXISTS ( - SELECT 1 - FROM [Tags] AS [t] - LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] - WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -"""); + AssertSql(); } - public override async Task Optional_navigation_type_compensation_works_with_negated_predicate(bool async) + public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_property(bool async) { - await base.Optional_navigation_type_compensation_works_with_negated_predicate(async); + await base.Complex_predicate_with_AndAlso_and_nullable_bool_property(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[HasSoulPatch] = CAST(0 AS bit) +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] +WHERE [w].[Id] <> 50 AND [g].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) + public override async Task Distinct_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_contains(async); + await base.Distinct_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [g].[SquadId] IN ( - SELECT [g0].[SquadId] - FROM [Gears] AS [g0] -) +SELECT DISTINCT [g].[HasSoulPatch] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_skip(bool async) - { - await base.Optional_navigation_type_compensation_works_with_skip(async); - - AssertSql(); - } - - public override async Task Optional_navigation_type_compensation_works_with_take(bool async) - { - await base.Optional_navigation_type_compensation_works_with_take(async); - - AssertSql(); - } - - public override async Task Select_correlated_filtered_collection(bool async) + public override async Task Sum_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Select_correlated_filtered_collection(async); + await base.Sum_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT COALESCE(SUM([g].[SquadId]), 0) FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [c].[Name] IN (N'Ephyra', N'Hanover') -ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) + public override async Task Count_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Select_correlated_filtered_collection_with_composite_key(async); + await base.Count_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] +SELECT COUNT(*) FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - WHERE [g0].[Nickname] <> N'Dom' -) AS [g1] ON [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Select_correlated_filtered_collection_works_with_caching(bool async) + public override async Task FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(bool async) { - await base.Select_correlated_filtered_collection_works_with_caching(async); + await base.FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] -ORDER BY [t].[Note], [t].[Id], [g].[Nickname] +SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Join_predicate_value_equals_condition(bool async) + public override async Task Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(bool async) { - await base.Join_predicate_value_equals_condition(async); + await base.Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(async); AssertSql( """ -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] -INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE NOT EXISTS ( + SELECT 1 + FROM [Gears] AS [g] + LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] + WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') """); } - public override async Task Join_predicate_value(bool async) + public override async Task All_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Join_predicate_value(async); + await base.All_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -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] -INNER JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT CASE + WHEN NOT EXISTS ( + SELECT 1 + FROM [Gears] AS [g] + LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] + WHERE [t].[Note] = N'Foo') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Join_predicate_condition_equals_condition(bool async) + public override async Task Contains_with_local_nullable_guid_list_closure(bool async) { - await base.Join_predicate_condition_equals_condition(async); + await base.Contains_with_local_nullable_guid_list_closure(async); AssertSql( """ -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] -INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +@ids='["df36f493-463f-4123-83f9-6b135deeb7ba","23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3","ab1b82d7-88db-42bd-a132-7eef9aa68af4"]' (Size = 4000) + +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +WHERE [t].[Id] IN ( + SELECT [i].[value] + FROM OPENJSON(@ids) WITH ([value] uniqueidentifier '$') AS [i] +) """); } - public override async Task Left_join_predicate_value_equals_condition(bool async) + public override async Task Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(bool async) { - await base.Left_join_predicate_value_equals_condition(async); + await base.Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[FullName] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g].[Rank] """); } - public override async Task Left_join_predicate_value(bool async) + public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(bool async) { - await base.Left_join_predicate_value(async); + await base.Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[FullName] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Left_join_predicate_condition_equals_condition(bool async) + public override async Task Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(bool async) { - await base.Left_join_predicate_condition_equals_condition(async); + await base.Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[FullName] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Where_datetimeoffset_now(bool async) + public override async Task Where_is_properly_lifted_from_subquery_created_by_include(bool async) { - await base.Where_datetimeoffset_now(async); + await base.Where_is_properly_lifted_from_subquery_created_by_include(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] <> SYSDATETIMEOFFSET() +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [g].[FullName] <> N'Augustus Cole' AND [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Where_datetimeoffset_utcnow(bool async) + public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMany(bool async) { - await base.Where_datetimeoffset_utcnow(async); + await base.Subquery_is_lifted_from_main_from_clause_of_SelectMany(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) +SELECT [g].[FullName] AS [Name1], [g0].[FullName] AS [Name2] +FROM [Gears] AS [g] +CROSS JOIN [Gears] AS [g0] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [g0].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Where_datetimeoffset_date_component(bool async) + public override async Task Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(bool async) { - await base.Where_datetimeoffset_date_component(async); + await base.Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -@Date='0001-01-01T00:00:00.0000000' - -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONVERT(date, [m].[Timeline]) > @Date +SELECT [g].[FullName] +FROM [Gears] AS [g] +CROSS JOIN [Tags] AS [t] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Where_datetimeoffset_year_component(bool async) + public override async Task Subquery_containing_join_projecting_main_from_clause_gets_lifted(bool async) { - await base.Where_datetimeoffset_year_component(async); + await base.Subquery_containing_join_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(year, [m].[Timeline]) = 2 +SELECT [g].[Nickname] +FROM [Gears] AS [g] +INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +ORDER BY [g].[Nickname] """); } - public override async Task Where_datetimeoffset_month_component(bool async) + public override async Task Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(bool async) { - await base.Where_datetimeoffset_month_component(async); + await base.Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(month, [m].[Timeline]) = 1 +SELECT [g].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +ORDER BY [g].[Nickname] """); } - public override async Task Where_datetimeoffset_dayofyear_component(bool async) + public override async Task Subquery_containing_join_gets_lifted_clashing_names(bool async) { - await base.Where_datetimeoffset_dayofyear_component(async); + await base.Subquery_containing_join_gets_lifted_clashing_names(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(dayofyear, [m].[Timeline]) = 2 +SELECT [g].[Nickname] +FROM [Gears] AS [g] +INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +INNER JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] +WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL +ORDER BY [g].[Nickname], [t0].[Id] """); } - public override async Task Where_datetimeoffset_day_component(bool async) + public override async Task Subquery_created_by_include_gets_lifted_nested(bool async) { - await base.Where_datetimeoffset_day_component(async); + await base.Subquery_created_by_include_gets_lifted_nested(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(day, [m].[Timeline]) = 2 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation] +FROM [Gears] AS [g] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +WHERE EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) AND [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[Nickname] """); } - public override async Task Where_datetimeoffset_hour_component(bool async) + public override async Task Subquery_is_lifted_from_additional_from_clause(bool async) { - await base.Where_datetimeoffset_hour_component(async); + await base.Subquery_is_lifted_from_additional_from_clause(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Timeline]) = 10 +SELECT [g].[FullName] AS [Name1], [g0].[FullName] AS [Name2] +FROM [Gears] AS [g] +CROSS JOIN [Gears] AS [g0] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [g0].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Where_datetimeoffset_minute_component(bool async) + public override async Task Subquery_with_result_operator_is_not_lifted(bool async) { - await base.Where_datetimeoffset_minute_component(async); + await base.Subquery_with_result_operator_is_not_lifted(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Timeline]) = 0 -"""); - } - - public override async Task Where_datetimeoffset_second_component(bool async) - { - await base.Where_datetimeoffset_second_component(async); +@p='2' - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Timeline]) = 0 +SELECT [g0].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) + ORDER BY [g].[FullName] +) AS [g0] +ORDER BY [g0].[Rank] """); } - public override async Task Where_datetimeoffset_millisecond_component(bool async) + public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down(bool async) { - await base.Where_datetimeoffset_millisecond_component(async); + await base.Skip_with_orderby_followed_by_orderBy_is_pushed_down(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Timeline]) = 0 +@p='1' + +SELECT [g0].[FullName] +FROM ( + SELECT [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) + ORDER BY [g].[FullName] + OFFSET @p ROWS +) AS [g0] +ORDER BY [g0].[Rank] """); } - public override async Task DateTimeOffset_DateAdd_AddMonths(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) { - await base.DateTimeOffset_DateAdd_AddMonths(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); AssertSql( """ -SELECT DATEADD(month, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +@p='999' + +SELECT [g0].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +) AS [g0] +ORDER BY [g0].[Rank] """); } - public override async Task DateTimeOffset_DateAdd_AddDays(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) { - await base.DateTimeOffset_DateAdd_AddDays(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); AssertSql( """ -SELECT DATEADD(day, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +@p='999' + +SELECT [g0].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +) AS [g0] +ORDER BY [g0].[Rank] """); } - public override async Task DateTimeOffset_DateAdd_AddHours(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) { - await base.DateTimeOffset_DateAdd_AddHours(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); AssertSql( """ -SELECT DATEADD(hour, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +@p='999' + +SELECT [g0].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +) AS [g0] +ORDER BY [g0].[FullName], [g0].[Rank] """); } - public override async Task DateTimeOffset_DateAdd_AddMinutes(bool async) + public override async Task Select_length_of_string_property(bool async) { - await base.DateTimeOffset_DateAdd_AddMinutes(async); + await base.Select_length_of_string_property(async); AssertSql( """ -SELECT DATEADD(minute, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] +FROM [Weapons] AS [w] """); } - public override async Task DateTimeOffset_DateAdd_AddSeconds(bool async) + public override async Task Client_method_on_collection_navigation_in_outer_join_key(bool async) { - await base.DateTimeOffset_DateAdd_AddSeconds(async); + await base.Client_method_on_collection_navigation_in_outer_join_key(async); - AssertSql( - """ -SELECT DATEADD(second, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] -"""); + AssertSql(); } - public override async Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) + public override async Task Member_access_on_derived_entity_using_cast(bool async) { - await base.DateTimeOffset_DateAdd_AddMilliseconds(async); + await base.Member_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT DATEADD(millisecond, CAST(300.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [f].[Name], [f].[Eradicated] +FROM [Factions] AS [f] +ORDER BY [f].[Name] """); } - public override async Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) + public override async Task Member_access_on_derived_materialized_entity_using_cast(bool async) { - await base.Where_datetimeoffset_milliseconds_parameter_and_constant(async); + await base.Member_access_on_derived_materialized_entity_using_cast(async); AssertSql( """ -SELECT COUNT(*) -FROM [Missions] AS [m] -WHERE [m].[Timeline] = '1902-01-02T10:00:00.1234567+01:30' +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] +FROM [Factions] AS [f] +ORDER BY [f].[Name] """); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - [SqlServerCondition(SqlServerCondition.SupportsSqlClr)] - public virtual async Task Where_AtTimeZone_datetime_constant(bool async) + public override async Task Member_access_on_derived_entity_using_cast_and_let(bool async) { - using var context = CreateContext(); - - var query = context.Set().Where(m => m.Timeline == EF.Functions.AtTimeZone(new DateTime(10, 5, 3, 12, 0, 0), "UTC")); - - var missions = async - ? await query.ToListAsync() - : query.ToList(); - - var mission = Assert.Single(missions); - Assert.Equal(3, mission.Id); + await base.Member_access_on_derived_entity_using_cast_and_let(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] = CAST('0010-05-03T12:00:00.0000000' AS datetime2) AT TIME ZONE 'UTC' +SELECT [f].[Name], [f].[Eradicated] +FROM [Factions] AS [f] +ORDER BY [f].[Name] """); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - [SqlServerCondition(SqlServerCondition.SupportsSqlClr)] - public virtual async Task Where_AtTimeZone_datetime_parameter(bool async) + public override async Task Property_access_on_derived_entity_using_cast(bool async) { - using var context = CreateContext(); - - var dateTime = new DateTime(10, 5, 3, 12, 0, 0); - var timeZone = "UTC"; - var query = context.Set().Where(m => m.Timeline == EF.Functions.AtTimeZone(dateTime, timeZone)); - - var missions = async - ? await query.ToListAsync() - : query.ToList(); - - var mission = Assert.Single(missions); - Assert.Equal(3, mission.Id); + await base.Property_access_on_derived_entity_using_cast(async); AssertSql( """ -@dateTime='0010-05-03T12:00:00.0000000' -@timeZone='UTC' (Size = 8000) (DbType = AnsiString) - -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] = @dateTime AT TIME ZONE @timeZone +SELECT [f].[Name], [f].[Eradicated] +FROM [Factions] AS [f] +ORDER BY [f].[Name] """); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - [SqlServerCondition(SqlServerCondition.SupportsSqlClr)] - public virtual async Task Where_AtTimeZone_datetime_column(bool async) + public override async Task Navigation_access_on_derived_entity_using_cast(bool async) { - using var context = CreateContext(); - - var query = context.Set() - .Where(ct => EF.Functions.AtTimeZone(ct.IssueDate, "UTC") == new DateTimeOffset(15, 3, 7, 0, 0, 0, TimeSpan.Zero)); - - var missions = async - ? await query.ToListAsync() - : query.ToList(); - - var mission = Assert.Single(missions); - Assert.Equal(Guid.Parse("A7BE028A-0CF2-448F-AB55-CE8BC5D8CF69"), mission.Id); + await base.Navigation_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[IssueDate] AT TIME ZONE 'UTC' = '0015-03-07T00:00:00.0000000+00:00' +SELECT [f].[Name], [l0].[ThreatLevel] AS [Threat] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name], [l].[ThreatLevel] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +ORDER BY [f].[Name] """); } - public override async Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( - bool async) - { - await base.Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(async); - - AssertSql(); - } - - public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_property(bool async) + public override async Task Navigation_access_on_derived_materialized_entity_using_cast(bool async) { - await base.Complex_predicate_with_AndAlso_and_nullable_bool_property(async); + await base.Navigation_access_on_derived_materialized_entity_using_cast(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] -WHERE [w].[Id] <> 50 AND [g].[HasSoulPatch] = CAST(0 AS bit) +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[ThreatLevel] AS [Threat] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name], [l].[ThreatLevel] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +ORDER BY [f].[Name] """); } - public override async Task Distinct_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) { - await base.Distinct_with_optional_navigation_is_translated_to_sql(async); + await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); AssertSql( """ -SELECT DISTINCT [g].[HasSoulPatch] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +SELECT [f].[Name], [l0].[ThreatLevel] AS [Threat] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name], [l].[ThreatLevel] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +ORDER BY [f].[Name] """); } - public override async Task Sum_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Navigation_access_fk_on_derived_entity_using_cast(bool async) { - await base.Sum_with_optional_navigation_is_translated_to_sql(async); + await base.Navigation_access_fk_on_derived_entity_using_cast(async); AssertSql( """ -SELECT COALESCE(SUM([g].[SquadId]), 0) -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +SELECT [f].[Name], [l0].[Name] AS [CommanderName] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +ORDER BY [f].[Name] """); } - public override async Task Count_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Collection_navigation_access_on_derived_entity_using_cast(bool async) { - await base.Count_with_optional_navigation_is_translated_to_sql(async); + await base.Collection_navigation_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT COUNT(*) -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +SELECT [f].[Name], ( + SELECT COUNT(*) + FROM [LocustLeaders] AS [l] + WHERE [f].[Id] = [l].[LocustHordeId]) AS [LeadersCount] +FROM [Factions] AS [f] +ORDER BY [f].[Name] """); } - public override async Task FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(bool async) + public override async Task Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(bool async) { - await base.FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(async); + await base.Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(async); AssertSql( """ -SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] -WHERE [s].[Name] = N'Kilo' +SELECT [f].[Name], [l].[Name] AS [LeaderName] +FROM [Factions] AS [f] +INNER JOIN [LocustLeaders] AS [l] ON [f].[Id] = [l].[LocustHordeId] +ORDER BY [l].[Name] """); } - public override async Task Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(bool async) + public override async Task Include_on_derived_entity_using_OfType(bool async) { - await base.Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(async); + await base.Include_on_derived_entity_using_OfType(async); AssertSql( """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE NOT EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] - WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +LEFT JOIN [LocustLeaders] AS [l1] ON [f].[Id] = [l1].[LocustHordeId] +ORDER BY [f].[Name], [f].[Id], [l0].[Name] """); } - public override async Task All_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) { - await base.All_with_optional_navigation_is_translated_to_sql(async); + await base.Distinct_on_subquery_doesnt_get_lifted(async); AssertSql( """ -SELECT CASE - WHEN NOT EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] - WHERE [t].[Note] = N'Foo') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [g0].[HasSoulPatch] +FROM ( + SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] +) AS [g0] """); } - public override async Task Contains_with_local_nullable_guid_list_closure(bool async) + public override async Task Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(bool async) { - await base.Contains_with_local_nullable_guid_list_closure(async); + await base.Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(async); AssertSql( """ -@ids='["df36f493-463f-4123-83f9-6b135deeb7ba","23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3","ab1b82d7-88db-42bd-a132-7eef9aa68af4"]' (Size = 4000) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] IN ( - SELECT [i].[value] - FROM OPENJSON(@ids) WITH ([value] uniqueidentifier '$') AS [i] -) +SELECT [f].[Eradicated] +FROM [Factions] AS [f] """); } - public override async Task Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(bool async) + public override async Task Comparing_two_collection_navigations_composite_key(bool async) { - await base.Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(async); + await base.Comparing_two_collection_navigations_composite_key(async); AssertSql( """ -SELECT [g].[FullName] +SELECT [g].[Nickname] AS [Nickname1], [g0].[Nickname] AS [Nickname2] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g].[Rank] +CROSS JOIN [Gears] AS [g0] +WHERE [g].[Nickname] = [g0].[Nickname] AND [g].[SquadId] = [g0].[SquadId] +ORDER BY [g].[Nickname] """); } - public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(bool async) + public override async Task Comparing_two_collection_navigations_inheritance(bool async) { - await base.Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(async); + await base.Comparing_two_collection_navigations_inheritance(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +SELECT [f].[Name], [g0].[Nickname] +FROM [Factions] AS [f] +CROSS JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + WHERE [g].[Discriminator] = N'Officer' +) AS [g0] +LEFT JOIN ( + SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +LEFT JOIN [Gears] AS [g1] ON [l0].[DefeatedByNickname] = [g1].[Nickname] AND [l0].[DefeatedBySquadId] = [g1].[SquadId] +WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) AND [g1].[Nickname] = [g0].[Nickname] AND [g1].[SquadId] = [g0].[SquadId] """); } - public override async Task Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(bool async) + public override async Task Comparing_entities_using_Equals_inheritance(bool async) { - await base.Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(async); + await base.Comparing_entities_using_Equals_inheritance(async); AssertSql( """ -SELECT [g].[FullName] +SELECT [g].[Nickname] AS [Nickname1], [g1].[Nickname] AS [Nickname2] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + WHERE [g0].[Discriminator] = N'Officer' +) AS [g1] +WHERE [g].[Nickname] = [g1].[Nickname] AND [g].[SquadId] = [g1].[SquadId] +ORDER BY [g].[Nickname], [g1].[Nickname] """); } - public override async Task Where_is_properly_lifted_from_subquery_created_by_include(bool async) + public override async Task Contains_on_nullable_array_produces_correct_sql(bool async) { - await base.Where_is_properly_lifted_from_subquery_created_by_include(async); + await base.Contains_on_nullable_array_produces_correct_sql(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +@cities_without_nulls='["Ephyra"]' (Size = 4000) + +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] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [g].[FullName] <> N'Augustus Cole' AND [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +WHERE [g].[SquadId] < 2 AND ([c].[Name] IN ( + SELECT [c0].[value] + FROM OPENJSON(@cities_without_nulls) AS [c0] +) OR [c].[Name] IS NULL) """); } - public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMany(bool async) + public override async Task Optional_navigation_with_collection_composite_key(bool async) { - await base.Subquery_is_lifted_from_main_from_clause_of_SelectMany(async); + await base.Optional_navigation_with_collection_composite_key(async); AssertSql( """ -SELECT [g].[FullName] AS [Name1], [g0].[FullName] AS [Name2] -FROM [Gears] AS [g] -CROSS JOIN [Gears] AS [g0] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [g0].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE [g].[Discriminator] = N'Officer' AND ( + SELECT COUNT(*) + FROM [Gears] AS [g0] + WHERE [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL AND [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[Nickname] = N'Dom') > 0 """); } - public override async Task Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Select_null_conditional_with_inheritance(bool async) { - await base.Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(async); + await base.Select_null_conditional_with_inheritance(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -CROSS JOIN [Tags] AS [t] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g].[FullName] +SELECT CASE + WHEN [f].[CommanderName] IS NOT NULL THEN [f].[CommanderName] +END +FROM [Factions] AS [f] """); } - public override async Task Subquery_containing_join_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Select_null_conditional_with_inheritance_negative(bool async) { - await base.Subquery_containing_join_projecting_main_from_clause_gets_lifted(async); + await base.Select_null_conditional_with_inheritance_negative(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -ORDER BY [g].[Nickname] +SELECT CASE + WHEN [f].[CommanderName] IS NOT NULL THEN [f].[Eradicated] +END +FROM [Factions] AS [f] """); } - public override async Task Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Project_collection_navigation_with_inheritance1(bool async) { - await base.Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(async); + await base.Project_collection_navigation_with_inheritance1(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -ORDER BY [g].[Nickname] +SELECT [f].[Id], [l0].[Name], [f0].[Id], [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +LEFT JOIN [Factions] AS [f0] ON [l0].[Name] = [f0].[CommanderName] +LEFT JOIN [LocustLeaders] AS [l1] ON [f0].[Id] = [l1].[LocustHordeId] +ORDER BY [f].[Id], [l0].[Name], [f0].[Id] """); } - public override async Task Subquery_containing_join_gets_lifted_clashing_names(bool async) + public override async Task Project_collection_navigation_with_inheritance2(bool async) { - await base.Subquery_containing_join_gets_lifted_clashing_names(async); + await base.Project_collection_navigation_with_inheritance2(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -INNER JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] -WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL -ORDER BY [g].[Nickname], [t0].[Id] +SELECT [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] +ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Subquery_created_by_include_gets_lifted_nested(bool async) + public override async Task Project_collection_navigation_with_inheritance3(bool async) { - await base.Subquery_created_by_include_gets_lifted_nested(async); + await base.Project_collection_navigation_with_inheritance3(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation] -FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -WHERE EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) AND [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[Nickname] +SELECT [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] +ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Subquery_is_lifted_from_additional_from_clause(bool async) + public override async Task Include_reference_on_derived_type_using_string(bool async) { - await base.Subquery_is_lifted_from_additional_from_clause(async); + await base.Include_reference_on_derived_type_using_string(async); AssertSql( """ -SELECT [g].[FullName] AS [Name1], [g0].[FullName] AS [Name2] -FROM [Gears] AS [g] -CROSS JOIN [Gears] AS [g0] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [g0].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] """); } - public override async Task Subquery_with_result_operator_is_not_lifted(bool async) + public override async Task Include_reference_on_derived_type_using_string_nested1(bool async) { - await base.Subquery_with_result_operator_is_not_lifted(async); + await base.Include_reference_on_derived_type_using_string_nested1(async); AssertSql( """ -@p='2' - -SELECT [g0].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) - ORDER BY [g].[FullName] -) AS [g0] -ORDER BY [g0].[Rank] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] """); } - public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down(bool async) + public override async Task Include_reference_on_derived_type_using_string_nested2(bool async) { - await base.Skip_with_orderby_followed_by_orderBy_is_pushed_down(async); + await base.Include_reference_on_derived_type_using_string_nested2(async); AssertSql( """ -@p='1' +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Name], [s].[Location], [s].[Nation] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [c].[Name], [c].[Location], [c].[Nation] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] +) AS [s] ON ([g].[Nickname] = [s].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [s].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [s].[LeaderSquadId] +ORDER BY [l].[Name], [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] +"""); + } -SELECT [g0].[FullName] -FROM ( - SELECT [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) - ORDER BY [g].[FullName] - OFFSET @p ROWS -) AS [g0] -ORDER BY [g0].[Rank] -"""); - } - - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) + public override async Task Include_reference_on_derived_type_using_lambda(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); + await base.Include_reference_on_derived_type_using_lambda(async); AssertSql( """ -@p='999' - -SELECT [g0].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -) AS [g0] -ORDER BY [g0].[Rank] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) + public override async Task Include_reference_on_derived_type_using_lambda_with_soft_cast(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); + await base.Include_reference_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( """ -@p='999' - -SELECT [g0].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -) AS [g0] -ORDER BY [g0].[Rank] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) + public override async Task Include_reference_on_derived_type_using_lambda_with_tracking(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); + await base.Include_reference_on_derived_type_using_lambda_with_tracking(async); AssertSql( """ -@p='999' - -SELECT [g0].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -) AS [g0] -ORDER BY [g0].[FullName], [g0].[Rank] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] """); } - public override async Task Select_length_of_string_property(bool async) + public override async Task Include_collection_on_derived_type_using_string(bool async) { - await base.Select_length_of_string_property(async); + await base.Include_collection_on_derived_type_using_string(async); AssertSql( """ -SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] -FROM [Weapons] AS [w] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Client_method_on_collection_navigation_in_outer_join_key(bool async) - { - await base.Client_method_on_collection_navigation_in_outer_join_key(async); - - AssertSql(); - } - - public override async Task Member_access_on_derived_entity_using_cast(bool async) + public override async Task Include_collection_on_derived_type_using_lambda(bool async) { - await base.Member_access_on_derived_entity_using_cast(async); + await base.Include_collection_on_derived_type_using_lambda(async); AssertSql( """ -SELECT [f].[Name], [f].[Eradicated] -FROM [Factions] AS [f] -ORDER BY [f].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Member_access_on_derived_materialized_entity_using_cast(bool async) + public override async Task Include_collection_on_derived_type_using_lambda_with_soft_cast(bool async) { - await base.Member_access_on_derived_materialized_entity_using_cast(async); + await base.Include_collection_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] -FROM [Factions] AS [f] -ORDER BY [f].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Member_access_on_derived_entity_using_cast_and_let(bool async) + public override async Task Include_base_navigation_on_derived_entity(bool async) { - await base.Member_access_on_derived_entity_using_cast_and_let(async); + await base.Include_base_navigation_on_derived_entity(async); AssertSql( """ -SELECT [f].[Name], [f].[Eradicated] -FROM [Factions] AS [f] -ORDER BY [f].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id] """); } - public override async Task Property_access_on_derived_entity_using_cast(bool async) + public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) { - await base.Property_access_on_derived_entity_using_cast(async); + await base.ThenInclude_collection_on_derived_after_base_reference(async); AssertSql( """ -SELECT [f].[Name], [f].[Eradicated] -FROM [Factions] AS [f] -ORDER BY [f].[Name] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId] """); } - public override async Task Navigation_access_on_derived_entity_using_cast(bool async) + public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) { - await base.Navigation_access_on_derived_entity_using_cast(async); + await base.ThenInclude_collection_on_derived_after_derived_reference(async); AssertSql( """ -SELECT [f].[Name], [l0].[ThreatLevel] AS [Threat] +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( - SELECT [l].[Name], [l].[ThreatLevel] + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -ORDER BY [f].[Name] +LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] +ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Navigation_access_on_derived_materialized_entity_using_cast(bool async) + public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) { - await base.Navigation_access_on_derived_materialized_entity_using_cast(async); + await base.ThenInclude_collection_on_derived_after_derived_collection(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[ThreatLevel] AS [Threat] -FROM [Factions] AS [f] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Nickname0], [s].[SquadId0], [s].[AssignedCityName0], [s].[CityOfBirthName0], [s].[Discriminator0], [s].[FullName0], [s].[HasSoulPatch0], [s].[LeaderNickname0], [s].[LeaderSquadId0], [s].[Rank0] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [l].[Name], [l].[ThreatLevel] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -ORDER BY [f].[Name] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g1].[Nickname] AS [Nickname0], [g1].[SquadId] AS [SquadId0], [g1].[AssignedCityName] AS [AssignedCityName0], [g1].[CityOfBirthName] AS [CityOfBirthName0], [g1].[Discriminator] AS [Discriminator0], [g1].[FullName] AS [FullName0], [g1].[HasSoulPatch] AS [HasSoulPatch0], [g1].[LeaderNickname] AS [LeaderNickname0], [g1].[LeaderSquadId] AS [LeaderSquadId0], [g1].[Rank] AS [Rank0] + FROM [Gears] AS [g0] + LEFT JOIN [Gears] AS [g1] ON [g0].[Nickname] = [g1].[LeaderNickname] AND [g0].[SquadId] = [g1].[LeaderSquadId] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[Nickname0] """); } - public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) + public override async Task ThenInclude_reference_on_derived_after_derived_collection(bool async) { - await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); + await base.ThenInclude_reference_on_derived_after_derived_collection(async); AssertSql( """ -SELECT [f].[Name], [l0].[ThreatLevel] AS [Threat] +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [s].[Name], [s].[Discriminator], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator0], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank] FROM [Factions] AS [f] LEFT JOIN ( - SELECT [l].[Name], [l].[ThreatLevel] + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -ORDER BY [f].[Name] + LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +) AS [s] ON [f].[Id] = [s].[LocustHordeId] +ORDER BY [f].[Id], [s].[Name], [s].[Nickname] """); } - public override async Task Navigation_access_fk_on_derived_entity_using_cast(bool async) + public override async Task Multiple_derived_included_on_one_method(bool async) { - await base.Navigation_access_fk_on_derived_entity_using_cast(async); + await base.Multiple_derived_included_on_one_method(async); AssertSql( """ -SELECT [f].[Name], [l0].[Name] AS [CommanderName] +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( - SELECT [l].[Name] + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [l0] ON [f].[CommanderName] = [l0].[Name] -ORDER BY [f].[Name] +LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] +ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Collection_navigation_access_on_derived_entity_using_cast(bool async) + public override async Task Include_on_derived_multi_level(bool async) { - await base.Collection_navigation_access_on_derived_entity_using_cast(async); + await base.Include_on_derived_multi_level(async); AssertSql( """ -SELECT [f].[Name], ( - SELECT COUNT(*) - FROM [LocustLeaders] AS [l] - WHERE [f].[Id] = [l].[LocustHordeId]) AS [LeadersCount] -FROM [Factions] AS [f] -ORDER BY [f].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[Discriminator], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Id], [s1].[Banner], [s1].[Banner5], [s1].[InternalNumber], [s1].[Name], [s1].[SquadId0], [s1].[MissionId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[SquadId] AS [SquadId0], [s0].[MissionId] + FROM [Gears] AS [g0] + INNER JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] + LEFT JOIN [SquadMissions] AS [s0] ON [s].[Id] = [s0].[SquadId] +) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[SquadId0] """); } - public override async Task Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(bool async) + public override async Task Projecting_nullable_bool_in_conditional_works(bool async) { - await base.Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(async); + await base.Projecting_nullable_bool_in_conditional_works(async); AssertSql( """ -SELECT [f].[Name], [l].[Name] AS [LeaderName] -FROM [Factions] AS [f] -INNER JOIN [LocustLeaders] AS [l] ON [f].[Id] = [l].[LocustHordeId] -ORDER BY [l].[Name] +SELECT CASE + WHEN [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL THEN [g].[HasSoulPatch] + ELSE CAST(0 AS bit) +END AS [Prop] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Include_on_derived_entity_using_OfType(bool async) + public override async Task ToString_string_property_projection(bool async) { - await base.Include_on_derived_entity_using_OfType(async); + await base.ToString_string_property_projection(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] -FROM [Factions] AS [f] -LEFT JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -LEFT JOIN [LocustLeaders] AS [l1] ON [f].[Id] = [l1].[LocustHordeId] -ORDER BY [f].[Name], [f].[Id], [l0].[Name] +SELECT [w].[Name] +FROM [Weapons] AS [w] """); } - public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) + public override async Task ToString_boolean_property_non_nullable(bool async) { - await base.Distinct_on_subquery_doesnt_get_lifted(async); + await base.ToString_boolean_property_non_nullable(async); AssertSql( """ -SELECT [g0].[HasSoulPatch] -FROM ( - SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] - FROM [Gears] AS [g] -) AS [g0] +SELECT CASE + WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN N'True' + ELSE N'False' +END +FROM [Weapons] AS [w] """); } - public override async Task Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(bool async) + public override async Task ToString_boolean_property_nullable(bool async) { - await base.Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(async); + await base.ToString_boolean_property_nullable(async); AssertSql( """ -SELECT [f].[Eradicated] +SELECT CASE [f].[Eradicated] + WHEN CAST(0 AS bit) THEN N'False' + WHEN CAST(1 AS bit) THEN N'True' + ELSE N'' +END FROM [Factions] AS [f] """); } - public override async Task Comparing_two_collection_navigations_composite_key(bool async) + [ConditionalTheory(Skip = "Issue #34001 SqlServer never returns null for bool?")] + public override async Task ToString_boolean_computed_nullable(bool async) { - await base.Comparing_two_collection_navigations_composite_key(async); + await base.ToString_boolean_computed_nullable(async); AssertSql( """ -SELECT [g].[Nickname] AS [Nickname1], [g0].[Nickname] AS [Nickname2] -FROM [Gears] AS [g] -CROSS JOIN [Gears] AS [g0] -WHERE [g].[Nickname] = [g0].[Nickname] AND [g].[SquadId] = [g0].[SquadId] -ORDER BY [g].[Nickname] +SELECT CASE CASE + WHEN NOT ([f].[Eradicated] = CAST(1 AS bit) OR ([f].[CommanderName] = N'Unknown' AND [f].[CommanderName] IS NOT NULL)) THEN CAST(0 AS bit) + WHEN [f].[Eradicated] = CAST(1 AS bit) OR ([f].[CommanderName] = N'Unknown' AND [f].[CommanderName] IS NOT NULL) THEN CAST(1 AS bit) +END + WHEN CAST(0 AS bit) THEN N'False' + WHEN CAST(1 AS bit) THEN N'True' + ELSE N'' +END +FROM [Factions] AS [f] """); } - public override async Task Comparing_two_collection_navigations_inheritance(bool async) + public override async Task ToString_enum_property_projection(bool async) { - await base.Comparing_two_collection_navigations_inheritance(async); + await base.ToString_enum_property_projection(async); AssertSql( """ -SELECT [f].[Name], [g0].[Nickname] -FROM [Factions] AS [f] -CROSS JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - WHERE [g].[Discriminator] = N'Officer' -) AS [g0] -LEFT JOIN ( - SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -LEFT JOIN [Gears] AS [g1] ON [l0].[DefeatedByNickname] = [g1].[Nickname] AND [l0].[DefeatedBySquadId] = [g1].[SquadId] -WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) AND [g1].[Nickname] = [g0].[Nickname] AND [g1].[SquadId] = [g0].[SquadId] +SELECT CASE [g].[Rank] + WHEN 0 THEN N'None' + WHEN 1 THEN N'Private' + WHEN 2 THEN N'Corporal' + WHEN 4 THEN N'Sergeant' + WHEN 8 THEN N'Lieutenant' + WHEN 16 THEN N'Captain' + WHEN 32 THEN N'Major' + WHEN 64 THEN N'Colonel' + WHEN 128 THEN N'General' + ELSE CAST([g].[Rank] AS nvarchar(max)) +END +FROM [Gears] AS [g] """); } - public override async Task Comparing_entities_using_Equals_inheritance(bool async) + public override async Task ToString_nullable_enum_property_projection(bool async) { - await base.Comparing_entities_using_Equals_inheritance(async); + await base.ToString_nullable_enum_property_projection(async); AssertSql( """ -SELECT [g].[Nickname] AS [Nickname1], [g1].[Nickname] AS [Nickname2] -FROM [Gears] AS [g] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - WHERE [g0].[Discriminator] = N'Officer' -) AS [g1] -WHERE [g].[Nickname] = [g1].[Nickname] AND [g].[SquadId] = [g1].[SquadId] -ORDER BY [g].[Nickname], [g1].[Nickname] +SELECT CASE [w].[AmmunitionType] + WHEN 1 THEN N'Cartridge' + WHEN 2 THEN N'Shell' + ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') +END +FROM [Weapons] AS [w] """); } - public override async Task Contains_on_nullable_array_produces_correct_sql(bool async) + public override async Task ToString_enum_contains(bool async) { - await base.Contains_on_nullable_array_produces_correct_sql(async); + await base.ToString_enum_contains(async); AssertSql( """ -@cities_without_nulls='["Ephyra"]' (Size = 4000) - -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] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE [g].[SquadId] < 2 AND ([c].[Name] IN ( - SELECT [c0].[value] - FROM OPENJSON(@cities_without_nulls) AS [c0] -) OR [c].[Name] IS NULL) +SELECT [m].[CodeName] +FROM [Missions] AS [m] +WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' """); } - public override async Task Optional_navigation_with_collection_composite_key(bool async) + public override async Task ToString_nullable_enum_contains(bool async) { - await base.Optional_navigation_with_collection_composite_key(async); + await base.ToString_nullable_enum_contains(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Discriminator] = N'Officer' AND ( - SELECT COUNT(*) - FROM [Gears] AS [g0] - WHERE [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL AND [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[Nickname] = N'Dom') > 0 +SELECT [w].[Name] +FROM [Weapons] AS [w] +WHERE CASE [w].[AmmunitionType] + WHEN 1 THEN N'Cartridge' + WHEN 2 THEN N'Shell' + ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') +END LIKE N'%Cart%' """); } - public override async Task Select_null_conditional_with_inheritance(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) { - await base.Select_null_conditional_with_inheritance(async); + await base.Correlated_collections_naked_navigation_with_ToList(async); AssertSql( """ -SELECT CASE - WHEN [f].[CommanderName] IS NOT NULL THEN [f].[CommanderName] -END -FROM [Factions] AS [f] +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Select_null_conditional_with_inheritance_negative(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool async) { - await base.Select_null_conditional_with_inheritance_negative(async); + await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(async); AssertSql( """ -SELECT CASE - WHEN [f].[CommanderName] IS NOT NULL THEN [f].[Eradicated] -END -FROM [Factions] AS [f] +SELECT ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) +FROM [Gears] AS [g] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname] """); } - public override async Task Project_collection_navigation_with_inheritance1(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToArray(bool async) { - await base.Project_collection_navigation_with_inheritance1(async); + await base.Correlated_collections_naked_navigation_with_ToArray(async); AssertSql( """ -SELECT [f].[Id], [l0].[Name], [f0].[Id], [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] -FROM [Factions] AS [f] -LEFT JOIN ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -LEFT JOIN [Factions] AS [f0] ON [l0].[Name] = [f0].[CommanderName] -LEFT JOIN [LocustLeaders] AS [l1] ON [f0].[Id] = [l1].[LocustHordeId] -ORDER BY [f].[Id], [l0].[Name], [f0].[Id] +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Project_collection_navigation_with_inheritance2(bool async) + public override async Task Correlated_collections_basic_projection(bool async) { - await base.Project_collection_navigation_with_inheritance2(async); + await base.Correlated_collections_basic_projection(async); AssertSql( """ -SELECT [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Factions] AS [f] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] -ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Project_collection_navigation_with_inheritance3(bool async) + public override async Task Correlated_collections_basic_projection_explicit_to_list(bool async) { - await base.Project_collection_navigation_with_inheritance3(async); + await base.Correlated_collections_basic_projection_explicit_to_list(async); AssertSql( """ -SELECT [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Factions] AS [f] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] -ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Include_reference_on_derived_type_using_string(bool async) + public override async Task Correlated_collections_basic_projection_explicit_to_array(bool async) { - await base.Include_reference_on_derived_type_using_string(async); + await base.Correlated_collections_basic_projection_explicit_to_array(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Include_reference_on_derived_type_using_string_nested1(bool async) + public override async Task Correlated_collections_basic_projection_ordered(bool async) { - await base.Include_reference_on_derived_type_using_string_nested1(async); + await base.Correlated_collections_basic_projection_ordered(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] -LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] DESC """); } - public override async Task Include_reference_on_derived_type_using_string_nested2(bool async) + public override async Task Correlated_collections_basic_projection_composite_key(bool async) { - await base.Include_reference_on_derived_type_using_string_nested2(async); + await base.Correlated_collections_basic_projection_composite_key(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Name], [s].[Location], [s].[Nation] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[FullName], [g1].[SquadId] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [c].[Name], [c].[Location], [c].[Nation] + SELECT [g0].[Nickname], [g0].[FullName], [g0].[SquadId], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] -) AS [s] ON ([g].[Nickname] = [s].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [s].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [s].[LeaderSquadId] -ORDER BY [l].[Name], [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] + WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) +) AS [g1] ON [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' AND [g].[Nickname] <> N'Foo' +ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] """); } - public override async Task Include_reference_on_derived_type_using_lambda(bool async) + public override async Task Correlated_collections_basic_projecting_single_property(bool async) { - await base.Include_reference_on_derived_type_using_lambda(async); + await base.Correlated_collections_basic_projecting_single_property(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[Id] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Include_reference_on_derived_type_using_lambda_with_soft_cast(bool async) + public override async Task Correlated_collections_basic_projecting_constant(bool async) { - await base.Include_reference_on_derived_type_using_lambda_with_soft_cast(async); + await base.Correlated_collections_basic_projecting_constant(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] -"""); - } - - public override async Task Include_reference_on_derived_type_using_lambda_with_tracking(bool async) - { - await base.Include_reference_on_derived_type_using_lambda_with_tracking(async); - - AssertSql( - """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Include_collection_on_derived_type_using_string(bool async) + public override async Task Correlated_collections_basic_projecting_constant_bool(bool async) { - await base.Include_collection_on_derived_type_using_string(async); + await base.Correlated_collections_basic_projecting_constant_bool(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname] +LEFT JOIN ( + SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Include_collection_on_derived_type_using_lambda(bool async) + public override async Task Correlated_collections_projection_of_collection_thru_navigation(bool async) { - await base.Include_collection_on_derived_type_using_lambda(async); + await base.Correlated_collections_projection_of_collection_thru_navigation(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId], [s1].[MissionId] FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname] +INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +LEFT JOIN ( + SELECT [s0].[SquadId], [s0].[MissionId] + FROM [SquadMissions] AS [s0] + WHERE [s0].[MissionId] <> 17 +) AS [s1] ON [s].[Id] = [s1].[SquadId] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] """); } - public override async Task Include_collection_on_derived_type_using_lambda_with_soft_cast(bool async) + public override async Task Correlated_collections_project_anonymous_collection_result(bool async) { - await base.Include_collection_on_derived_type_using_lambda_with_soft_cast(async); + await base.Correlated_collections_project_anonymous_collection_result(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname] +SELECT [s].[Name], [s].[Id], [g].[FullName], [g].[Rank], [g].[Nickname], [g].[SquadId] +FROM [Squads] AS [s] +LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] +WHERE [s].[Id] < 20 +ORDER BY [s].[Id], [g].[Nickname] """); } - public override async Task Include_base_navigation_on_derived_entity(bool async) + public override async Task Correlated_collections_nested(bool async) { - await base.Include_base_navigation_on_derived_entity(async); + await base.Correlated_collections_nested(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 7 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 42 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) + public override async Task Correlated_collections_nested_mixed_streaming_with_buffer1(bool async) { - await base.ThenInclude_collection_on_derived_after_base_reference(async); + await base.Correlated_collections_nested_mixed_streaming_with_buffer1(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 2 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 3 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) + public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) { - await base.ThenInclude_collection_on_derived_after_derived_reference(async); + await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Factions] AS [f] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] -ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 7 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 42 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) + public override async Task Correlated_collections_nested_with_custom_ordering(bool async) { - await base.ThenInclude_collection_on_derived_after_derived_collection(async); + await base.Correlated_collections_nested_with_custom_ordering(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Nickname0], [s].[SquadId0], [s].[AssignedCityName0], [s].[CityOfBirthName0], [s].[Discriminator0], [s].[FullName0], [s].[HasSoulPatch0], [s].[LeaderNickname0], [s].[LeaderSquadId0], [s].[Rank0] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g1].[Nickname] AS [Nickname0], [g1].[SquadId] AS [SquadId0], [g1].[AssignedCityName] AS [AssignedCityName0], [g1].[CityOfBirthName] AS [CityOfBirthName0], [g1].[Discriminator] AS [Discriminator0], [g1].[FullName] AS [FullName0], [g1].[HasSoulPatch] AS [HasSoulPatch0], [g1].[LeaderNickname] AS [LeaderNickname0], [g1].[LeaderSquadId] AS [LeaderSquadId0], [g1].[Rank] AS [Rank0] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g0].[Rank], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] - LEFT JOIN [Gears] AS [g1] ON [g0].[Nickname] = [g1].[LeaderNickname] AND [g0].[SquadId] = [g1].[LeaderSquadId] + LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] + WHERE [g0].[FullName] <> N'Foo' ) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[Nickname0] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[HasSoulPatch] DESC, [g].[Nickname], [g].[SquadId], [s].[Rank], [s].[Nickname], [s].[SquadId], [s].[IsAutomatic] """); } - public override async Task ThenInclude_reference_on_derived_after_derived_collection(bool async) + public override async Task Correlated_collections_same_collection_projected_multiple_times(bool async) { - await base.ThenInclude_reference_on_derived_after_derived_collection(async); + await base.Correlated_collections_same_collection_projected_multiple_times(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [s].[Name], [s].[Discriminator], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator0], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank] -FROM [Factions] AS [f] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] - FROM [LocustLeaders] AS [l] - LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] -) AS [s] ON [f].[Id] = [s].[LocustHordeId] -ORDER BY [f].[Id], [s].[Name], [s].[Nickname] -"""); - } - - public override async Task Multiple_derived_included_on_one_method(bool async) - { - await base.Multiple_derived_included_on_one_method(async); - - AssertSql( - """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Factions] AS [f] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] LEFT JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -LEFT JOIN [Gears] AS [g] ON [l0].[DefeatedByNickname] = [g].[Nickname] AND [l0].[DefeatedBySquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] -ORDER BY [f].[Id], [l0].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname] + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(1 AS bit) +) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [w1].[Id] """); } - public override async Task Include_on_derived_multi_level(bool async) + public override async Task Correlated_collections_similar_collection_projected_multiple_times(bool async) { - await base.Include_on_derived_multi_level(async); + await base.Correlated_collections_similar_collection_projected_multiple_times(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[Discriminator], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Id], [s1].[Banner], [s1].[Banner5], [s1].[InternalNumber], [s1].[Name], [s1].[SquadId0], [s1].[MissionId] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[SquadId] AS [SquadId0], [s0].[MissionId] - FROM [Gears] AS [g0] - INNER JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] - LEFT JOIN [SquadMissions] AS [s0] ON [s].[Id] = [s0].[SquadId] -) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[SquadId0] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(0 AS bit) +) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +ORDER BY [g].[Rank], [g].[Nickname], [g].[SquadId], [w1].[OwnerFullName], [w1].[Id], [w2].[IsAutomatic] """); } - public override async Task Projecting_nullable_bool_in_conditional_works(bool async) + public override async Task Correlated_collections_different_collections_projected(bool async) { - await base.Projecting_nullable_bool_in_conditional_works(async); + await base.Correlated_collections_different_collections_projected(async); AssertSql( """ -SELECT CASE - WHEN [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL THEN [g].[HasSoulPatch] - ELSE CAST(0 AS bit) -END AS [Prop] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[IsAutomatic], [w0].[Id], [g0].[Nickname], [g0].[Rank], [g0].[SquadId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [w0].[Id], [g0].[FullName], [g0].[Nickname] """); } - public override async Task ToString_string_property_projection(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(bool async) { - await base.ToString_string_property_projection(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); AssertSql( """ -SELECT [w].[Name] -FROM [Weapons] AS [w] +SELECT [g].[FullName] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note] """); } - public override async Task ToString_boolean_property_non_nullable(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) { - await base.ToString_boolean_property_non_nullable(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); AssertSql( """ -SELECT CASE - WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN N'True' - ELSE N'False' -END -FROM [Weapons] AS [w] -"""); - } - - public override async Task ToString_boolean_property_nullable(bool async) - { - await base.ToString_boolean_property_nullable(async); - - AssertSql( - """ -SELECT CASE [f].[Eradicated] - WHEN CAST(0 AS bit) THEN N'False' - WHEN CAST(1 AS bit) THEN N'True' - ELSE N'' -END -FROM [Factions] AS [f] -"""); - } - - [ConditionalTheory(Skip = "Issue #34001 SqlServer never returns null for bool?")] - public override async Task ToString_boolean_computed_nullable(bool async) - { - await base.ToString_boolean_computed_nullable(async); - - AssertSql( - """ -SELECT CASE CASE - WHEN NOT ([f].[Eradicated] = CAST(1 AS bit) OR ([f].[CommanderName] = N'Unknown' AND [f].[CommanderName] IS NOT NULL)) THEN CAST(0 AS bit) - WHEN [f].[Eradicated] = CAST(1 AS bit) OR ([f].[CommanderName] = N'Unknown' AND [f].[CommanderName] IS NOT NULL) THEN CAST(1 AS bit) -END - WHEN CAST(0 AS bit) THEN N'False' - WHEN CAST(1 AS bit) THEN N'True' - ELSE N'' -END -FROM [Factions] AS [f] -"""); - } - - public override async Task ToString_enum_property_projection(bool async) - { - await base.ToString_enum_property_projection(async); - - AssertSql( - """ -SELECT CASE [g].[Rank] - WHEN 0 THEN N'None' - WHEN 1 THEN N'Private' - WHEN 2 THEN N'Corporal' - WHEN 4 THEN N'Sergeant' - WHEN 8 THEN N'Lieutenant' - WHEN 16 THEN N'Captain' - WHEN 32 THEN N'Major' - WHEN 64 THEN N'Colonel' - WHEN 128 THEN N'General' - ELSE CAST([g].[Rank] AS nvarchar(max)) -END -FROM [Gears] AS [g] -"""); - } - - public override async Task ToString_nullable_enum_property_projection(bool async) - { - await base.ToString_nullable_enum_property_projection(async); - - AssertSql( - """ -SELECT CASE [w].[AmmunitionType] - WHEN 1 THEN N'Cartridge' - WHEN 2 THEN N'Shell' - ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') -END -FROM [Weapons] AS [w] -"""); - } - - public override async Task ToString_enum_contains(bool async) - { - await base.ToString_enum_contains(async); - - AssertSql( - """ -SELECT [m].[CodeName] -FROM [Missions] AS [m] -WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' -"""); - } - - public override async Task ToString_nullable_enum_contains(bool async) - { - await base.ToString_nullable_enum_contains(async); - - AssertSql( - """ -SELECT [w].[Name] -FROM [Weapons] AS [w] -WHERE CASE [w].[AmmunitionType] - WHEN 1 THEN N'Cartridge' - WHEN 2 THEN N'Shell' - ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') -END LIKE N'%Cart%' -"""); - } - - public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) - { - await base.Correlated_collections_naked_navigation_with_ToList(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool async) - { - await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(async); - - AssertSql( - """ -SELECT ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) -FROM [Gears] AS [g] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname] -"""); - } - - public override async Task Correlated_collections_naked_navigation_with_ToArray(bool async) - { - await base.Correlated_collections_naked_navigation_with_ToArray(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection(bool async) - { - await base.Correlated_collections_basic_projection(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection_explicit_to_list(bool async) - { - await base.Correlated_collections_basic_projection_explicit_to_list(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection_explicit_to_array(bool async) - { - await base.Correlated_collections_basic_projection_explicit_to_array(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection_ordered(bool async) - { - await base.Correlated_collections_basic_projection_ordered(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] DESC -"""); - } - - public override async Task Correlated_collections_basic_projection_composite_key(bool async) - { - await base.Correlated_collections_basic_projection_composite_key(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[FullName], [g1].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[FullName], [g0].[SquadId], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) -) AS [g1] ON [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' AND [g].[Nickname] <> N'Foo' -ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_basic_projecting_single_property(bool async) - { - await base.Correlated_collections_basic_projecting_single_property(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[Id] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projecting_constant(bool async) - { - await base.Correlated_collections_basic_projecting_constant(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projecting_constant_bool(bool async) - { - await base.Correlated_collections_basic_projecting_constant_bool(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_projection_of_collection_thru_navigation(bool async) - { - await base.Correlated_collections_projection_of_collection_thru_navigation(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId], [s1].[MissionId] -FROM [Gears] AS [g] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId] - FROM [SquadMissions] AS [s0] - WHERE [s0].[MissionId] <> 17 -) AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - - public override async Task Correlated_collections_project_anonymous_collection_result(bool async) - { - await base.Correlated_collections_project_anonymous_collection_result(async); - - AssertSql( - """ -SELECT [s].[Name], [s].[Id], [g].[FullName], [g].[Rank], [g].[Nickname], [g].[SquadId] -FROM [Squads] AS [s] -LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] -WHERE [s].[Id] < 20 -ORDER BY [s].[Id], [g].[Nickname] -"""); - } - - public override async Task Correlated_collections_nested(bool async) - { - await base.Correlated_collections_nested(async); - - AssertSql( - """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 7 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 42 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] -"""); - } - - public override async Task Correlated_collections_nested_mixed_streaming_with_buffer1(bool async) - { - await base.Correlated_collections_nested_mixed_streaming_with_buffer1(async); - - AssertSql( - """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 2 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 3 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] -"""); - } - - public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) - { - await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); - - AssertSql( - """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 7 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 42 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] -"""); - } - - public override async Task Correlated_collections_nested_with_custom_ordering(bool async) - { - await base.Correlated_collections_nested_with_custom_ordering(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g0].[Rank], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] - WHERE [g0].[FullName] <> N'Foo' -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[HasSoulPatch] DESC, [g].[Nickname], [g].[SquadId], [s].[Rank], [s].[Nickname], [s].[SquadId], [s].[IsAutomatic] -"""); - } - - public override async Task Correlated_collections_same_collection_projected_multiple_times(bool async) - { - await base.Correlated_collections_same_collection_projected_multiple_times(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(1 AS bit) -) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w1].[Id] -"""); - } - - public override async Task Correlated_collections_similar_collection_projected_multiple_times(bool async) - { - await base.Correlated_collections_similar_collection_projected_multiple_times(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(0 AS bit) -) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -ORDER BY [g].[Rank], [g].[Nickname], [g].[SquadId], [w1].[OwnerFullName], [w1].[Id], [w2].[IsAutomatic] -"""); - } - - public override async Task Correlated_collections_different_collections_projected(bool async) - { - await base.Correlated_collections_different_collections_projected(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[IsAutomatic], [w0].[Id], [g0].[Nickname], [g0].[Rank], [g0].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [w0].[Id], [g0].[FullName], [g0].[Nickname] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); - - AssertSql( - """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g2].[Nickname], [g2].[SquadId] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] -) AS [s] ON [g1].[FullName] = [s].[OwnerFullName] -WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( - bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g2].[Nickname], [g2].[SquadId] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] -) AS [s] ON [g1].[FullName] = [s].[OwnerFullName] -WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( - bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g2].[Nickname], [g2].[SquadId], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [g2].[FullName] IS NOT NULL AND [g2].[FullName] = [w0].[OwnerFullName]) AS [c] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] -) AS [s] ON [g1].[FullName] = [s].[OwnerFullName] -WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] DESC, [s].[c], [s].[Nickname] -"""); - } - - public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) - { - await base.Correlated_collections_multiple_nested_complex_collections(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Name], [s1].[IsAutomatic], [s1].[Id1], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00], [s2].[Id], [s2].[AmmunitionType], [s2].[IsAutomatic], [s2].[Name], [s2].[OwnerFullName], [s2].[SynergyWithId], [s2].[Nickname], [s2].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] -LEFT JOIN ( - SELECT [g2].[FullName], [g2].[Nickname], [g2].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Name], [s0].[IsAutomatic], [s0].[Id1], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [g2].[Rank], [s0].[IsAutomatic0], [g2].[LeaderNickname], [g2].[LeaderSquadId] - FROM [Gears] AS [g2] - LEFT JOIN ( - SELECT [w].[Id], [g3].[Nickname], [g3].[SquadId], [s].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [g4].[Nickname] AS [Nickname0], [g4].[HasSoulPatch], [g4].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g3] ON [w].[OwnerFullName] = [g3].[FullName] - LEFT JOIN [Squads] AS [s] ON [g3].[SquadId] = [s].[Id] - LEFT JOIN [Weapons] AS [w0] ON [g3].[FullName] = [w0].[OwnerFullName] - LEFT JOIN [Gears] AS [g4] ON [s].[Id] = [g4].[SquadId] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [s0] ON [g2].[FullName] = [s0].[OwnerFullName] - WHERE [g2].[FullName] <> N'Foo' -) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] -LEFT JOIN ( - SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g5].[Nickname], [g5].[SquadId] - FROM [Weapons] AS [w1] - LEFT JOIN [Gears] AS [g5] ON [w1].[OwnerFullName] = [g5].[FullName] -) AS [s2] ON [g1].[FullName] = [s2].[OwnerFullName] -WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s1].[Rank], [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic0], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Id1], [s1].[Nickname00], [s1].[SquadId00], [s2].[IsAutomatic], [s2].[Nickname] DESC, [s2].[Id] -"""); - } - - public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) - { - await base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [g1].[ReportName], [g1].[OfficerName], [g1].[Nickname], [g1].[SquadId] -FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -) AS [g1] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) - { - await base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [g1].[ReportName], [g1].[Nickname], [g1].[SquadId] -FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [g0].[FullName] AS [ReportName], [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g].[FullName] <> N'Foo' -) AS [g1] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) - { - await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - OUTER APPLY ( - SELECT [w].[Name], [g0].[Nickname], [w].[Id] - FROM [Weapons] AS [w] - WHERE [g0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) - ) AS [w0] - WHERE [g0].[FullName] <> N'Foo' -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) - { - await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] -FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[FullName] <> N'Foo' -) AS [s] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_on_select_many(bool async) - { - await base.Correlated_collections_on_select_many(async); - - AssertSql( - """ -SELECT [g].[Nickname], [s].[Name], [g].[SquadId], [s].[Id], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] -FROM [Gears] AS [g] -CROSS JOIN [Squads] AS [s] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) -) AS [g1] ON [s].[Id] = [g1].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g].[Nickname], [s].[Id] DESC, [g].[SquadId], [w0].[Id], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Skip(bool async) - { - await base.Correlated_collections_with_Skip(async); - - AssertSql( - """ -SELECT [s].[Id], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] - FROM [Gears] AS [g] - ) AS [g0] - WHERE 1 < [g0].[row] -) AS [g1] ON [s].[Id] = [g1].[SquadId] -ORDER BY [s].[Name], [s].[Id], [g1].[SquadId], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Take(bool async) - { - await base.Correlated_collections_with_Take(async); - - AssertSql( - """ -SELECT [s].[Id], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] - FROM [Gears] AS [g] - ) AS [g0] - WHERE [g0].[row] <= 2 -) AS [g1] ON [s].[Id] = [g1].[SquadId] -ORDER BY [s].[Name], [s].[Id], [g1].[SquadId], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Distinct(bool async) - { - await base.Correlated_collections_with_Distinct(async); - - AssertSql( - """ -SELECT [s].[Id], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] -FROM [Squads] AS [s] -OUTER APPLY ( - SELECT DISTINCT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM ( - 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 [s].[Id] = [g].[SquadId] - ORDER BY [g].[Nickname] - OFFSET 0 ROWS - ) AS [g0] -) AS [g1] -ORDER BY [s].[Name], [s].[Id], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_FirstOrDefault(bool async) - { - await base.Correlated_collections_with_FirstOrDefault(async); - - AssertSql( - """ -SELECT ( - SELECT TOP(1) [g].[FullName] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] - ORDER BY [g].[Nickname]) -FROM [Squads] AS [s] -ORDER BY [s].[Name] -"""); - } - - public override async Task Correlated_collections_on_left_join_with_predicate(bool async) - { - await base.Correlated_collections_on_left_join_with_predicate(async); - - AssertSql( - """ -SELECT [g].[Nickname], [t].[Id], [g].[SquadId], [w].[Name], [w].[Id] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_on_left_join_with_null_value(bool async) - { - await base.Correlated_collections_on_left_join_with_null_value(async); - - AssertSql( - """ -SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_left_join_with_self_reference(bool async) - { - await base.Correlated_collections_left_join_with_self_reference(async); - - AssertSql( - """ -SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId], [g1].[FullName], [g1].[Nickname], [g1].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - WHERE [g].[Discriminator] = N'Officer' -) AS [g0] ON [t].[GearNickName] = [g0].[Nickname] -LEFT JOIN [Gears] AS [g1] ON ([g0].[Nickname] = [g1].[LeaderNickname] OR ([g0].[Nickname] IS NULL AND [g1].[LeaderNickname] IS NULL)) AND [g0].[SquadId] = [g1].[LeaderSquadId] -ORDER BY [t].[Id], [g0].[Nickname], [g0].[SquadId], [g1].[Nickname] -"""); - } - - public override async Task Correlated_collections_deeply_nested_left_join(bool async) - { - await base.Correlated_collections_deeply_nested_left_join(async); - - AssertSql( - """ -SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] -LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) - ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] - WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) -) AS [s0] ON [s].[Id] = [s0].[SquadId] -ORDER BY [t].[Note], [g].[Nickname] DESC, [t].[Id], [g].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId] -"""); - } - - public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) - { - await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); - - AssertSql( - """ -SELECT [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId], [s0].[Rank] -FROM [Weapons] AS [w] -LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] -LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g0].[Rank], [g0].[FullName] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(0 AS bit) - ) AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -ORDER BY [w].[Name], [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s0].[FullName] DESC, [s0].[Nickname], [s0].[SquadId], [s0].[Id] -"""); - } - - public override async Task Correlated_collections_complex_scenario1(bool async) - { - await base.Correlated_collections_complex_scenario1(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [g1].[Nickname] AS [Nickname0], [g1].[HasSoulPatch], [g1].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] - LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] - LEFT JOIN [Gears] AS [g1] ON [s].[Id] = [g1].[SquadId] -) AS [s0] ON [g].[FullName] = [s0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] -"""); - } - - public override async Task Correlated_collections_complex_scenario2(bool async) - { - await base.Correlated_collections_complex_scenario2(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [g2].[Nickname] AS [Nickname0], [g2].[HasSoulPatch], [g2].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] - LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] - LEFT JOIN [Gears] AS [g2] ON [s].[Id] = [g2].[SquadId] - ) AS [s0] ON [g0].[FullName] = [s0].[OwnerFullName] -) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] -"""); - } - - public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) - { - await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] LEFT JOIN ( - SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [g1].[Nickname] AS [Nickname0], [g1].[HasSoulPatch], [g1].[SquadId] AS [SquadId0], [w].[OwnerFullName] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g2].[Nickname], [g2].[SquadId] FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] - LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] - LEFT JOIN [Gears] AS [g1] ON [s].[Id] = [g1].[SquadId] -) AS [s0] ON [g].[FullName] = [s0].[OwnerFullName] -ORDER BY [g].[FullName], [g].[Nickname] DESC, [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] -"""); - } - - public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) - { - await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [g0].[HasSoulPatch] AS [HasSoulPatch0], [s0].[IsAutomatic], [s0].[Name], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [g2].[Nickname] AS [Nickname0], [g2].[HasSoulPatch], [g2].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] - LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] - LEFT JOIN [Gears] AS [g2] ON [s].[Id] = [g2].[SquadId] - ) AS [s0] ON [g0].[FullName] = [s0].[OwnerFullName] -) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[HasSoulPatch], [g].[LeaderNickname], [g].[FullName], [g].[Nickname], [g].[SquadId], [s1].[FullName], [s1].[HasSoulPatch0] DESC, [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic], [s1].[Name] DESC, [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] -"""); - } - - public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) - { - await base.Correlated_collection_with_top_level_FirstOrDefault(async); - - AssertSql( - """ -SELECT [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[Nickname] -) AS [g0] -LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] -ORDER BY [g0].[Nickname], [g0].[SquadId] -"""); - } - - public override async Task Correlated_collection_with_top_level_Count(bool async) - { - await base.Correlated_collection_with_top_level_Count(async); - - AssertSql( - """ -SELECT COUNT(*) -FROM [Gears] AS [g] -"""); - } - - public override async Task Correlated_collection_with_top_level_Last_with_orderby_on_outer(bool async) - { - await base.Correlated_collection_with_top_level_Last_with_orderby_on_outer(async); - - AssertSql( - """ -SELECT [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[FullName] -) AS [g0] -LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] -ORDER BY [g0].[FullName], [g0].[Nickname], [g0].[SquadId] -"""); - } - - public override async Task Correlated_collection_with_top_level_Last_with_order_by_on_inner(bool async) - { - await base.Correlated_collection_with_top_level_Last_with_order_by_on_inner(async); - - AssertSql( - """ -SELECT [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[FullName] DESC -) AS [g0] -LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] -ORDER BY [g0].[FullName] DESC, [g0].[Nickname], [g0].[SquadId], [w].[Name] -"""); - } - - public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) - { - await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); - - AssertSql( - """ -SELECT [f0].[Id], [f0].[CapitalName], [f0].[Discriminator], [f0].[Name], [f0].[ServerAddress], [f0].[CommanderName], [f0].[Eradicated] -FROM [LocustLeaders] AS [l] -INNER JOIN ( - SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] - FROM [Factions] AS [f] - WHERE [f].[Name] = N'Swarm' -) AS [f0] ON [l].[Name] = [f0].[CommanderName] -WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL -"""); - } - - public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) - { - await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); - - AssertSql( - """ -SELECT [f0].[Id], [f0].[CapitalName], [f0].[Discriminator], [f0].[Name], [f0].[ServerAddress], [f0].[CommanderName], [f0].[Eradicated] -FROM [LocustLeaders] AS [l] -LEFT JOIN ( - SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] - FROM [Factions] AS [f] - WHERE [f].[Name] = N'Swarm' -) AS [f0] ON [l].[Name] = [f0].[CommanderName] -WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL -"""); - } - - public override async Task Include_on_derived_type_with_order_by_and_paging(bool async) - { - await base.Include_on_derived_type_with_order_by_and_paging(async); - - AssertSql( - """ -@p='10' - -SELECT [s].[Name], [s].[Discriminator], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator0], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(@p) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[Note] - FROM [LocustLeaders] AS [l] - LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] - LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName] OR ([g].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([g].[SquadId] = [t].[GearSquadId] OR ([g].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) - ORDER BY [t].[Note] -) AS [s] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [s].[Note], [s].[Name], [s].[Nickname], [s].[SquadId], [s].[Id] -"""); - } - - public override async Task Select_required_navigation_on_derived_type(bool async) - { - await base.Select_required_navigation_on_derived_type(async); - - AssertSql( - """ -SELECT [l0].[Name] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] -"""); - } - - public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) - { - await base.Select_required_navigation_on_the_same_type_with_cast(async); - - AssertSql( - """ -SELECT [c].[Name] -FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] + LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] +) AS [s] ON [g1].[FullName] = [s].[OwnerFullName] +WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] """); } - public override async Task Where_required_navigation_on_derived_type(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( + bool async) { - await base.Where_required_navigation_on_derived_type(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] -WHERE [l0].[IsOperational] = CAST(1 AS bit) +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g2].[Nickname], [g2].[SquadId] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] +) AS [s] ON [g1].[FullName] = [s].[OwnerFullName] +WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] """); } - public override async Task Outer_parameter_in_join_key(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( + bool async) { - await base.Outer_parameter_in_join_key(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] - FROM [Tags] AS [t] - INNER JOIN [Gears] AS [g0] ON [g].[FullName] = [g0].[FullName] -) AS [s] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g2].[Nickname], [g2].[SquadId], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [g2].[FullName] IS NOT NULL AND [g2].[FullName] = [w0].[OwnerFullName]) AS [c] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] +) AS [s] ON [g1].[FullName] = [s].[OwnerFullName] +WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] DESC, [s].[c], [s].[Nickname] """); } - public override async Task Outer_parameter_in_join_key_inner_and_outer(bool async) + public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) { - await base.Outer_parameter_in_join_key_inner_and_outer(async); + await base.Correlated_collections_multiple_nested_complex_collections(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Name], [s1].[IsAutomatic], [s1].[Id1], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00], [s2].[Id], [s2].[AmmunitionType], [s2].[IsAutomatic], [s2].[Name], [s2].[OwnerFullName], [s2].[SynergyWithId], [s2].[Nickname], [s2].[SquadId] FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] - FROM [Tags] AS [t] - INNER JOIN [Gears] AS [g0] ON [g].[FullName] = [g].[Nickname] -) AS [s] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Gears] AS [g1] ON [t].[GearNickName] = [g1].[Nickname] AND [t].[GearSquadId] = [g1].[SquadId] +LEFT JOIN ( + SELECT [g2].[FullName], [g2].[Nickname], [g2].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Name], [s0].[IsAutomatic], [s0].[Id1], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [g2].[Rank], [s0].[IsAutomatic0], [g2].[LeaderNickname], [g2].[LeaderSquadId] + FROM [Gears] AS [g2] + LEFT JOIN ( + SELECT [w].[Id], [g3].[Nickname], [g3].[SquadId], [s].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [g4].[Nickname] AS [Nickname0], [g4].[HasSoulPatch], [g4].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g3] ON [w].[OwnerFullName] = [g3].[FullName] + LEFT JOIN [Squads] AS [s] ON [g3].[SquadId] = [s].[Id] + LEFT JOIN [Weapons] AS [w0] ON [g3].[FullName] = [w0].[OwnerFullName] + LEFT JOIN [Gears] AS [g4] ON [s].[Id] = [g4].[SquadId] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [s0] ON [g2].[FullName] = [s0].[OwnerFullName] + WHERE [g2].[FullName] <> N'Foo' +) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] +LEFT JOIN ( + SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g5].[Nickname], [g5].[SquadId] + FROM [Weapons] AS [w1] + LEFT JOIN [Gears] AS [g5] ON [w1].[OwnerFullName] = [g5].[FullName] +) AS [s2] ON [g1].[FullName] = [s2].[OwnerFullName] +WHERE [g].[Discriminator] = N'Officer' AND EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g1].[Nickname], [g1].[SquadId], [s1].[Rank], [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic0], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Id1], [s1].[Nickname00], [s1].[SquadId00], [s2].[IsAutomatic], [s2].[Nickname] DESC, [s2].[Id] """); } - public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) + public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) { - await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); + await base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [g1].[ReportName], [g1].[OfficerName], [g1].[Nickname], [g1].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] - FROM [Tags] AS [t] - LEFT JOIN [Gears] AS [g0] ON [g].[FullName] = [g0].[FullName] -) AS [s] + SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +) AS [g1] WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] -"""); - } - - public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) - { - await base.Negated_bool_ternary_inside_anonymous_type_in_projection(async); - - AssertSql( - """ -SELECT ~CASE - WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE COALESCE([g].[HasSoulPatch], CAST(1 AS bit)) -END AS [c] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] """); } - public override async Task Order_by_entity_qsre(bool async) + public override async Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) { - await base.Order_by_entity_qsre(async); + await base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async); AssertSql( """ -SELECT [g].[FullName] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [g1].[ReportName], [g1].[Nickname], [g1].[SquadId] FROM [Gears] AS [g] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -ORDER BY [c].[Name], [g].[Nickname] DESC -"""); - } - - public override async Task Order_by_entity_qsre_with_inheritance(bool async) - { - await base.Order_by_entity_qsre_with_inheritance(async); - - AssertSql( - """ -SELECT [l].[Name] -FROM [LocustLeaders] AS [l] -INNER JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] -WHERE [l].[Discriminator] = N'LocustCommander' -ORDER BY [l0].[Id], [l].[Name] -"""); - } - - public override async Task Order_by_entity_qsre_composite_key(bool async) - { - await base.Order_by_entity_qsre_composite_key(async); - - AssertSql( - """ -SELECT [w].[Name] -FROM [Weapons] AS [w] -LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id] -"""); - } - - public override async Task Order_by_entity_qsre_with_other_orderbys(bool async) - { - await base.Order_by_entity_qsre_with_other_orderbys(async); - - AssertSql( - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w].[IsAutomatic], [g].[Nickname] DESC, [g].[SquadId] DESC, [w0].[Id], [w].[Name] -"""); - } - - public override async Task Join_on_entity_qsre_keys(bool async) - { - await base.Join_on_entity_qsre_keys(async); - - AssertSql( - """ -SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] -FROM [Weapons] AS [w] -INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id] +OUTER APPLY ( + SELECT [g0].[FullName] AS [ReportName], [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g].[FullName] <> N'Foo' +) AS [g1] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] """); } - public override async Task Join_on_entity_qsre_keys_composite_key(bool async) + public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) { - await base.Join_on_entity_qsre_keys_composite_key(async); + await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async); AssertSql( """ -SELECT [g].[FullName] AS [GearName1], [g0].[FullName] AS [GearName2] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] FROM [Gears] AS [g] -INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname] AND [g].[SquadId] = [g0].[SquadId] +LEFT JOIN ( + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] + OUTER APPLY ( + SELECT [w].[Name], [g0].[Nickname], [w].[Id] + FROM [Weapons] AS [w] + WHERE [g0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) + ) AS [w0] + WHERE [g0].[FullName] <> N'Foo' +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Join_on_entity_qsre_keys_inheritance(bool async) + public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) { - await base.Join_on_entity_qsre_keys_inheritance(async); + await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async); AssertSql( """ -SELECT [g].[FullName] AS [GearName], [g1].[FullName] AS [OfficerName] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] FROM [Gears] AS [g] -INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] +OUTER APPLY ( + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id] FROM [Gears] AS [g0] - WHERE [g0].[Discriminator] = N'Officer' -) AS [g1] ON [g].[Nickname] = [g1].[Nickname] AND [g].[SquadId] = [g1].[SquadId] -"""); - } - - public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_outer_key_is_navigation(async); - - AssertSql( - """ -SELECT [w].[Name] AS [Name1], [w1].[Name] AS [Name2] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -INNER JOIN [Weapons] AS [w1] ON [w0].[Id] = [w1].[Id] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_inner_key_is_navigation(async); - - AssertSql( - """ -SELECT [c].[Name] AS [CityName], [s].[Nickname] AS [GearNickname] -FROM [Cities] AS [c] -INNER JOIN ( - SELECT [g].[Nickname], [c0].[Name] - FROM [Gears] AS [g] - LEFT JOIN [Cities] AS [c0] ON [g].[AssignedCityName] = [c0].[Name] -) AS [s] ON [c].[Name] = [s].[Name] + LEFT JOIN ( + SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[FullName] <> N'Foo' +) AS [s] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) + public override async Task Correlated_collections_on_select_many(bool async) { - await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); + await base.Correlated_collections_on_select_many(async); AssertSql( """ -SELECT [g].[Nickname], [s].[Note] +SELECT [g].[Nickname], [s].[Name], [g].[SquadId], [s].[Id], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] FROM [Gears] AS [g] -INNER JOIN ( - SELECT [t].[Note], [g0].[Nickname], [g0].[SquadId] - FROM [Tags] AS [t] - LEFT JOIN [Gears] AS [g0] ON [t].[GearNickName] = [g0].[Nickname] AND [t].[GearSquadId] = [g0].[SquadId] - WHERE [t].[Note] IN (N'Cole''s Tag', N'Dom''s Tag') -) AS [s] ON [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] +CROSS JOIN [Squads] AS [s] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) +) AS [g1] ON [s].[Id] = [g1].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g].[Nickname], [s].[Id] DESC, [g].[SquadId], [w0].[Id], [g1].[Nickname] """); } - public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) + public override async Task Correlated_collections_with_Skip(bool async) { - await base.Join_on_entity_qsre_keys_inner_key_is_nested_navigation(async); + await base.Correlated_collections_with_Skip(async); AssertSql( """ -SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] +SELECT [s].[Id], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] FROM [Squads] AS [s] -INNER JOIN ( - SELECT [w].[Name], [s0].[Id] AS [Id0] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] - LEFT JOIN [Squads] AS [s0] ON [g].[SquadId] = [s0].[Id] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [s1] ON [s].[Id] = [s1].[Id0] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] + FROM [Gears] AS [g] + ) AS [g0] + WHERE 1 < [g0].[row] +) AS [g1] ON [s].[Id] = [g1].[SquadId] +ORDER BY [s].[Name], [s].[Id], [g1].[SquadId], [g1].[Nickname] """); } - public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) + public override async Task Correlated_collections_with_Take(bool async) { - await base.GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(async); + await base.Correlated_collections_with_Take(async); AssertSql( """ -SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] +SELECT [s].[Id], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] FROM [Squads] AS [s] LEFT JOIN ( - SELECT [w].[Name], [s0].[Id] AS [Id0] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] - LEFT JOIN [Squads] AS [s0] ON [g].[SquadId] = [s0].[Id] -) AS [s1] ON [s].[Id] = [s1].[Id0] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] + FROM [Gears] AS [g] + ) AS [g0] + WHERE [g0].[row] <= 2 +) AS [g1] ON [s].[Id] = [g1].[SquadId] +ORDER BY [s].[Name], [s].[Id], [g1].[SquadId], [g1].[Nickname] """); } - public override async Task Streaming_correlated_collection_issue_11403(bool async) + public override async Task Correlated_collections_with_Distinct(bool async) { - await base.Streaming_correlated_collection_issue_11403(async); + await base.Correlated_collections_with_Distinct(async); AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[Nickname] -) AS [g0] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(0 AS bit) -) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] -ORDER BY [g0].[Nickname], [g0].[SquadId], [w0].[Id] +SELECT [s].[Id], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] +FROM [Squads] AS [s] +OUTER APPLY ( + SELECT DISTINCT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM ( + 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 [s].[Id] = [g].[SquadId] + ORDER BY [g].[Nickname] + OFFSET 0 ROWS + ) AS [g0] +) AS [g1] +ORDER BY [s].[Name], [s].[Id], [g1].[Nickname] """); } - public override async Task Project_one_value_type_from_empty_collection(bool async) + public override async Task Correlated_collections_with_FirstOrDefault(bool async) { - await base.Project_one_value_type_from_empty_collection(async); + await base.Correlated_collections_with_FirstOrDefault(async); AssertSql( """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) [g].[SquadId] +SELECT ( + SELECT TOP(1) [g].[FullName] FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] + WHERE [s].[Id] = [g].[SquadId] + ORDER BY [g].[Nickname]) FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' +ORDER BY [s].[Name] """); } - public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) + public override async Task Correlated_collections_on_left_join_with_predicate(bool async) { - await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); + await base.Correlated_collections_on_left_join_with_predicate(async); AssertSql( """ -SELECT [s].[Name], ( - SELECT TOP(1) [g].[SquadId] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' +SELECT [g].[Nickname], [t].[Id], [g].[SquadId], [w].[Name], [w].[Id] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId] """); } - public override async Task Project_one_value_type_with_client_projection_from_empty_collection(bool async) + public override async Task Correlated_collections_on_left_join_with_null_value(bool async) { - await base.Project_one_value_type_with_client_projection_from_empty_collection(async); + await base.Correlated_collections_on_left_join_with_null_value(async); AssertSql( """ -SELECT [s].[Name], [g1].[SquadId], [g1].[LeaderSquadId], [g1].[c] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g0].[SquadId], [g0].[LeaderSquadId], [g0].[c] - FROM ( - SELECT [g].[SquadId], [g].[LeaderSquadId], 1 AS [c], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [g0] - WHERE [g0].[row] <= 1 -) AS [g1] ON [s].[Id] = [g1].[SquadId] -WHERE [s].[Name] = N'Kilo' +SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId] """); } - public override async Task Filter_on_subquery_projecting_one_value_type_from_empty_collection(bool async) + public override async Task Correlated_collections_left_join_with_self_reference(bool async) { - await base.Filter_on_subquery_projecting_one_value_type_from_empty_collection(async); + await base.Correlated_collections_left_join_with_self_reference(async); AssertSql( """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' AND COALESCE(( - SELECT TOP(1) [g].[SquadId] +SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId], [g1].[FullName], [g1].[Nickname], [g1].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 + WHERE [g].[Discriminator] = N'Officer' +) AS [g0] ON [t].[GearNickName] = [g0].[Nickname] +LEFT JOIN [Gears] AS [g1] ON ([g0].[Nickname] = [g1].[LeaderNickname] OR ([g0].[Nickname] IS NULL AND [g1].[LeaderNickname] IS NULL)) AND [g0].[SquadId] = [g1].[LeaderSquadId] +ORDER BY [t].[Id], [g0].[Nickname], [g0].[SquadId], [g1].[Nickname] """); } - public override async Task Select_subquery_projecting_single_constant_int(bool async) + public override async Task Correlated_collections_deeply_nested_left_join(bool async) { - await base.Select_subquery_projecting_single_constant_int(async); + await base.Correlated_collections_deeply_nested_left_join(async); AssertSql( """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) 42 - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] -FROM [Squads] AS [s] +SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] +LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) + ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] + WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) +) AS [s0] ON [s].[Id] = [s0].[SquadId] +ORDER BY [t].[Note], [g].[Nickname] DESC, [t].[Id], [g].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId] """); } - public override async Task Select_subquery_projecting_single_constant_string(bool async) + public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) { - await base.Select_subquery_projecting_single_constant_string(async); + await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); AssertSql( """ -SELECT [s].[Name], ( - SELECT TOP(1) N'Foo' - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] -FROM [Squads] AS [s] +SELECT [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId], [s0].[Rank] +FROM [Weapons] AS [w] +LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] +LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g0].[Rank], [g0].[FullName] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(0 AS bit) + ) AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +ORDER BY [w].[Name], [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s0].[FullName] DESC, [s0].[Nickname], [s0].[SquadId], [s0].[Id] """); } - public override async Task Select_subquery_projecting_single_constant_bool(bool async) + public override async Task Correlated_collections_complex_scenario1(bool async) { - await base.Select_subquery_projecting_single_constant_bool(async); + await base.Correlated_collections_complex_scenario1(async); AssertSql( """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) CAST(1 AS bit) - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] -FROM [Squads] AS [s] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [g1].[Nickname] AS [Nickname0], [g1].[HasSoulPatch], [g1].[SquadId] AS [SquadId0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] + LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] + LEFT JOIN [Gears] AS [g1] ON [s].[Id] = [g1].[SquadId] +) AS [s0] ON [g].[FullName] = [s0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] """); } - public override async Task Select_subquery_projecting_single_constant_inside_anonymous(bool async) + public override async Task Correlated_collections_complex_scenario2(bool async) { - await base.Select_subquery_projecting_single_constant_inside_anonymous(async); + await base.Correlated_collections_complex_scenario2(async); AssertSql( """ -SELECT [s].[Name], [g1].[One] -FROM [Squads] AS [s] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g0].[One], [g0].[SquadId] - FROM ( - SELECT 1 AS [One], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [g0] - WHERE [g0].[row] <= 1 -) AS [g1] ON [s].[Id] = [g1].[SquadId] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [g2].[Nickname] AS [Nickname0], [g2].[HasSoulPatch], [g2].[SquadId] AS [SquadId0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] + LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] + LEFT JOIN [Gears] AS [g2] ON [s].[Id] = [g2].[SquadId] + ) AS [s0] ON [g0].[FullName] = [s0].[OwnerFullName] +) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] """); } - public override async Task Select_subquery_projecting_multiple_constants_inside_anonymous(bool async) + public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) { - await base.Select_subquery_projecting_multiple_constants_inside_anonymous(async); + await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); AssertSql( """ -SELECT [s].[Name], [g1].[True1], [g1].[False1], [g1].[c] -FROM [Squads] AS [s] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g0].[True1], [g0].[False1], [g0].[c], [g0].[SquadId] - FROM ( - SELECT CAST(1 AS bit) AS [True1], CAST(0 AS bit) AS [False1], 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [g0] - WHERE [g0].[row] <= 1 -) AS [g1] ON [s].[Id] = [g1].[SquadId] + SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [g1].[Nickname] AS [Nickname0], [g1].[HasSoulPatch], [g1].[SquadId] AS [SquadId0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] + LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] + LEFT JOIN [Gears] AS [g1] ON [s].[Id] = [g1].[SquadId] +) AS [s0] ON [g].[FullName] = [s0].[OwnerFullName] +ORDER BY [g].[FullName], [g].[Nickname] DESC, [g].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] """); } - public override async Task Include_with_order_by_constant(bool async) + public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) { - await base.Include_with_order_by_constant(async); + await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [Squads] AS [s] -LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] -ORDER BY [s].[Id], [g].[Nickname] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [g0].[HasSoulPatch] AS [HasSoulPatch0], [s0].[IsAutomatic], [s0].[Name], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [g2].[Nickname] AS [Nickname0], [g2].[HasSoulPatch], [g2].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] + LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] + LEFT JOIN [Gears] AS [g2] ON [s].[Id] = [g2].[SquadId] + ) AS [s0] ON [g0].[FullName] = [s0].[OwnerFullName] +) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[HasSoulPatch], [g].[LeaderNickname], [g].[FullName], [g].[Nickname], [g].[SquadId], [s1].[FullName], [s1].[HasSoulPatch0] DESC, [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic], [s1].[Name] DESC, [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] """); } - public override async Task Correlated_collection_order_by_constant(bool async) + public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) { - await base.Correlated_collection_order_by_constant(async); + await base.Correlated_collection_with_top_level_FirstOrDefault(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId] +SELECT [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[Nickname] +) AS [g0] +LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] +ORDER BY [g0].[Nickname], [g0].[SquadId] """); } - public override async Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool async) + public override async Task Correlated_collection_with_top_level_Count(bool async) { - await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(async); + await base.Correlated_collection_with_top_level_Count(async); AssertSql( """ -SELECT [s].[Name], [g1].[c] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g0].[c], [g0].[SquadId] - FROM ( - SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [g0] - WHERE [g0].[row] <= 1 -) AS [g1] ON [s].[Id] = [g1].[SquadId] +SELECT COUNT(*) +FROM [Gears] AS [g] """); } - public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool async) + public override async Task Correlated_collection_with_top_level_Last_with_orderby_on_outer(bool async) { - await base.Select_subquery_projecting_single_constant_of_non_mapped_type(async); + await base.Correlated_collection_with_top_level_Last_with_orderby_on_outer(async); AssertSql( """ -SELECT [s].[Name], [g1].[c] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g0].[c], [g0].[SquadId] - FROM ( - SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [g0] - WHERE [g0].[row] <= 1 -) AS [g1] ON [s].[Id] = [g1].[SquadId] +SELECT [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[FullName] +) AS [g0] +LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] +ORDER BY [g0].[FullName], [g0].[Nickname], [g0].[SquadId] """); } - public override async Task Include_collection_OrderBy_aggregate(bool async) + public override async Task Correlated_collection_with_top_level_Last_with_order_by_on_inner(bool async) { - await base.Include_collection_OrderBy_aggregate(async); + await base.Correlated_collection_with_top_level_Last_with_order_by_on_inner(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [g0].[Nickname] +SELECT [g0].[Nickname], [g0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[FullName] DESC +) AS [g0] +LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] +ORDER BY [g0].[FullName] DESC, [g0].[Nickname], [g0].[SquadId], [w].[Name] """); } - public override async Task Include_collection_with_complex_OrderBy2(bool async) + public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) { - await base.Include_collection_with_complex_OrderBy2(async); + await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), [g].[Nickname], [g].[SquadId], [g0].[Nickname] +SELECT [f0].[Id], [f0].[CapitalName], [f0].[Discriminator], [f0].[Name], [f0].[ServerAddress], [f0].[CommanderName], [f0].[Eradicated] +FROM [LocustLeaders] AS [l] +INNER JOIN ( + SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] + FROM [Factions] AS [f] + WHERE [f].[Name] = N'Swarm' +) AS [f0] ON [l].[Name] = [f0].[CommanderName] +WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL """); } - public override async Task Include_collection_with_complex_OrderBy3(bool async) + public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) { - await base.Include_collection_with_complex_OrderBy3(async); + await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)), [g].[Nickname], [g].[SquadId], [g0].[Nickname] +SELECT [f0].[Id], [f0].[CapitalName], [f0].[Discriminator], [f0].[Name], [f0].[ServerAddress], [f0].[CommanderName], [f0].[Eradicated] +FROM [LocustLeaders] AS [l] +LEFT JOIN ( + SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] + FROM [Factions] AS [f] + WHERE [f].[Name] = N'Swarm' +) AS [f0] ON [l].[Name] = [f0].[CommanderName] +WHERE [f0].[Eradicated] = CAST(0 AS bit) OR [f0].[Eradicated] IS NULL """); } - public override async Task Correlated_collection_with_complex_OrderBy(bool async) + public override async Task Include_on_derived_type_with_order_by_and_paging(bool async) { - await base.Correlated_collection_with_complex_OrderBy(async); + await base.Include_on_derived_type_with_order_by_and_paging(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) -) AS [g1] ON [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [g1].[Nickname] +@p='10' + +SELECT [s].[Name], [s].[Discriminator], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator0], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(@p) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[Note] + FROM [LocustLeaders] AS [l] + LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] + LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName] OR ([g].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([g].[SquadId] = [t].[GearSquadId] OR ([g].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) + ORDER BY [t].[Note] +) AS [s] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [s].[Note], [s].[Name], [s].[Nickname], [s].[SquadId], [s].[Id] """); } - public override async Task Correlated_collection_with_very_complex_order_by(bool async) + public override async Task Select_required_navigation_on_derived_type(bool async) { - await base.Correlated_collection_with_very_complex_order_by(async); + await base.Select_required_navigation_on_derived_type(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g2].[Nickname], [g2].[SquadId], [g2].[AssignedCityName], [g2].[CityOfBirthName], [g2].[Discriminator], [g2].[FullName], [g2].[HasSoulPatch], [g2].[LeaderNickname], [g2].[LeaderSquadId], [g2].[Rank] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] - FROM [Gears] AS [g1] - WHERE [g1].[HasSoulPatch] = CAST(0 AS bit) -) AS [g2] ON [g].[Nickname] = [g2].[LeaderNickname] AND [g].[SquadId] = [g2].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( - SELECT TOP(1) [g0].[HasSoulPatch] - FROM [Gears] AS [g0] - WHERE [g0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [g].[Nickname], [g].[SquadId], [g2].[Nickname] +SELECT [l0].[Name] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] """); } - public override async Task Cast_to_derived_type_after_OfType_works(bool async) + public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) { - await base.Cast_to_derived_type_after_OfType_works(async); + await base.Select_required_navigation_on_the_same_type_with_cast(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [c].[Name] FROM [Gears] AS [g] -WHERE [g].[Discriminator] = N'Officer' +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] """); } - public override async Task Select_subquery_boolean(bool async) + public override async Task Where_required_navigation_on_derived_type(bool async) { - await base.Select_subquery_boolean(async); + await base.Where_required_navigation_on_derived_type(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)) -FROM [Gears] AS [g] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] +WHERE [l0].[IsOperational] = CAST(1 AS bit) """); } - public override async Task Select_subquery_boolean_with_pushdown(bool async) + public override async Task Outer_parameter_in_join_key(bool async) { - await base.Select_subquery_boolean_with_pushdown(async); - - AssertSql( - """ -SELECT ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) + await base.Outer_parameter_in_join_key(async); + + AssertSql( + """ +SELECT [g].[Nickname], [g].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] FROM [Gears] AS [g] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] + FROM [Tags] AS [t] + INNER JOIN [Gears] AS [g0] ON [g].[FullName] = [g0].[FullName] +) AS [s] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) + public override async Task Outer_parameter_in_join_key_inner_and_outer(bool async) { - await base.Select_subquery_int_with_inside_cast_and_coalesce(async); + await base.Outer_parameter_in_join_key_inner_and_outer(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 42) +SELECT [g].[Nickname], [g].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] FROM [Gears] AS [g] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] + FROM [Tags] AS [t] + INNER JOIN [Gears] AS [g0] ON [g].[FullName] = [g].[Nickname] +) AS [s] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bool async) + public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) { - await base.Select_subquery_int_with_outside_cast_and_coalesce(async); + await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 0) +SELECT [g].[Nickname], [g].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] FROM [Gears] AS [g] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] + FROM [Tags] AS [t] + LEFT JOIN [Gears] AS [g0] ON [g].[FullName] = [g0].[FullName] +) AS [s] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool async) + public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) { - await base.Select_subquery_int_with_pushdown_and_coalesce(async); + await base.Negated_bool_ternary_inside_anonymous_type_in_projection(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 42) -FROM [Gears] AS [g] +SELECT ~CASE + WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE COALESCE([g].[HasSoulPatch], CAST(1 AS bit)) +END AS [c] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool async) + public override async Task Order_by_entity_qsre(bool async) { - await base.Select_subquery_int_with_pushdown_and_coalesce2(async); + await base.Order_by_entity_qsre(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), ( - SELECT TOP(1) [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ORDER BY [w0].[Id])) +SELECT [g].[FullName] FROM [Gears] AS [g] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +ORDER BY [c].[Name], [g].[Nickname] DESC """); } - public override async Task Select_subquery_boolean_empty(bool async) + public override async Task Order_by_entity_qsre_with_inheritance(bool async) { - await base.Select_subquery_boolean_empty(async); + await base.Order_by_entity_qsre_with_inheritance(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ORDER BY [w].[Id]), CAST(0 AS bit)) -FROM [Gears] AS [g] +SELECT [l].[Name] +FROM [LocustLeaders] AS [l] +INNER JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] +WHERE [l].[Discriminator] = N'LocustCommander' +ORDER BY [l0].[Id], [l].[Name] """); } - public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) + public override async Task Order_by_entity_qsre_composite_key(bool async) { - await base.Select_subquery_boolean_empty_with_pushdown(async); + await base.Order_by_entity_qsre_composite_key(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ORDER BY [w].[Id]) -FROM [Gears] AS [g] +SELECT [w].[Name] +FROM [Weapons] AS [w] +LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] +ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) + public override async Task Order_by_entity_qsre_with_other_orderbys(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean1(async); + await base.Order_by_entity_qsre_with_other_orderbys(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]), CAST(0 AS bit)) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w].[IsAutomatic], [g].[Nickname] DESC, [g].[SquadId] DESC, [w0].[Id], [w].[Name] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean2(bool async) + public override async Task Join_on_entity_qsre_keys(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean2(async); + await base.Join_on_entity_qsre_keys(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] +FROM [Weapons] AS [w] +INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) + public override async Task Join_on_entity_qsre_keys_composite_key(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_with_pushdown(async); + await base.Join_on_entity_qsre_keys_composite_key(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]) +SELECT [g].[FullName] AS [GearName1], [g0].[FullName] AS [GearName2] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname] AND [g].[SquadId] = [g0].[SquadId] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty1(bool async) + public override async Task Join_on_entity_qsre_keys_inheritance(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty1(async); + await base.Join_on_entity_qsre_keys_inheritance(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ) AS [w0]), CAST(0 AS bit)) +SELECT [g].[FullName] AS [GearName], [g1].[FullName] AS [OfficerName] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +INNER JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + WHERE [g0].[Discriminator] = N'Officer' +) AS [g1] ON [g].[Nickname] = [g1].[Nickname] AND [g].[SquadId] = [g1].[SquadId] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty2(bool async) + public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty2(async); + await base.Join_on_entity_qsre_keys_outer_key_is_navigation(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG'), CAST(0 AS bit)) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [w].[Name] AS [Name1], [w1].[Name] AS [Name2] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +INNER JOIN [Weapons] AS [w1] ON [w0].[Id] = [w1].[Id] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); + await base.Join_on_entity_qsre_keys_inner_key_is_navigation(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ) AS [w0]) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [c].[Name] AS [CityName], [s].[Nickname] AS [GearNickname] +FROM [Cities] AS [c] +INNER JOIN ( + SELECT [g].[Nickname], [c0].[Name] + FROM [Gears] AS [g] + LEFT JOIN [Cities] AS [c0] ON [g].[AssignedCityName] = [c0].[Name] +) AS [s] ON [c].[Name] = [s].[Name] """); } - public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) { - await base.Cast_subquery_to_base_type_using_typed_ToList(async); + await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); AssertSql( """ -SELECT [c].[Name], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId] -FROM [Cities] AS [c] -LEFT JOIN [Gears] AS [g] ON [c].[Name] = [g].[AssignedCityName] -WHERE [c].[Name] = N'Ephyra' -ORDER BY [c].[Name], [g].[Nickname] +SELECT [g].[Nickname], [s].[Note] +FROM [Gears] AS [g] +INNER JOIN ( + SELECT [t].[Note], [g0].[Nickname], [g0].[SquadId] + FROM [Tags] AS [t] + LEFT JOIN [Gears] AS [g0] ON [t].[GearNickName] = [g0].[Nickname] AND [t].[GearSquadId] = [g0].[SquadId] + WHERE [t].[Note] IN (N'Cole''s Tag', N'Dom''s Tag') +) AS [s] ON [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] """); } - public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArray(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { - await base.Cast_ordered_subquery_to_base_type_using_typed_ToArray(async); + await base.Join_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( """ -SELECT [c].[Name], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId] -FROM [Cities] AS [c] -LEFT JOIN [Gears] AS [g] ON [c].[Name] = [g].[AssignedCityName] -WHERE [c].[Name] = N'Ephyra' -ORDER BY [c].[Name], [g].[Nickname] DESC +SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] +FROM [Squads] AS [s] +INNER JOIN ( + SELECT [w].[Name], [s0].[Id] AS [Id0] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] + LEFT JOIN [Squads] AS [s0] ON [g].[SquadId] = [s0].[Id] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [s1] ON [s].[Id] = [s1].[Id0] """); } - public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) + public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { - await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); + await base.GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( """ -@nicknames='[]' (Size = 4000) - -SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY CASE - WHEN [g].[Nickname] IN ( - SELECT [n].[value] - FROM OPENJSON(@nicknames) WITH ([value] nvarchar(450) '$') AS [n] - ) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END DESC, [g].[Nickname], [g].[SquadId] +SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [w].[Name], [s0].[Id] AS [Id0] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] + LEFT JOIN [Squads] AS [s0] ON [g].[SquadId] = [s0].[Id] +) AS [s1] ON [s].[Id] = [s1].[Id0] """); } - public override async Task Double_order_by_on_nullable_bool_coming_from_optional_navigation(bool async) + public override async Task Streaming_correlated_collection_issue_11403(bool async) { - await base.Double_order_by_on_nullable_bool_coming_from_optional_navigation(async); + await base.Streaming_correlated_collection_issue_11403(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w0].[IsAutomatic], [w0].[Id] +SELECT [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[Nickname] +) AS [g0] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(0 AS bit) +) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] +ORDER BY [g0].[Nickname], [g0].[SquadId], [w0].[Id] """); } - public override async Task Double_order_by_on_Like(bool async) + public override async Task Project_one_value_type_from_empty_collection(bool async) { - await base.Double_order_by_on_Like(async); + await base.Project_one_value_type_from_empty_collection(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] LIKE N'%Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Double_order_by_on_is_null(bool async) + public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) { - await base.Double_order_by_on_is_null(async); + await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [s].[Name], ( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Double_order_by_on_string_compare(bool async) + public override async Task Project_one_value_type_with_client_projection_from_empty_collection(bool async) { - await base.Double_order_by_on_string_compare(async); + await base.Project_one_value_type_with_client_projection_from_empty_collection(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -ORDER BY CASE - WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w].[Id] +SELECT [s].[Name], [g1].[SquadId], [g1].[LeaderSquadId], [g1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g0].[SquadId], [g0].[LeaderSquadId], [g0].[c] + FROM ( + SELECT [g].[SquadId], [g].[LeaderSquadId], 1 AS [c], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [g0] + WHERE [g0].[row] <= 1 +) AS [g1] ON [s].[Id] = [g1].[SquadId] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Double_order_by_binary_expression(bool async) + public override async Task Filter_on_subquery_projecting_one_value_type_from_empty_collection(bool async) { - await base.Double_order_by_binary_expression(async); + await base.Filter_on_subquery_projecting_one_value_type_from_empty_collection(async); AssertSql( """ -SELECT [w].[Id] + 2 AS [Binary] -FROM [Weapons] AS [w] -ORDER BY [w].[Id] + 2 +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' AND COALESCE(( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 """); } - public override async Task String_compare_with_null_conditional_argument(bool async) + public override async Task Select_subquery_projecting_single_constant_int(bool async) { - await base.String_compare_with_null_conditional_argument(async); + await base.Select_subquery_projecting_single_constant_int(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) 42 + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task String_compare_with_null_conditional_argument2(bool async) + public override async Task Select_subquery_projecting_single_constant_string(bool async) { - await base.String_compare_with_null_conditional_argument2(async); + await base.Select_subquery_projecting_single_constant_string(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [s].[Name], ( + SELECT TOP(1) N'Foo' + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task String_concat_with_null_conditional_argument(bool async) + public override async Task Select_subquery_projecting_single_constant_bool(bool async) { - await base.String_concat_with_null_conditional_argument(async); + await base.Select_subquery_projecting_single_constant_bool(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY COALESCE([w0].[Name], N'') + CAST(5 AS nvarchar(max)) +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) CAST(1 AS bit) + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task String_concat_with_null_conditional_argument2(bool async) + public override async Task Select_subquery_projecting_single_constant_inside_anonymous(bool async) { - await base.String_concat_with_null_conditional_argument2(async); + await base.Select_subquery_projecting_single_constant_inside_anonymous(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY COALESCE([w0].[Name], N'') + N'Marcus'' Lancer' +SELECT [s].[Name], [g1].[One] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g0].[One], [g0].[SquadId] + FROM ( + SELECT 1 AS [One], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [g0] + WHERE [g0].[row] <= 1 +) AS [g1] ON [s].[Id] = [g1].[SquadId] """); } - public override async Task String_concat_on_various_types(bool async) + public override async Task Select_subquery_projecting_multiple_constants_inside_anonymous(bool async) { - await base.String_concat_on_various_types(async); + await base.Select_subquery_projecting_multiple_constants_inside_anonymous(async); AssertSql( """ -SELECT N'HasSoulPatch ' + CAST([g].[HasSoulPatch] AS nvarchar(max)) + N' HasSoulPatch' AS [HasSoulPatch], N'Rank ' + CAST([g].[Rank] AS nvarchar(max)) + N' Rank' AS [Rank], N'SquadId ' + CAST([g].[SquadId] AS nvarchar(max)) + N' SquadId' AS [SquadId], N'Rating ' + COALESCE(CAST([m].[Rating] AS nvarchar(max)), N'') + N' Rating' AS [Rating], N'Timeline ' + CAST([m].[Timeline] AS nvarchar(max)) + N' Timeline' AS [Timeline] -FROM [Gears] AS [g] -CROSS JOIN [Missions] AS [m] -ORDER BY [g].[Nickname], [m].[Id] +SELECT [s].[Name], [g1].[True1], [g1].[False1], [g1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g0].[True1], [g0].[False1], [g0].[c], [g0].[SquadId] + FROM ( + SELECT CAST(1 AS bit) AS [True1], CAST(0 AS bit) AS [False1], 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [g0] + WHERE [g0].[row] <= 1 +) AS [g1] ON [s].[Id] = [g1].[SquadId] """); } - public override async Task Time_of_day_datetimeoffset(bool async) + public override async Task Include_with_order_by_constant(bool async) { - await base.Time_of_day_datetimeoffset(async); + await base.Include_with_order_by_constant(async); AssertSql( """ -SELECT CONVERT(time, [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [Squads] AS [s] +LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] +ORDER BY [s].[Id], [g].[Nickname] """); } - public override async Task GroupBy_Property_Include_Select_Average(bool async) + public override async Task Correlated_collection_order_by_constant(bool async) { - await base.GroupBy_Property_Include_Select_Average(async); + await base.Correlated_collection_order_by_constant(async); AssertSql( """ -SELECT AVG(CAST([g].[SquadId] AS float)) +SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] FROM [Gears] AS [g] -GROUP BY [g].[Rank] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task GroupBy_Property_Include_Select_Sum(bool async) + public override async Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool async) { - await base.GroupBy_Property_Include_Select_Sum(async); + await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(async); AssertSql( """ -SELECT COALESCE(SUM([g].[SquadId]), 0) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Name], [g1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g0].[c], [g0].[SquadId] + FROM ( + SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [g0] + WHERE [g0].[row] <= 1 +) AS [g1] ON [s].[Id] = [g1].[SquadId] """); } - public override async Task GroupBy_Property_Include_Select_Count(bool async) + public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool async) { - await base.GroupBy_Property_Include_Select_Count(async); + await base.Select_subquery_projecting_single_constant_of_non_mapped_type(async); AssertSql( """ -SELECT COUNT(*) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Name], [g1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g0].[c], [g0].[SquadId] + FROM ( + SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [g0] + WHERE [g0].[row] <= 1 +) AS [g1] ON [s].[Id] = [g1].[SquadId] """); } - public override async Task GroupBy_Property_Include_Select_LongCount(bool async) + public override async Task Include_collection_OrderBy_aggregate(bool async) { - await base.GroupBy_Property_Include_Select_LongCount(async); + await base.Include_collection_OrderBy_aggregate(async); AssertSql( """ -SELECT COUNT_BIG(*) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] -GROUP BY [g].[Rank] +LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task GroupBy_Property_Include_Select_Min(bool async) + public override async Task Include_collection_with_complex_OrderBy2(bool async) { - await base.GroupBy_Property_Include_Select_Min(async); + await base.Include_collection_with_complex_OrderBy2(async); AssertSql( """ -SELECT MIN([g].[SquadId]) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] -GROUP BY [g].[Rank] +LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(bool async) + public override async Task Include_collection_with_complex_OrderBy3(bool async) { - await base.GroupBy_Property_Include_Aggregate_with_anonymous_selector(async); + await base.Include_collection_with_complex_OrderBy3(async); AssertSql( """ -SELECT [g].[Nickname] AS [Key], COUNT(*) AS [c] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] -GROUP BY [g].[Nickname] -ORDER BY [g].[Nickname] +LEFT JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)), [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Group_by_with_include_with_entity_in_result_selector(bool async) + public override async Task Correlated_collection_with_complex_OrderBy(bool async) { - await base.Group_by_with_include_with_entity_in_result_selector(async); + await base.Correlated_collection_with_complex_OrderBy(async); AssertSql( """ -SELECT [g1].[Rank], [g1].[c], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[Discriminator], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Name], [s0].[Location], [s0].[Nation] -FROM ( - SELECT [g].[Rank], COUNT(*) AS [c] - FROM [Gears] AS [g] - GROUP BY [g].[Rank] -) AS [g1] +SELECT [g].[Nickname], [g].[SquadId], [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Name], [s].[Location], [s].[Nation] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname]) AS [row] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] - ) AS [s] - WHERE [s].[row] <= 1 -) AS [s0] ON [g1].[Rank] = [s0].[Rank] -ORDER BY [g1].[Rank] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) +) AS [g1] ON [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [g1].[Nickname] """); } - public override async Task GroupBy_Property_Include_Select_Max(bool async) + public override async Task Correlated_collection_with_very_complex_order_by(bool async) { - await base.GroupBy_Property_Include_Select_Max(async); + await base.Correlated_collection_with_very_complex_order_by(async); AssertSql( """ -SELECT MAX([g].[SquadId]) +SELECT [g].[Nickname], [g].[SquadId], [g2].[Nickname], [g2].[SquadId], [g2].[AssignedCityName], [g2].[CityOfBirthName], [g2].[Discriminator], [g2].[FullName], [g2].[HasSoulPatch], [g2].[LeaderNickname], [g2].[LeaderSquadId], [g2].[Rank] FROM [Gears] AS [g] -GROUP BY [g].[Rank] +LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] + FROM [Gears] AS [g1] + WHERE [g1].[HasSoulPatch] = CAST(0 AS bit) +) AS [g2] ON [g].[Nickname] = [g2].[LeaderNickname] AND [g].[SquadId] = [g2].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( + SELECT TOP(1) [g0].[HasSoulPatch] + FROM [Gears] AS [g0] + WHERE [g0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [g].[Nickname], [g].[SquadId], [g2].[Nickname] """); } - public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) + public override async Task Cast_to_derived_type_after_OfType_works(bool async) { - await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); + await base.Cast_to_derived_type_after_OfType_works(async); AssertSql( """ -SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[Discriminator], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Name], [s0].[Location], [s0].[Nation] -FROM ( - SELECT [g].[Rank] - FROM [Gears] AS [g] - GROUP BY [g].[Rank] -) AS [g1] -LEFT JOIN ( - SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Name], [s].[Location], [s].[Nation] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname], [g0].[SquadId], [c].[Name]) AS [row] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] - WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) - ) AS [s] - WHERE [s].[row] <= 1 -) AS [s0] ON [g1].[Rank] = [s0].[Rank] +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 [g].[Discriminator] = N'Officer' """); } - public override async Task Include_collection_with_Cast_to_base(bool async) + public override async Task Select_subquery_boolean(bool async) { - await base.Include_collection_with_Cast_to_base(async); + await base.Select_subquery_boolean(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)) FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Include_with_client_method_and_member_access_still_applies_includes(bool async) + public override async Task Select_subquery_boolean_with_pushdown(bool async) { - await base.Include_with_client_method_and_member_access_still_applies_includes(async); + await base.Select_subquery_boolean_with_pushdown(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] """); } - public override async Task Include_with_projection_of_unmapped_property_still_gets_applied(bool async) + public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) { - await base.Include_with_projection_of_unmapped_property_still_gets_applied(async); + await base.Select_subquery_int_with_inside_cast_and_coalesce(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 42) FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection() + public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bool async) { - await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); + await base.Select_subquery_int_with_outside_cast_and_coalesce(async); AssertSql( """ -SELECT [s].[Name], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[Discriminator], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Gears] AS [g] - LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -WHERE [s].[Name] = N'Delta' -ORDER BY [s].[Id], [s0].[Nickname], [s0].[SquadId] +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 0) +FROM [Gears] AS [g] """); } - public override async Task OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(bool async) + public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool async) { - await base.OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(async); + await base.Select_subquery_int_with_pushdown_and_coalesce(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) -END +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 42) FROM [Gears] AS [g] -ORDER BY CASE - WHEN CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) - END IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END """); } - public override async Task GetValueOrDefault_in_projection(bool async) + public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool async) { - await base.GetValueOrDefault_in_projection(async); + await base.Select_subquery_int_with_pushdown_and_coalesce2(async); AssertSql( """ -SELECT COALESCE([w].[SynergyWithId], 0) -FROM [Weapons] AS [w] +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), ( + SELECT TOP(1) [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ORDER BY [w0].[Id])) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_in_filter(bool async) + public override async Task Select_subquery_boolean_empty(bool async) { - await base.GetValueOrDefault_in_filter(async); + await base.Select_subquery_boolean_empty(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], 0) = 0 +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ORDER BY [w].[Id]), CAST(0 AS bit)) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool async) + public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) { - await base.GetValueOrDefault_in_filter_non_nullable_column(async); + await base.Select_subquery_boolean_empty_with_pushdown(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[Id] = 0 +SELECT ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ORDER BY [w].[Id]) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_in_order_by(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) { - await base.GetValueOrDefault_in_order_by(async); + await base.Select_subquery_distinct_singleordefault_boolean1(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -ORDER BY COALESCE([w].[SynergyWithId], 0), [w].[Id] +SELECT COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]), CAST(0 AS bit)) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task GetValueOrDefault_with_argument(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean2(bool async) { - await base.GetValueOrDefault_with_argument(async); + await base.Select_subquery_distinct_singleordefault_boolean2(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], [w].[Id]) = 1 +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task GetValueOrDefault_with_argument_complex(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { - await base.GetValueOrDefault_with_argument_complex(async); + await base.Select_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], CAST(LEN([w].[Name]) AS int) + 42) > 10 +SELECT ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Filter_with_complex_predicate_containing_subquery(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty1(bool async) { - await base.Filter_with_complex_predicate_containing_subquery(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty1(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ) AS [w0]), CAST(0 AS bit)) FROM [Gears] AS [g] -WHERE [g].[FullName] <> N'Dom' AND EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit)) +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( - bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty2(bool async) { - await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty2(async); AssertSql( """ -SELECT [g].[Nickname], ( - SELECT TOP(1) [w].[Name] +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit) - ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG'), CAST(0 AS bit)) FROM [Gears] AS [g] -WHERE [g].[Nickname] <> N'Dom' +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task - Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE SUBSTRING([t].[Note], 0 + 1, [g].[SquadId]) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [g].[SquadId] IS NULL) AND [t].[GearNickName] IS NULL) +SELECT ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ) AS [w0]) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task - Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) + public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( - async); + await base.Cast_subquery_to_base_type_using_typed_ToList(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -WHERE SUBSTRING([t].[Note], 0 + 1, CAST(LEN([s].[Name]) AS int)) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s].[Name] IS NULL) AND [t].[GearNickName] IS NULL) +SELECT [c].[Name], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId] +FROM [Cities] AS [c] +LEFT JOIN [Gears] AS [g] ON [c].[Name] = [g].[AssignedCityName] +WHERE [c].[Name] = N'Ephyra' +ORDER BY [c].[Name], [g].[Nickname] """); } - public override async Task Filter_with_new_Guid(bool async) + public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArray(bool async) { - await base.Filter_with_new_Guid(async); + await base.Cast_ordered_subquery_to_base_type_using_typed_ToArray(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] = 'df36f493-463f-4123-83f9-6b135deeb7ba' +SELECT [c].[Name], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId] +FROM [Cities] AS [c] +LEFT JOIN [Gears] AS [g] ON [c].[Name] = [g].[AssignedCityName] +WHERE [c].[Name] = N'Ephyra' +ORDER BY [c].[Name], [g].[Nickname] DESC """); } - public override async Task Filter_with_new_Guid_closure(bool async) + public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) { - await base.Filter_with_new_Guid_closure(async); + await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); AssertSql( """ -@p='df36f493-463f-4123-83f9-6b135deeb7bd' - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] = @p -""", - // - """ -@p='b39a6fba-9026-4d69-828e-fd7068673e57' +@nicknames='[]' (Size = 4000) -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] = @p +SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY CASE + WHEN [g].[Nickname] IN ( + SELECT [n].[value] + FROM OPENJSON(@nicknames) WITH ([value] nvarchar(450) '$') AS [n] + ) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END DESC, [g].[Nickname], [g].[SquadId] """); } - public override async Task OfTypeNav1(bool async) + public override async Task Double_order_by_on_nullable_bool_coming_from_optional_navigation(bool async) { - await base.OfTypeNav1(async); + await base.Double_order_by_on_nullable_bool_coming_from_optional_navigation(async); AssertSql( """ -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] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w0].[IsAutomatic], [w0].[Id] """); } - public override async Task OfTypeNav2(bool async) + public override async Task Double_order_by_on_Like(bool async) { - await base.OfTypeNav2(async); + await base.Double_order_by_on_Like(async); AssertSql( """ -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] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] LIKE N'%Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task OfTypeNav3(bool async) + public override async Task Double_order_by_on_is_null(bool async) { - await base.OfTypeNav3(async); + await base.Double_order_by_on_is_null(async); AssertSql( """ -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] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Nav_rewrite_Distinct_with_convert() - { - await base.Nav_rewrite_Distinct_with_convert(); - - AssertSql(); - } - - public override async Task Nav_rewrite_Distinct_with_convert_anonymous() - { - await base.Nav_rewrite_Distinct_with_convert_anonymous(); - - AssertSql(); - } - - public override async Task Nav_rewrite_with_convert1(bool async) + public override async Task Double_order_by_on_string_compare(bool async) { - await base.Nav_rewrite_with_convert1(async); + await base.Double_order_by_on_string_compare(async); AssertSql( """ -SELECT [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] -FROM [Factions] AS [f] -LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] -LEFT JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +ORDER BY CASE + WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w].[Id] """); } - public override async Task Nav_rewrite_with_convert2(bool async) + public override async Task Double_order_by_binary_expression(bool async) { - await base.Nav_rewrite_with_convert2(async); + await base.Double_order_by_binary_expression(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] -FROM [Factions] AS [f] -LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] -LEFT JOIN ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +SELECT [w].[Id] + 2 AS [Binary] +FROM [Weapons] AS [w] +ORDER BY [w].[Id] + 2 """); } - public override async Task Nav_rewrite_with_convert3(bool async) + public override async Task String_compare_with_null_conditional_argument(bool async) { - await base.Nav_rewrite_with_convert3(async); + await base.String_compare_with_null_conditional_argument(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] -FROM [Factions] AS [f] -LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] -LEFT JOIN ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Where_contains_on_navigation_with_composite_keys(bool async) + public override async Task String_compare_with_null_conditional_argument2(bool async) { - await base.Where_contains_on_navigation_with_composite_keys(async); + await base.String_compare_with_null_conditional_argument2(async); AssertSql( """ -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 EXISTS ( - SELECT 1 - FROM [Cities] AS [c] - WHERE EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [c].[Name] = [g0].[CityOfBirthName] AND [g0].[Nickname] = [g].[Nickname] AND [g0].[SquadId] = [g].[SquadId])) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Include_with_complex_order_by(bool async) + public override async Task String_concat_with_null_conditional_argument(bool async) { - await base.Include_with_complex_order_by(async); + await base.String_concat_with_null_conditional_argument(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY ( - SELECT TOP(1) [w].[Name] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Gnasher%'), [g].[Nickname], [g].[SquadId] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY COALESCE([w0].[Name], N'') + CAST(5 AS nvarchar(max)) """); } - public override async Task Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(bool async) + public override async Task String_concat_with_null_conditional_argument2(bool async) { - await base.Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(async); + await base.String_concat_with_null_conditional_argument2(async); AssertSql( - """ -@p='25' - -SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId] -FROM ( - SELECT TOP(@p) [g].[FullName] - FROM [Gears] AS [g] -) AS [g0] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] - FROM [Weapons] AS [w] - ) AS [w0] - WHERE [w0].[row] <= 1 -) AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] + """ +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY COALESCE([w0].[Name], N'') + N'Marcus'' Lancer' """); } - public override async Task Bool_projection_from_subquery_treated_appropriately_in_where(bool async) + public override async Task String_concat_on_various_types(bool async) { - await base.Bool_projection_from_subquery_treated_appropriately_in_where(async); + await base.String_concat_on_various_types(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE ( - SELECT TOP(1) [g].[HasSoulPatch] - FROM [Gears] AS [g] - ORDER BY [g].[Nickname], [g].[SquadId]) = CAST(1 AS bit) +SELECT N'HasSoulPatch ' + CAST([g].[HasSoulPatch] AS nvarchar(max)) + N' HasSoulPatch' AS [HasSoulPatch], N'Rank ' + CAST([g].[Rank] AS nvarchar(max)) + N' Rank' AS [Rank], N'SquadId ' + CAST([g].[SquadId] AS nvarchar(max)) + N' SquadId' AS [SquadId], N'Rating ' + COALESCE(CAST([m].[Rating] AS nvarchar(max)), N'') + N' Rating' AS [Rating], N'Timeline ' + CAST([m].[Timeline] AS nvarchar(max)) + N' Timeline' AS [Timeline] +FROM [Gears] AS [g] +CROSS JOIN [Missions] AS [m] +ORDER BY [g].[Nickname], [m].[Id] """); } - public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) + public override async Task GroupBy_Property_Include_Select_Average(bool async) { - await base.DateTimeOffset_Contains_Less_than_Greater_than(async); + await base.GroupBy_Property_Include_Select_Average(async); AssertSql( """ -@start='1902-01-01T10:00:00.1234567+01:30' -@end='1902-01-03T10:00:00.1234567+01:30' -@dates='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) - -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE @start <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @end AND [m].[Timeline] IN ( - SELECT [d].[value] - FROM OPENJSON(@dates) WITH ([value] datetimeoffset '$') AS [d] -) +SELECT AVG(CAST([g].[SquadId] AS float)) +FROM [Gears] AS [g] +GROUP BY [g].[Rank] """); } - public override Task DateTimeOffsetNow_minus_timespan(bool async) - => AssertTranslationFailed(() => base.DateTimeOffsetNow_minus_timespan(async)); - - public override async Task Navigation_inside_interpolated_string_expanded(bool async) + public override async Task GroupBy_Property_Include_Select_Sum(bool async) { - await base.Navigation_inside_interpolated_string_expanded(async); + await base.GroupBy_Property_Include_Select_Sum(async); AssertSql( """ -SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w0].[OwnerFullName] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +SELECT COALESCE(SUM([g].[SquadId]), 0) +FROM [Gears] AS [g] +GROUP BY [g].[Rank] """); } - public override async Task Left_join_projection_using_coalesce_tracking(bool async) + public override async Task GroupBy_Property_Include_Select_Count(bool async) { - await base.Left_join_projection_using_coalesce_tracking(async); + await base.GroupBy_Property_Include_Select_Count(async); AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT COUNT(*) FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +GROUP BY [g].[Rank] """); } - public override async Task Left_join_projection_using_conditional_tracking(bool async) + public override async Task GroupBy_Property_Include_Select_LongCount(bool async) { - await base.Left_join_projection_using_conditional_tracking(async); + await base.GroupBy_Property_Include_Select_LongCount(async); AssertSql( """ -SELECT CASE - WHEN [g0].[Nickname] IS NULL OR [g0].[SquadId] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +SELECT COUNT_BIG(*) FROM [Gears] AS [g] -LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] +GROUP BY [g].[Rank] """); } - public override async Task Project_collection_navigation_nested_with_take_composite_key(bool async) + public override async Task GroupBy_Property_Include_Select_Min(bool async) { - await base.Project_collection_navigation_nested_with_take_composite_key(async); + await base.GroupBy_Property_Include_Select_Min(async); AssertSql( """ -SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g2].[Nickname], [g2].[SquadId], [g2].[AssignedCityName], [g2].[CityOfBirthName], [g2].[Discriminator], [g2].[FullName], [g2].[HasSoulPatch], [g2].[LeaderNickname], [g2].[LeaderSquadId], [g2].[Rank] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], ROW_NUMBER() OVER(PARTITION BY [g0].[LeaderNickname], [g0].[LeaderSquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) AS [row] - FROM [Gears] AS [g0] - ) AS [g1] - WHERE [g1].[row] <= 50 -) AS [g2] ON ([g].[Nickname] = [g2].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g2].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g2].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [g2].[Nickname] +SELECT MIN([g].[SquadId]) +FROM [Gears] AS [g] +GROUP BY [g].[Rank] """); } - public override async Task Project_collection_navigation_nested_composite_key(bool async) + public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(bool async) { - await base.Project_collection_navigation_nested_composite_key(async); + await base.GroupBy_Property_Include_Aggregate_with_anonymous_selector(async); AssertSql( """ -SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname] +SELECT [g].[Nickname] AS [Key], COUNT(*) AS [c] +FROM [Gears] AS [g] +GROUP BY [g].[Nickname] +ORDER BY [g].[Nickname] """); } - public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) + public override async Task Group_by_with_include_with_entity_in_result_selector(bool async) { - await base.Null_checks_in_correlated_predicate_are_correctly_translated(async); + await base.Group_by_with_include_with_entity_in_result_selector(async); AssertSql( """ -SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] AND [t].[Note] IS NOT NULL -ORDER BY [t].[Id], [g].[Nickname] +SELECT [g1].[Rank], [g1].[c], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[Discriminator], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Name], [s0].[Location], [s0].[Nation] +FROM ( + SELECT [g].[Rank], COUNT(*) AS [c] + FROM [Gears] AS [g] + GROUP BY [g].[Rank] +) AS [g1] +LEFT JOIN ( + SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Name], [s].[Location], [s].[Nation] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname]) AS [row] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] + ) AS [s] + WHERE [s].[row] <= 1 +) AS [s0] ON [g1].[Rank] = [s0].[Rank] +ORDER BY [g1].[Rank] """); } - public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(bool async) + public override async Task GroupBy_Property_Include_Select_Max(bool async) { - await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(async); + await base.GroupBy_Property_Include_Select_Max(async); AssertSql( """ -@isAutomatic='True' - -SELECT [g].[Nickname], [g].[FullName], CASE - WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Collection] +SELECT MAX([g].[SquadId]) FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = @isAutomatic -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +GROUP BY [g].[Rank] """); } - public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_not_equal(bool async) + public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) { - await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_not_equal(async); + await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); AssertSql( """ -@isAutomatic='True' - -SELECT [g].[Nickname], [g].[FullName], CASE - WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Collection] -FROM [Gears] AS [g] +SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[Discriminator], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Name], [s0].[Location], [s0].[Nation] +FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + GROUP BY [g].[Rank] +) AS [g1] LEFT JOIN ( - SELECT [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] <> @isAutomatic -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] + SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[Discriminator], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Name], [s].[Location], [s].[Nation] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname], [g0].[SquadId], [c].[Name]) AS [row] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] + WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) + ) AS [s] + WHERE [s].[row] <= 1 +) AS [s0] ON [g1].[Rank] = [s0].[Rank] """); } - public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(bool async) + public override async Task Include_collection_with_Cast_to_base(bool async) { - await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(async); + await base.Include_collection_with_Cast_to_base(async); AssertSql( """ -@prm='1' - -SELECT [g].[Nickname], [g].[FullName], CASE - WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Collection] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[Id] > @prm -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Join_with_inner_being_a_subquery_projecting_single_property(bool async) + public override async Task Include_with_client_method_and_member_access_still_applies_includes(bool async) { - await base.Join_with_inner_being_a_subquery_projecting_single_property(async); + await base.Include_with_client_method_and_member_access_still_applies_includes(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Gears] AS [g] -INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] """); } - public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) + public override async Task Include_with_projection_of_unmapped_property_still_gets_applied(bool async) { - await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); + await base.Include_with_projection_of_unmapped_property_still_gets_applied(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Navigation_based_on_complex_expression1(bool async) + public override async Task Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection() { - await base.Navigation_based_on_complex_expression1(async); + await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] -FROM [Factions] AS [f] +SELECT [s].[Name], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[Discriminator], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Gears] AS [g] + LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +WHERE [s].[Name] = N'Delta' +ORDER BY [s].[Id], [s0].[Nickname], [s0].[SquadId] """); } - public override async Task Navigation_based_on_complex_expression2(bool async) + public override async Task OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(bool async) { - await base.Navigation_based_on_complex_expression2(async); + await base.OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] -FROM [Factions] AS [f] -LEFT JOIN ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) +END +FROM [Gears] AS [g] +ORDER BY CASE + WHEN CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) + END IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Navigation_based_on_complex_expression3(bool async) + public override async Task GetValueOrDefault_in_projection(bool async) { - await base.Navigation_based_on_complex_expression3(async); + await base.GetValueOrDefault_in_projection(async); AssertSql( """ -SELECT [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] -FROM [Factions] AS [f] -LEFT JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] ON [f].[CommanderName] = [l0].[Name] +SELECT COALESCE([w].[SynergyWithId], 0) +FROM [Weapons] AS [w] """); } - public override async Task Navigation_based_on_complex_expression4(bool async) + public override async Task GetValueOrDefault_in_filter(bool async) { - await base.Navigation_based_on_complex_expression4(async); + await base.GetValueOrDefault_in_filter(async); AssertSql( """ -SELECT CAST(1 AS bit), [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] -FROM [Factions] AS [f] -CROSS JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] -LEFT JOIN ( - SELECT [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l1] - WHERE [l1].[Discriminator] = N'LocustCommander' -) AS [l2] ON [f].[CommanderName] = [l2].[Name] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], 0) = 0 """); } - public override async Task Navigation_based_on_complex_expression5(bool async) + public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool async) { - await base.Navigation_based_on_complex_expression5(async); + await base.GetValueOrDefault_in_filter_non_nullable_column(async); AssertSql( """ -SELECT [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] -FROM [Factions] AS [f] -CROSS JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] -LEFT JOIN ( - SELECT [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l1] - WHERE [l1].[Discriminator] = N'LocustCommander' -) AS [l2] ON [f].[CommanderName] = [l2].[Name] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[Id] = 0 """); } - public override async Task Navigation_based_on_complex_expression6(bool async) + public override async Task GetValueOrDefault_in_order_by(bool async) { - await base.Navigation_based_on_complex_expression6(async); + await base.GetValueOrDefault_in_order_by(async); AssertSql( """ -SELECT CASE - WHEN [l2].[Name] = N'Queen Myrrah' AND [l2].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] -FROM [Factions] AS [f] -CROSS JOIN ( - SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] - FROM [LocustLeaders] AS [l] - WHERE [l].[Discriminator] = N'LocustCommander' -) AS [l0] -LEFT JOIN ( - SELECT [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l1] - WHERE [l1].[Discriminator] = N'LocustCommander' -) AS [l2] ON [f].[CommanderName] = [l2].[Name] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +ORDER BY COALESCE([w].[SynergyWithId], 0), [w].[Id] """); } - public override async Task Select_as_operator(bool async) + public override async Task GetValueOrDefault_with_argument(bool async) { - await base.Select_as_operator(async); + await base.GetValueOrDefault_with_argument(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], [w].[Id]) = 1 """); } - public override async Task Select_datetimeoffset_comparison_in_projection(bool async) + public override async Task GetValueOrDefault_with_argument_complex(bool async) { - await base.Select_datetimeoffset_comparison_in_projection(async); + await base.GetValueOrDefault_with_argument_complex(async); AssertSql( """ -SELECT CASE - WHEN [m].[Timeline] > SYSDATETIMEOFFSET() THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Missions] AS [m] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], CAST(LEN([w].[Name]) AS int) + 42) > 10 """); } - public override async Task OfType_in_subquery_works(bool async) + public override async Task Filter_with_complex_predicate_containing_subquery(bool async) { - await base.OfType_in_subquery_works(async); + await base.Filter_with_complex_predicate_containing_subquery(async); AssertSql( """ -SELECT [s].[Name], [s].[Location], [s].[Nation] +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] -INNER JOIN ( - SELECT [c].[Name], [c].[Location], [c].[Nation], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] - WHERE [g0].[Discriminator] = N'Officer' -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [g].[Discriminator] = N'Officer' +WHERE [g].[FullName] <> N'Dom' AND EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit)) """); } - public override async Task Nullable_bool_comparison_is_translated_to_server(bool async) + public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( + bool async) { - await base.Nullable_bool_comparison_is_translated_to_server(async); + await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(async); AssertSql( """ -SELECT CASE - WHEN [f].[Eradicated] = CAST(1 AS bit) AND [f].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [IsEradicated] -FROM [Factions] AS [f] +SELECT [g].[Nickname], ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit) + ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] +FROM [Gears] AS [g] +WHERE [g].[Nickname] <> N'Dom' """); } - public override async Task Accessing_reference_navigation_collection_composition_generates_single_query(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) { - await base.Accessing_reference_navigation_collection_composition_generates_single_query(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s].[IsAutomatic], [s].[Name], [s].[Id0] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [g].[FullName] = [s].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE SUBSTRING([t].[Note], 0 + 1, [g].[SquadId]) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [g].[SquadId] IS NULL) AND [t].[GearNickName] IS NULL) """); } - public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) { - await base.Reference_include_chain_loads_correctly_when_middle_is_null(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -ORDER BY [t].[Note] +WHERE SUBSTRING([t].[Note], 0 + 1, CAST(LEN([s].[Name]) AS int)) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s].[Name] IS NULL) AND [t].[GearNickName] IS NULL) """); } - public override async Task Accessing_property_of_optional_navigation_in_child_projection_works(bool async) + public override async Task OfTypeNav1(bool async) { - await base.Accessing_property_of_optional_navigation_in_child_projection_works(async); + await base.OfTypeNav1(async); AssertSql( """ -SELECT CASE - WHEN [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[Id], [s].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [w].[Id], [g0].[SquadId], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] -) AS [s] ON [g].[FullName] = [s].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] +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] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) """); } - public override async Task Collection_navigation_ofType_filter_works(bool async) + public override async Task OfTypeNav2(bool async) { - await base.Collection_navigation_ofType_filter_works(async); + await base.OfTypeNav2(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - WHERE [c].[Name] = [g].[CityOfBirthName] AND [g].[Discriminator] = N'Officer' AND [g].[Nickname] = N'Marcus') +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] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) """); } - public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) + public override async Task OfTypeNav3(bool async) { - await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); + await base.OfTypeNav3(async); AssertSql( """ -@prm_Inner_Nickname='Marcus' (Size = 450) - -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM ( - SELECT DISTINCT [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 [g].[Nickname] <> @prm_Inner_Nickname -) AS [g0] -ORDER BY [g0].[FullName] +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] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [g].[Discriminator] = N'Officer' AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) """); } - public override async Task Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(bool async) + public override async Task Nav_rewrite_Distinct_with_convert() { - await base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async); + await base.Nav_rewrite_Distinct_with_convert(); + + AssertSql(); + } + + public override async Task Nav_rewrite_Distinct_with_convert_anonymous() + { + await base.Nav_rewrite_Distinct_with_convert_anonymous(); + + AssertSql(); + } + + public override async Task Nav_rewrite_with_convert1(bool async) + { + await base.Nav_rewrite_with_convert1(async); AssertSql( """ -@squadId='1' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[Discriminator], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank] -FROM ( - 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] - INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] - WHERE [s].[Id] IN ( - SELECT [s0].[Id] - FROM [Squads] AS [s0] - WHERE [s0].[Id] = @squadId - ) - UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] - FROM [Gears] AS [g0] - INNER JOIN [Squads] AS [s1] ON [g0].[SquadId] = [s1].[Id] - WHERE [s1].[Id] IN ( - SELECT [s2].[Id] - FROM [Squads] AS [s2] - WHERE [s2].[Id] = @squadId - ) -) AS [u] -ORDER BY [u].[FullName] +SELECT [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] +FROM [Factions] AS [f] +LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] +LEFT JOIN ( + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL """); } - public override async Task Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(bool async) + public override async Task Nav_rewrite_with_convert2(bool async) { - await base.Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(async); + await base.Nav_rewrite_with_convert2(async); AssertSql( """ -@gearId='1' - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[SquadId] = @gearId AND [g].[SquadId] = @gearId) +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] +LEFT JOIN ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) """); } - public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(bool async) + public override async Task Nav_rewrite_with_convert3(bool async) { - await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(async); + await base.Nav_rewrite_with_convert3(async); AssertSql( """ -@entity_equality_prm_Inner_Squad_Id='1' (Nullable = true) +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] +LEFT JOIN ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +"""); + } -SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[Discriminator], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank] -FROM ( - SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] - FROM [Gears] AS [g] - INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] - WHERE [s].[Id] = @entity_equality_prm_Inner_Squad_Id -) AS [s1] -INNER JOIN [Squads] AS [s0] ON [s1].[SquadId] = [s0].[Id] -WHERE [s0].[Id] = @entity_equality_prm_Inner_Squad_Id -ORDER BY [s1].[FullName] + public override async Task Where_contains_on_navigation_with_composite_keys(bool async) + { + await base.Where_contains_on_navigation_with_composite_keys(async); + + AssertSql( + """ +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 EXISTS ( + SELECT 1 + FROM [Cities] AS [c] + WHERE EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [c].[Name] = [g0].[CityOfBirthName] AND [g0].[Nickname] = [g].[Nickname] AND [g0].[SquadId] = [g].[SquadId])) """); } - public override async Task Complex_GroupBy_after_set_operator(bool async) + public override async Task Include_with_complex_order_by(bool async) { - await base.Complex_GroupBy_after_set_operator(async); + await base.Include_with_complex_order_by(async); AssertSql( """ -SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] -FROM ( - SELECT [c].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] - FROM [Gears] AS [g] - LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] - UNION ALL - SELECT [c0].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] -) AS [u] -GROUP BY [u].[Name], [u].[Count] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Gnasher%'), [g].[Nickname], [g].[SquadId] """); } - public override async Task Complex_GroupBy_after_set_operator_using_result_selector(bool async) + public override async Task Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(bool async) { - await base.Complex_GroupBy_after_set_operator_using_result_selector(async); + await base.Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(async); AssertSql( """ -SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] +@p='25' + +SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId] FROM ( - SELECT [c].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] + SELECT TOP(@p) [g].[FullName] FROM [Gears] AS [g] - LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] - UNION ALL - SELECT [c0].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] -) AS [u] -GROUP BY [u].[Name], [u].[Count] +) AS [g0] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] + FROM [Weapons] AS [w] + ) AS [w0] + WHERE [w0].[row] <= 1 +) AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] """); } - public override async Task Left_join_with_GroupBy_with_composite_group_key(bool async) + public override async Task Bool_projection_from_subquery_treated_appropriately_in_where(bool async) { - await base.Left_join_with_GroupBy_with_composite_group_key(async); + await base.Bool_projection_from_subquery_treated_appropriately_in_where(async); AssertSql( """ -SELECT [g].[CityOfBirthName], [g].[HasSoulPatch] -FROM [Gears] AS [g] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -GROUP BY [g].[CityOfBirthName], [g].[HasSoulPatch] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE ( + SELECT TOP(1) [g].[HasSoulPatch] + FROM [Gears] AS [g] + ORDER BY [g].[Nickname], [g].[SquadId]) = CAST(1 AS bit) """); } - public override async Task GroupBy_with_boolean_grouping_key(bool async) + public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) { - await base.GroupBy_with_boolean_grouping_key(async); + await base.DateTimeOffset_Contains_Less_than_Greater_than(async); AssertSql( """ -SELECT [g0].[CityOfBirthName], [g0].[HasSoulPatch], [g0].[IsMarcus], COUNT(*) AS [Count] -FROM ( - SELECT [g].[CityOfBirthName], [g].[HasSoulPatch], CASE - WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [IsMarcus] - FROM [Gears] AS [g] -) AS [g0] -GROUP BY [g0].[CityOfBirthName], [g0].[HasSoulPatch], [g0].[IsMarcus] +@start='1902-01-01T10:00:00.1234567+01:30' +@end='1902-01-03T10:00:00.1234567+01:30' +@dates='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) + +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE @start <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @end AND [m].[Timeline] IN ( + SELECT [d].[value] + FROM OPENJSON(@dates) WITH ([value] datetimeoffset '$') AS [d] +) """); } - public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) + public override Task DateTimeOffsetNow_minus_timespan(bool async) + => AssertTranslationFailed(() => base.DateTimeOffsetNow_minus_timespan(async)); + + public override async Task Navigation_inside_interpolated_string_expanded(bool async) { - await base.GroupBy_with_boolean_groupin_key_thru_navigation_access(async); + await base.Navigation_inside_interpolated_string_expanded(async); AssertSql( """ -SELECT [g].[HasSoulPatch], LOWER([s].[Name]) AS [Name] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -GROUP BY [g].[HasSoulPatch], [s].[Name] +SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w0].[OwnerFullName] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] """); } - public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) + public override async Task Left_join_projection_using_coalesce_tracking(bool async) { - await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); + await base.Left_join_projection_using_coalesce_tracking(async); AssertSql( """ -SELECT [c].[Name] +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -GROUP BY [c].[Name] +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] """); } - public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Left_join_projection_using_conditional_tracking(bool async) { - await base.Group_by_on_StartsWith_with_null_parameter_as_argument(async); + await base.Left_join_projection_using_conditional_tracking(async); AssertSql( """ -SELECT [g0].[Key] -FROM ( - SELECT CAST(0 AS bit) AS [Key] - FROM [Gears] AS [g] -) AS [g0] -GROUP BY [g0].[Key] +SELECT CASE + WHEN [g0].[Nickname] IS NULL OR [g0].[SquadId] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [Gears] AS [g] +LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] """); } - public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Project_collection_navigation_nested_with_take_composite_key(bool async) { - await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); + await base.Project_collection_navigation_nested_with_take_composite_key(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -GROUP BY [g].[FullName] -HAVING 0 = 1 +SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g2].[Nickname], [g2].[SquadId], [g2].[AssignedCityName], [g2].[CityOfBirthName], [g2].[Discriminator], [g2].[FullName], [g2].[HasSoulPatch], [g2].[LeaderNickname], [g2].[LeaderSquadId], [g2].[Rank] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[Discriminator], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], ROW_NUMBER() OVER(PARTITION BY [g0].[LeaderNickname], [g0].[LeaderSquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) AS [row] + FROM [Gears] AS [g0] + ) AS [g1] + WHERE [g1].[row] <= 50 +) AS [g2] ON ([g].[Nickname] = [g2].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g2].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g2].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [g2].[Nickname] """); } - public override async Task Select_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Project_collection_navigation_nested_composite_key(bool async) { - await base.Select_StartsWith_with_null_parameter_as_argument(async); + await base.Project_collection_navigation_nested_composite_key(async); AssertSql( """ -SELECT CAST(0 AS bit) -FROM [Gears] AS [g] +SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname] OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND [g].[SquadId] = [g0].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname] """); } - public override async Task Select_null_parameter_is_not_null(bool async) + public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) { - await base.Select_null_parameter_is_not_null(async); + await base.Null_checks_in_correlated_predicate_are_correctly_translated(async); AssertSql( """ -@p='False' - -SELECT @p -FROM [Gears] AS [g] +SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] AND [t].[Note] IS NOT NULL +ORDER BY [t].[Id], [g].[Nickname] """); } - public override async Task Where_null_parameter_is_not_null(bool async) + public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(bool async) { - await base.Where_null_parameter_is_not_null(async); + await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(async); AssertSql( """ -@p='False' +@isAutomatic='True' -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [g].[Nickname], [g].[FullName], CASE + WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Collection] FROM [Gears] AS [g] -WHERE @p = CAST(1 AS bit) +LEFT JOIN ( + SELECT [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = @isAutomatic +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] """); } - public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_not_equal(bool async) { - await base.OrderBy_StartsWith_with_null_parameter_as_argument(async); + await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_not_equal(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +@isAutomatic='True' + +SELECT [g].[Nickname], [g].[FullName], CASE + WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Collection] FROM [Gears] AS [g] -ORDER BY [g].[Nickname] +LEFT JOIN ( + SELECT [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] <> @isAutomatic +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] """); } - public override async Task OrderBy_Contains_empty_list(bool async) + public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(bool async) { - await base.OrderBy_Contains_empty_list(async); + await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(async); AssertSql( """ -@ids='[]' (Size = 4000) +@prm='1' -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] -ORDER BY CASE - WHEN [g].[SquadId] IN ( - SELECT [i].[value] - FROM OPENJSON(@ids) WITH ([value] int '$') AS [i] - ) THEN CAST(1 AS bit) +SELECT [g].[Nickname], [g].[FullName], CASE + WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END +END AS [Collection] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[Id] > @prm +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] """); } - public override async Task Where_with_enum_flags_parameter(bool async) + public override async Task Join_with_inner_being_a_subquery_projecting_single_property(bool async) { - await base.Where_with_enum_flags_parameter(async); + await base.Join_with_inner_being_a_subquery_projecting_single_property(async); AssertSql( """ -@rank='1' (Nullable = true) - -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 [g].[Rank] & @rank = @rank -""", - // - """ -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] -""", - // - """ -@rank='2' (Nullable = true) - -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 [g].[Rank] | @rank <> @rank -""", - // - """ 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 0 = 1 +INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname] """); } - public override async Task FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(bool async) + public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) { - await base.FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(async); + await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); AssertSql( """ 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] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE [c].[Name] = ( - SELECT TOP(1) [c0].[Name] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] - ORDER BY [g0].[Nickname]) OR ([c].[Name] IS NULL AND ( - SELECT TOP(1) [c0].[Name] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] - ORDER BY [g0].[Nickname]) IS NULL) +INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname] """); } - public override async Task Bitwise_operation_with_non_null_parameter_optimizes_null_checks(bool async) + public override async Task Navigation_based_on_complex_expression1(bool async) { - await base.Bitwise_operation_with_non_null_parameter_optimizes_null_checks(async); + await base.Navigation_based_on_complex_expression1(async); AssertSql( """ -@ranks='134' - -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 [g].[Rank] & @ranks <> 0 -""", - // - """ -@ranks='134' - -SELECT ~CAST(([g].[Rank] | @ranks) ^ @ranks AS bit) -FROM [Gears] AS [g] -""", - // - """ -@ranks='134' - -SELECT ~CAST(([g].[Rank] | [g].[Rank] | @ranks | [g].[Rank] | @ranks) ^ @ranks AS bit) -FROM [Gears] AS [g] +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +WHERE [l0].[Name] IS NOT NULL """); } - public override async Task Bitwise_operation_with_null_arguments(bool async) + public override async Task Navigation_based_on_complex_expression2(bool async) { - await base.Bitwise_operation_with_null_arguments(async); + await base.Navigation_based_on_complex_expression2(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -""", - // - """ -@prm='2' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @prm <> 0 OR [w].[AmmunitionType] IS NULL -""", - // - """ -@prm='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @prm = @prm +SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[ServerAddress], [f].[CommanderName], [f].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] +WHERE [l0].[Name] IS NOT NULL """); } - public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) + public override async Task Navigation_based_on_complex_expression3(bool async) { - await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); + await base.Navigation_based_on_complex_expression3(async); AssertSql( """ -@prm='True' - -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 [g].[HasSoulPatch] <> @prm -""", - // - """ -@prm='False' - -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 [g].[HasSoulPatch] <> @prm +SELECT [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] +FROM [Factions] AS [f] +LEFT JOIN ( + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] ON [f].[CommanderName] = [l0].[Name] """); } - public override async Task Cast_OfType_works_correctly(bool async) + public override async Task Navigation_based_on_complex_expression4(bool async) { - await base.Cast_OfType_works_correctly(async); + await base.Navigation_based_on_complex_expression4(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -WHERE [g].[Discriminator] = N'Officer' +SELECT CAST(1 AS bit), [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] +FROM [Factions] AS [f] +CROSS JOIN ( + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] +LEFT JOIN ( + SELECT [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l1] + WHERE [l1].[Discriminator] = N'LocustCommander' +) AS [l2] ON [f].[CommanderName] = [l2].[Name] """); } - public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) + public override async Task Navigation_based_on_complex_expression5(bool async) { - await base.Join_inner_source_custom_projection_followed_by_filter(async); + await base.Navigation_based_on_complex_expression5(async); AssertSql( """ -SELECT CASE - WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) -END AS [IsEradicated], [f].[CommanderName], [f].[Name] -FROM [LocustLeaders] AS [l] -INNER JOIN [Factions] AS [f] ON [l].[Name] = [f].[CommanderName] -WHERE CASE - WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) -END = CAST(0 AS bit) OR CASE - WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) -END IS NULL +SELECT [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] +FROM [Factions] AS [f] +CROSS JOIN ( + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] +LEFT JOIN ( + SELECT [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l1] + WHERE [l1].[Discriminator] = N'LocustCommander' +) AS [l2] ON [f].[CommanderName] = [l2].[Name] """); } - public override async Task Byte_array_contains_literal(bool async) + public override async Task Navigation_based_on_complex_expression6(bool async) { - await base.Byte_array_contains_literal(async); + await base.Navigation_based_on_complex_expression6(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CHARINDEX(0x01, [s].[Banner]) > 0 +SELECT CASE + WHEN [l2].[Name] = N'Queen Myrrah' AND [l2].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [l2].[Name], [l2].[Discriminator], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] +FROM [Factions] AS [f] +CROSS JOIN ( + SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] + FROM [LocustLeaders] AS [l] + WHERE [l].[Discriminator] = N'LocustCommander' +) AS [l0] +LEFT JOIN ( + SELECT [l1].[Name], [l1].[Discriminator], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l1] + WHERE [l1].[Discriminator] = N'LocustCommander' +) AS [l2] ON [f].[CommanderName] = [l2].[Name] """); } - public override async Task Byte_array_filter_by_length_literal(bool async) + public override async Task Select_as_operator(bool async) { - await base.Byte_array_filter_by_length_literal(async); + await base.Select_as_operator(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = 2 +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] """); } - public override async Task Byte_array_filter_by_length_parameter(bool async) + public override async Task Select_datetimeoffset_comparison_in_projection(bool async) { - await base.Byte_array_filter_by_length_parameter(async); + await base.Select_datetimeoffset_comparison_in_projection(async); AssertSql( """ -@p='2' - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = @p +SELECT CASE + WHEN [m].[Timeline] > SYSDATETIMEOFFSET() THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Missions] AS [m] """); } - public override void Byte_array_filter_by_length_parameter_compiled() + public override async Task OfType_in_subquery_works(bool async) { - base.Byte_array_filter_by_length_parameter_compiled(); + await base.OfType_in_subquery_works(async); AssertSql( """ -@byteArrayParam='0x2A80' (Size = 8000) - -SELECT COUNT(*) -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@byteArrayParam) AS int) +SELECT [s].[Name], [s].[Location], [s].[Nation] +FROM [Gears] AS [g] +INNER JOIN ( + SELECT [c].[Name], [c].[Location], [c].[Nation], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] + LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] + WHERE [g0].[Discriminator] = N'Officer' +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [g].[Discriminator] = N'Officer' """); } - public override async Task Byte_array_contains_parameter(bool async) + public override async Task Nullable_bool_comparison_is_translated_to_server(bool async) { - await base.Byte_array_contains_parameter(async); + await base.Nullable_bool_comparison_is_translated_to_server(async); AssertSql( """ -@someByte='1' (Size = 1) - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CHARINDEX(CAST(@someByte AS varbinary(max)), [s].[Banner]) > 0 +SELECT CASE + WHEN [f].[Eradicated] = CAST(1 AS bit) AND [f].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [IsEradicated] +FROM [Factions] AS [f] """); } - public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) + public override async Task Accessing_reference_navigation_collection_composition_generates_single_query(bool async) { - await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); + await base.Accessing_reference_navigation_collection_composition_generates_single_query(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE DATALENGTH([s].[Banner5]) = 5 +SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s].[IsAutomatic], [s].[Name], [s].[Id0] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +) AS [s] ON [g].[FullName] = [s].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id] """); } - public override async Task Conditional_expression_with_test_being_simplified_to_constant_simple(bool isAsync) + public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) { - await base.Conditional_expression_with_test_being_simplified_to_constant_simple(isAsync); + await base.Reference_include_chain_loads_correctly_when_middle_is_null(async); AssertSql( """ -@prm='True' - -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].[HasSoulPatch] = @prm THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +ORDER BY [t].[Note] """); } - public override async Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) + public override async Task Accessing_property_of_optional_navigation_in_child_projection_works(bool async) { - await base.Conditional_expression_with_test_being_simplified_to_constant_complex(isAsync); + await base.Accessing_property_of_optional_navigation_in_child_projection_works(async); AssertSql( """ -@prm='True' -@prm2='Marcus' Lancer' (Size = 4000) - -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].[HasSoulPatch] = @prm AND ( - SELECT TOP(1) [w].[Name] - FROM [Weapons] AS [w] - WHERE [w].[Id] = [g].[SquadId]) = @prm2 THEN CAST(1 AS bit) +SELECT CASE + WHEN [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +END, [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[Id], [s].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [w].[Id], [g0].[SquadId], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] +) AS [s] ON [g].[FullName] = [s].[OwnerFullName] +ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task OrderBy_bool_coming_from_optional_navigation(bool async) + public override async Task Collection_navigation_ofType_filter_works(bool async) { - await base.OrderBy_bool_coming_from_optional_navigation(async); + await base.Collection_navigation_ofType_filter_works(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w0].[IsAutomatic] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE EXISTS ( + SELECT 1 + FROM [Gears] AS [g] + WHERE [c].[Name] = [g].[CityOfBirthName] AND [g].[Discriminator] = N'Officer' AND [g].[Nickname] = N'Marcus') """); } - public override async Task DateTimeOffset_Date_returns_datetime(bool async) + public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) { - await base.DateTimeOffset_Date_returns_datetime(async); + await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); AssertSql( """ -@dateTimeOffset_Date='0002-03-01T00:00:00.0000000' +@prm_Inner_Nickname='Marcus' (Size = 450) -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONVERT(date, [m].[Timeline]) >= @dateTimeOffset_Date +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM ( + SELECT DISTINCT [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 [g].[Nickname] <> @prm_Inner_Nickname +) AS [g0] +ORDER BY [g0].[FullName] """); } - public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async) + public override async Task Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(bool async) { - await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async); + await base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] +@squadId='1' + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[Discriminator], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank] +FROM ( + 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] + INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] + WHERE [s].[Id] IN ( + SELECT [s0].[Id] + FROM [Squads] AS [s0] + WHERE [s0].[Id] = @squadId + ) + UNION ALL + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] + FROM [Gears] AS [g0] + INNER JOIN [Squads] AS [s1] ON [g0].[SquadId] = [s1].[Id] + WHERE [s1].[Id] IN ( + SELECT [s2].[Id] + FROM [Squads] AS [s2] + WHERE [s2].[Id] = @squadId + ) +) AS [u] +ORDER BY [u].[FullName] """); } - public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async) + public override async Task Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(bool async) { - await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async); + await base.Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(async); AssertSql( """ -SELECT [g].[CityOfBirthName] -FROM [Gears] AS [g] +@gearId='1' + +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE EXISTS ( + SELECT 1 + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[SquadId] = @gearId AND [g].[SquadId] = @gearId) """); } - public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async) + public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(bool async) { - await base.Projecting_required_string_column_compared_to_null_parameter(async); + await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(async); AssertSql( """ -SELECT CAST(0 AS bit) -FROM [Gears] AS [g] +@entity_equality_prm_Inner_Squad_Id='1' (Nullable = true) + +SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[Discriminator], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank] +FROM ( + SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] + WHERE [s].[Id] = @entity_equality_prm_Inner_Squad_Id +) AS [s1] +INNER JOIN [Squads] AS [s0] ON [s1].[SquadId] = [s0].[Id] +WHERE [s0].[Id] = @entity_equality_prm_Inner_Squad_Id +ORDER BY [s1].[FullName] """); } - public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) + public override async Task Complex_GroupBy_after_set_operator(bool async) { - await base.Byte_array_filter_by_SequenceEqual(isAsync); + await base.Complex_GroupBy_after_set_operator(async); AssertSql( """ -@byteArrayParam='0x0405060708' (Size = 5) - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE [s].[Banner5] = @byteArrayParam +SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] +FROM ( + SELECT [c].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g] + LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] + UNION ALL + SELECT [c0].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] +) AS [u] +GROUP BY [u].[Name], [u].[Count] """); } - public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) + public override async Task Complex_GroupBy_after_set_operator_using_result_selector(bool async) { - await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); + await base.Complex_GroupBy_after_set_operator_using_result_selector(async); AssertSql( """ -SELECT [w0].[Key] +SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] FROM ( - SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [Key] - FROM [Weapons] AS [w] -) AS [w0] -GROUP BY [w0].[Key] + SELECT [c].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g] + LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] + UNION ALL + SELECT [c0].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] +) AS [u] +GROUP BY [u].[Name], [u].[Count] """); } - public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) + public override async Task Left_join_with_GroupBy_with_composite_group_key(bool async) { - await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); + await base.Left_join_with_GroupBy_with_composite_group_key(async); AssertSql( """ -SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Weapons] AS [w] -GROUP BY [w].[SynergyWithId] +SELECT [g].[CityOfBirthName], [g].[HasSoulPatch] +FROM [Gears] AS [g] +INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +GROUP BY [g].[CityOfBirthName], [g].[HasSoulPatch] """); } - public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) + public override async Task GroupBy_with_boolean_grouping_key(bool async) { - await base.Checked_context_with_cast_does_not_fail(isAsync); + await base.GroupBy_with_boolean_grouping_key(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -WHERE CAST([l].[ThreatLevel] AS tinyint) >= CAST(5 AS tinyint) +SELECT [g0].[CityOfBirthName], [g0].[HasSoulPatch], [g0].[IsMarcus], COUNT(*) AS [Count] +FROM ( + SELECT [g].[CityOfBirthName], [g].[HasSoulPatch], CASE + WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [IsMarcus] + FROM [Gears] AS [g] +) AS [g0] +GROUP BY [g0].[CityOfBirthName], [g0].[HasSoulPatch], [g0].[IsMarcus] """); } - public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) + public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) { - await base.Checked_context_with_addition_does_not_fail(isAsync); + await base.GroupBy_with_boolean_groupin_key_thru_navigation_access(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -WHERE CAST([l].[ThreatLevel] AS bigint) <= CAST(5 AS bigint) + CAST([l].[ThreatLevel] AS bigint) +SELECT [g].[HasSoulPatch], LOWER([s].[Name]) AS [Name] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +GROUP BY [g].[HasSoulPatch], [s].[Name] """); } - public override async Task TimeSpan_Hours(bool async) + public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) { - await base.TimeSpan_Hours(async); + await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); AssertSql( """ -SELECT DATEPART(hour, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [c].[Name] +FROM [Gears] AS [g] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +GROUP BY [c].[Name] """); } - public override async Task TimeSpan_Minutes(bool async) + public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async) { - await base.TimeSpan_Minutes(async); + await base.Group_by_on_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT DATEPART(minute, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [g0].[Key] +FROM ( + SELECT CAST(0 AS bit) AS [Key] + FROM [Gears] AS [g] +) AS [g0] +GROUP BY [g0].[Key] """); } - public override async Task TimeSpan_Seconds(bool async) + public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) { - await base.TimeSpan_Seconds(async); + await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT DATEPART(second, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [g].[FullName] +FROM [Gears] AS [g] +GROUP BY [g].[FullName] +HAVING 0 = 1 """); } - public override async Task TimeSpan_Milliseconds(bool async) + public override async Task Select_StartsWith_with_null_parameter_as_argument(bool async) { - await base.TimeSpan_Milliseconds(async); + await base.Select_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT DATEPART(millisecond, [m].[Duration]) -FROM [Missions] AS [m] +SELECT CAST(0 AS bit) +FROM [Gears] AS [g] """); } - public override async Task Where_TimeSpan_Hours(bool async) + public override async Task Select_null_parameter_is_not_null(bool async) { - await base.Where_TimeSpan_Hours(async); + await base.Select_null_parameter_is_not_null(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Duration]) = 1 +@p='False' + +SELECT @p +FROM [Gears] AS [g] """); } - public override async Task Where_TimeSpan_Minutes(bool async) + public override async Task Where_null_parameter_is_not_null(bool async) { - await base.Where_TimeSpan_Minutes(async); + await base.Where_null_parameter_is_not_null(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Duration]) = 2 +@p='False' + +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 @p = CAST(1 AS bit) """); } - public override async Task Where_TimeSpan_Seconds(bool async) + public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Where_TimeSpan_Seconds(async); + await base.OrderBy_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Duration]) = 3 +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] +ORDER BY [g].[Nickname] """); } - public override async Task Where_TimeSpan_Milliseconds(bool async) + public override async Task OrderBy_Contains_empty_list(bool async) { - await base.Where_TimeSpan_Milliseconds(async); + await base.OrderBy_Contains_empty_list(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Duration]) = 456 +@ids='[]' (Size = 4000) + +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] +ORDER BY CASE + WHEN [g].[SquadId] IN ( + SELECT [i].[value] + FROM OPENJSON(@ids) WITH ([value] int '$') AS [i] + ) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Contains_on_collection_of_byte_subquery(bool async) + public override async Task Where_with_enum_flags_parameter(bool async) { - await base.Contains_on_collection_of_byte_subquery(async); + await base.Where_with_enum_flags_parameter(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -WHERE [l].[ThreatLevelByte] IN ( - SELECT [l0].[ThreatLevelByte] - FROM [LocustLeaders] AS [l0] -) -"""); - } +@rank='1' (Nullable = true) - public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) - { - await base.Contains_on_collection_of_nullable_byte_subquery(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 [g].[Rank] & @rank = @rank +""", + // + """ +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] +""", + // + """ +@rank='2' (Nullable = true) - AssertSql( +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 [g].[Rank] | @rank <> @rank +""", + // """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -WHERE EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) +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 0 = 1 """); } - public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) + public override async Task FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(bool async) { - await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); + await base.FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -WHERE EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] IS NULL) +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] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +WHERE [c].[Name] = ( + SELECT TOP(1) [c0].[Name] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] + ORDER BY [g0].[Nickname]) OR ([c].[Name] IS NULL AND ( + SELECT TOP(1) [c0].[Name] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] + ORDER BY [g0].[Nickname]) IS NULL) """); } - public override async Task Contains_on_collection_of_nullable_byte_subquery_null_parameter(bool async) + public override async Task Bitwise_operation_with_non_null_parameter_optimizes_null_checks(bool async) { - await base.Contains_on_collection_of_nullable_byte_subquery_null_parameter(async); + await base.Bitwise_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -WHERE EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] IS NULL) -"""); - } +@ranks='134' - public override async Task Contains_on_byte_array_property_using_byte_column(bool async) - { - await base.Contains_on_byte_array_property_using_byte_column(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 [g].[Rank] & @ranks <> 0 +""", + // + """ +@ranks='134' - AssertSql( +SELECT ~CAST(([g].[Rank] | @ranks) ^ @ranks AS bit) +FROM [Gears] AS [g] +""", + // """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [Squads] AS [s] -CROSS JOIN [LocustLeaders] AS [l] -WHERE CHARINDEX(CAST([l].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0 +@ranks='134' + +SELECT ~CAST(([g].[Rank] | [g].[Rank] | @ranks | [g].[Rank] | @ranks) ^ @ranks AS bit) +FROM [Gears] AS [g] """); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( - bool async) + public override async Task Bitwise_operation_with_null_arguments(bool async) { - await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); + await base.Bitwise_operation_with_null_arguments(async); AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [LocustLeaders] AS [l] -CROSS APPLY ( - 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 [l].[ThreatLevelByte] IN ( - SELECT [l0].[ThreatLevelByte] - FROM [LocustLeaders] AS [l0] - ) -) AS [g0] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +""", + // + """ +@prm='2' (Nullable = true) + +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] & @prm <> 0 OR [w].[AmmunitionType] IS NULL +""", + // + """ +@prm='1' (Nullable = true) + +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] & @prm = @prm """); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( - bool async) + public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) { - await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); + await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [LocustLeaders] AS [l] -CROSS APPLY ( - 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 [l].[ThreatLevelByte] NOT IN ( - SELECT [l0].[ThreatLevelByte] - FROM [LocustLeaders] AS [l0] - ) -) AS [g0] +@prm='True' + +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 [g].[HasSoulPatch] <> @prm +""", + // + """ +@prm='False' + +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 [g].[HasSoulPatch] <> @prm """); } - public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) + public override async Task Cast_OfType_works_correctly(bool async) { - await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async); + await base.Cast_OfType_works_correctly(async); AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [LocustLeaders] AS [l] -CROSS APPLY ( - 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 EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) -) AS [g0] +SELECT [g].[FullName] +FROM [Gears] AS [g] +WHERE [g].[Discriminator] = N'Officer' """); } - public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) + public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) { - await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async); + await base.Join_inner_source_custom_projection_followed_by_filter(async); AssertSql( """ -SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +SELECT CASE + WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) +END AS [IsEradicated], [f].[CommanderName], [f].[Name] FROM [LocustLeaders] AS [l] -CROSS APPLY ( - 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 NOT EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) -) AS [g0] +INNER JOIN [Factions] AS [f] ON [l].[Name] = [f].[CommanderName] +WHERE CASE + WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) +END = CAST(0 AS bit) OR CASE + WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) +END IS NULL """); } - public override async Task Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) + public override async Task Byte_array_contains_literal(bool async) { - await base.Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(async); + await base.Byte_array_contains_literal(async); AssertSql( """ -@prm='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE @prm = [w].[AmmunitionType] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CHARINDEX(0x01, [s].[Banner]) > 0 """); } - public override async Task Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) + public override async Task Byte_array_filter_by_length_literal(bool async) { - await base.Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(async); + await base.Byte_array_filter_by_length_literal(async); AssertSql( """ -@prm='133' - -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 @prm & [g].[Rank] = [g].[Rank] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = 2 """); } - public override async Task Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(bool async) + public override async Task Byte_array_filter_by_length_parameter(bool async) { - await base.Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(async); + await base.Byte_array_filter_by_length_parameter(async); AssertSql( """ -@prm='5' +@p='2' -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 @prm & CAST([g].[Rank] AS int) = CAST([g].[Rank] AS int) +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = @p """); } - public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) + public override void Byte_array_filter_by_length_parameter_compiled() { - await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); + base.Byte_array_filter_by_length_parameter_compiled(); AssertSql( """ -@p='1' +@byteArrayParam='0x2A80' (Size = 8000) -SELECT TOP(@p) [g].[Rank] & 1 -FROM [Gears] AS [g] -ORDER BY [g].[Nickname] +SELECT COUNT(*) +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@byteArrayParam) AS int) """); } - public override async Task Enum_array_contains(bool async) + public override async Task Byte_array_contains_parameter(bool async) { - await base.Enum_array_contains(async); + await base.Byte_array_contains_parameter(async); AssertSql( """ -@types_without_nulls='[1]' (Size = 4000) +@someByte='1' (Size = 1) -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -WHERE [w0].[Id] IS NOT NULL AND ([w0].[AmmunitionType] IN ( - SELECT [t].[value] - FROM OPENJSON(@types_without_nulls) AS [t] -) OR [w0].[AmmunitionType] IS NULL) +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CHARINDEX(CAST(@someByte AS varbinary(max)), [s].[Banner]) > 0 """); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public async Task DataLength_function_for_string_parameter(bool async) + public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) { - await AssertQueryScalar( - async, - ss => ss.Set().Select(m => EF.Functions.DataLength(m.CodeName)), - ss => ss.Set().Select(m => (int?)(m.CodeName.Length * 2))); + await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); AssertSql( """ -SELECT CAST(DATALENGTH([m].[CodeName]) AS int) -FROM [Missions] AS [m] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE DATALENGTH([s].[Banner5]) = 5 """); } - public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) + public override async Task Conditional_expression_with_test_being_simplified_to_constant_simple(bool isAsync) { - await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); + await base.Conditional_expression_with_test_being_simplified_to_constant_simple(isAsync); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' -"""); - } - - public override async Task Coalesce_used_with_non_unicode_string_column_and_constant(bool async) - { - await base.Coalesce_used_with_non_unicode_string_column_and_constant(async); +@prm='True' - AssertSql( - """ -SELECT COALESCE([c].[Location], 'Unknown') -FROM [Cities] AS [c] +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].[HasSoulPatch] = @prm THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(bool async) + public override async Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) { - await base.Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(async); + await base.Conditional_expression_with_test_being_simplified_to_constant_complex(isAsync); AssertSql( """ -SELECT [c].[Name], [c].[Location], COUNT(*) AS [Count] -FROM [Weapons] AS [w] -LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] -LEFT JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -GROUP BY [c].[Name], [c].[Location] -ORDER BY [c].[Location] -"""); - } - - public override async Task SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(bool async) - { - await base.SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(async); +@prm='True' +@prm2='Marcus' Lancer' (Size = 4000) - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +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] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL -ORDER BY [g].[Nickname], [w].[Id] +WHERE CASE + WHEN [g].[HasSoulPatch] = @prm AND ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [w].[Id] = [g].[SquadId]) = @prm2 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) + public override async Task OrderBy_bool_coming_from_optional_navigation(bool async) { - await base.SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); + await base.OrderBy_bool_coming_from_optional_navigation(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL -ORDER BY [g].[Nickname], [w].[Id] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w0].[IsAutomatic] """); } - public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( - bool async) + public override async Task DateTimeOffset_Date_returns_datetime(bool async) { - await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); + await base.DateTimeOffset_Date_returns_datetime(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w] - LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [g].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL -ORDER BY [g].[Nickname], [s].[Id] +@dateTimeOffset_Date='0002-03-01T00:00:00.0000000' + +SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE CONVERT(date, [m].[Timeline]) >= @dateTimeOffset_Date """); } - public override async Task SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(bool async) + public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async) { - await base.SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(async); + await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [g].[FullName] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(bool async) + public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(async); + await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [g].[CityOfBirthName] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] < [w].[Id] -ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(bool async) + public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(async); + await base.Projecting_required_string_column_compared_to_null_parameter(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT CAST(0 AS bit) FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] <= [w].[Id] -ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(bool async) + public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(async); + await base.Byte_array_filter_by_SequenceEqual(isAsync); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] >= [w].[Id] -ORDER BY [g].[Nickname], [g].[SquadId] +@byteArrayParam='0x0405060708' (Size = 5) + +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Banner5] = @byteArrayParam """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) + public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) { - await base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async); + await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -CROSS APPLY ( - SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w0].[Key] +FROM ( + SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [Key] FROM [Weapons] AS [w] - WHERE [w].[OwnerFullName] <> [g].[FullName] OR [w].[OwnerFullName] IS NULL - ORDER BY [w].[Id] ) AS [w0] -ORDER BY [g].[Nickname], [w0].[Id] +GROUP BY [w0].[Key] """); } - public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) + public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) { - await base.FirstOrDefault_over_int_compared_to_zero(async); + await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); AssertSql( """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Delta' AND COALESCE(( - SELECT TOP(1) [g].[SquadId] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit) - ORDER BY [g].[FullName]), 0) <> 0 +SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Weapons] AS [w] +GROUP BY [w].[SynergyWithId] """); } - public override async Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async) + public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) { - await base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async); + await base.Checked_context_with_cast_does_not_fail(isAsync); AssertSql( """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [g1].[ReportName], [g1].[OfficerName], [g1].[Nickname], [g1].[SquadId] -FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -) AS [g1] -WHERE [g].[Discriminator] = N'Officer' -ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +WHERE CAST([l].[ThreatLevel] AS tinyint) >= CAST(5 AS tinyint) """); } - public override async Task Accessing_derived_property_using_hard_and_soft_cast(bool async) + public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) { - await base.Accessing_derived_property_using_hard_and_soft_cast(async); + await base.Checked_context_with_addition_does_not_fail(isAsync); AssertSql( """ SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] -WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) -""", - // +WHERE CAST([l].[ThreatLevel] AS bigint) <= CAST(5 AS bigint) + CAST([l].[ThreatLevel] AS bigint) +"""); + } + + public override async Task Contains_on_collection_of_byte_subquery(bool async) + { + await base.Contains_on_collection_of_byte_subquery(async); + + AssertSql( """ SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] -WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) +WHERE [l].[ThreatLevelByte] IN ( + SELECT [l0].[ThreatLevelByte] + FROM [LocustLeaders] AS [l0] +) """); } - public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) { - await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); + await base.Contains_on_collection_of_nullable_byte_subquery(async); AssertSql( """ -SELECT TOP(1) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] -WHERE [l].[Name] LIKE N'%Queen%' +WHERE EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l0] + WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) """); } - public override async Task Correlated_collection_take(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) { - await base.Correlated_collection_take(async); + await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [c].[Location], [c].[Nation] -FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] - FROM [Weapons] AS [w] - ) AS [w0] - WHERE [w0].[row] <= 10 -) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +WHERE EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l0] + WHERE [l0].[ThreatLevelNullableByte] IS NULL) """); } - public override async Task FirstOrDefault_on_empty_collection_of_DateTime_in_subquery(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery_null_parameter(bool async) { - await base.FirstOrDefault_on_empty_collection_of_DateTime_in_subquery(async); + await base.Contains_on_collection_of_nullable_byte_subquery_null_parameter(async); AssertSql( """ -SELECT [g].[Nickname], COALESCE(( - SELECT TOP(1) [t1].[IssueDate] - FROM [Tags] AS [t1] - WHERE [t1].[GearNickName] = [g].[FullName] - ORDER BY [t1].[Id]), '0001-01-01T00:00:00.0000000') AS [invalidTagIssueDate] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[IssueDate] > COALESCE(( - SELECT TOP(1) [t0].[IssueDate] - FROM [Tags] AS [t0] - WHERE [t0].[GearNickName] = [g].[FullName] - ORDER BY [t0].[Id]), '0001-01-01T00:00:00.0000000') +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +WHERE EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l0] + WHERE [l0].[ThreatLevelNullableByte] IS NULL) """); } - public override async Task First_on_byte_array(bool async) + public override async Task Contains_on_byte_array_property_using_byte_column(bool async) { - await base.First_on_byte_array(async); + await base.Contains_on_byte_array_property_using_byte_column(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [Squads] AS [s] -WHERE CAST(SUBSTRING([s].[Banner], 1, 1) AS tinyint) = CAST(2 AS tinyint) +CROSS JOIN [LocustLeaders] AS [l] +WHERE CHARINDEX(CAST([l].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0 """); } - public override async Task Array_access_on_byte_array(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( + bool async) { - await base.Array_access_on_byte_array(async); + await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(SUBSTRING([s].[Banner5], 2 + 1, 1) AS tinyint) = CAST(6 AS tinyint) +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [LocustLeaders] AS [l] +CROSS APPLY ( + 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 [l].[ThreatLevelByte] IN ( + SELECT [l0].[ThreatLevelByte] + FROM [LocustLeaders] AS [l0] + ) +) AS [g0] """); } - public override async Task Project_shadow_properties(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) { - await base.Project_shadow_properties(async); + await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); AssertSql( """ -SELECT [g].[Nickname], [g].[AssignedCityName] -FROM [Gears] AS [g] +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [LocustLeaders] AS [l] +CROSS APPLY ( + 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 [l].[ThreatLevelByte] NOT IN ( + SELECT [l0].[ThreatLevelByte] + FROM [LocustLeaders] AS [l0] + ) +) AS [g0] """); } - public override async Task Project_discriminator_columns(bool async) + public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) { - await base.Project_discriminator_columns(async); + await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async); AssertSql( """ -SELECT [g].[Nickname], [g].[Discriminator] -FROM [Gears] AS [g] -""", - // - """ -SELECT [g].[Nickname], [g].[Discriminator] -FROM [Gears] AS [g] -WHERE [g].[Discriminator] = N'Officer' -""", - // - """ -SELECT [f].[Id], [f].[Discriminator] -FROM [Factions] AS [f] -""", - // - """ -SELECT [f].[Id], [f].[Discriminator] -FROM [Factions] AS [f] -""", - // - """ -SELECT [l].[Name], [l].[Discriminator] -FROM [LocustLeaders] AS [l] -""", - // - """ -SELECT [l].[Name], [l].[Discriminator] +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [LocustLeaders] AS [l] -WHERE [l].[Discriminator] = N'LocustCommander' +CROSS APPLY ( + 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 EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l0] + WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) +) AS [g0] """); } - public override async Task Composite_key_entity_equal(bool async) + public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) { - await base.Composite_key_entity_equal(async); + await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] -FROM [Gears] AS [g] -CROSS JOIN [Gears] AS [g0] -WHERE [g].[Nickname] = [g0].[Nickname] AND [g].[SquadId] = [g0].[SquadId] +SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +FROM [LocustLeaders] AS [l] +CROSS APPLY ( + 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 NOT EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l0] + WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) +) AS [g0] +"""); + } + + public override async Task Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) + { + await base.Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(async); + + AssertSql( + """ +@prm='1' (Nullable = true) + +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE @prm = [w].[AmmunitionType] """); } - public override async Task Composite_key_entity_not_equal(bool async) + public override async Task Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) { - await base.Composite_key_entity_not_equal(async); + await base.Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] +@prm='133' + +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] -CROSS JOIN [Gears] AS [g0] -WHERE [g].[Nickname] <> [g0].[Nickname] OR [g].[SquadId] <> [g0].[SquadId] +WHERE @prm & [g].[Rank] = [g].[Rank] """); } - public override async Task Composite_key_entity_equal_null(bool async) + public override async Task Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(bool async) { - await base.Composite_key_entity_equal_null(async); + await base.Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] -WHERE [l].[Discriminator] = N'LocustCommander' AND ([g].[Nickname] IS NULL OR [g].[SquadId] IS NULL) +@prm='5' + +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 @prm & CAST([g].[Rank] AS int) = CAST([g].[Rank] AS int) """); } - public override async Task Composite_key_entity_not_equal_null(bool async) + public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) { - await base.Composite_key_entity_not_equal_null(async); + await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); AssertSql( """ -SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] -FROM [LocustLeaders] AS [l] -LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] -WHERE [l].[Discriminator] = N'LocustCommander' AND [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL +@p='1' + +SELECT TOP(@p) [g].[Rank] & 1 +FROM [Gears] AS [g] +ORDER BY [g].[Nickname] """); } - [ConditionalFact] - [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] - public async Task FreeText_with_binary_column() + public override async Task Enum_array_contains(bool async) { - using var context = CreateContext(); - var result = await context.Missions.SingleAsync( - e => EF.Functions.FreeText(EF.Property(e, "BriefingDocument"), "bombing")); - - Assert.Equal(1, result.Id); + await base.Enum_array_contains(async); AssertSql( """ -SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE FREETEXT([m].[BriefingDocument], N'bombing') +@types_without_nulls='[1]' (Size = 4000) + +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +WHERE [w0].[Id] IS NOT NULL AND ([w0].[AmmunitionType] IN ( + SELECT [t].[value] + FROM OPENJSON(@types_without_nulls) AS [t] +) OR [w0].[AmmunitionType] IS NULL) """); } - [ConditionalFact] - [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] - public async Task FreeText_with_binary_column_and_language_term() + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DataLength_function_for_string_parameter(bool async) { - using var context = CreateContext(); - var result = await context.Missions.SingleAsync( - e => EF.Functions.FreeText(EF.Property(e, "BriefingDocument"), "bombing", 1033)); - - Assert.Equal(1, result.Id); + await AssertQueryScalar( + async, + ss => ss.Set().Select(m => EF.Functions.DataLength(m.CodeName)), + ss => ss.Set().Select(m => (int?)(m.CodeName.Length * 2))); AssertSql( """ -SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT CAST(DATALENGTH([m].[CodeName]) AS int) FROM [Missions] AS [m] -WHERE FREETEXT([m].[BriefingDocument], N'bombing', LANGUAGE 1033) """); } - [ConditionalFact] - [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] - public async Task Contains_with_binary_column() + public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) { - using var context = CreateContext(); - var result = await context.Missions.SingleAsync(e => EF.Functions.Contains(EF.Property(e, "BriefingDocument"), "bomb")); - - Assert.Equal(1, result.Id); + await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); AssertSql( """ -SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONTAINS([m].[BriefingDocument], N'bomb') +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' """); } - [ConditionalFact] - [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] - public async Task Contains_with_binary_column_and_language_term() + public override async Task Coalesce_used_with_non_unicode_string_column_and_constant(bool async) { - using var context = CreateContext(); - var result = await context.Missions.SingleAsync( - e => EF.Functions.Contains(EF.Property(e, "BriefingDocument"), "bomb", 1033)); - - Assert.Equal(1, result.Id); + await base.Coalesce_used_with_non_unicode_string_column_and_constant(async); AssertSql( """ -SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONTAINS([m].[BriefingDocument], N'bomb', LANGUAGE 1033) +SELECT COALESCE([c].[Location], 'Unknown') +FROM [Cities] AS [c] """); } - public override async Task Projecting_property_converted_to_nullable_with_comparison(bool async) + public override async Task Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(bool async) { - await base.Projecting_property_converted_to_nullable_with_comparison(async); + await base.Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END = 1 +SELECT [c].[Name], [c].[Location], COUNT(*) AS [Count] +FROM [Weapons] AS [w] +LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] +LEFT JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +GROUP BY [c].[Name], [c].[Location] +ORDER BY [c].[Location] """); } - public override async Task Projecting_property_converted_to_nullable_with_addition(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(bool async) { - await base.Projecting_property_converted_to_nullable_with_addition(async); + await base.SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END + 1 = 2 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +INNER JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +ORDER BY [g].[Nickname], [w].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_with_addition_and_final_projection(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) { - await base.Projecting_property_converted_to_nullable_with_addition_and_final_projection(async); + await base.SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END + 1 AS [Value] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END IS NOT NULL +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +ORDER BY [g].[Nickname], [w].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_with_conditional(bool async) + public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( + bool async) { - await base.Projecting_property_converted_to_nullable_with_conditional(async); + await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( """ -SELECT CASE - WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] - END - ELSE -1 -END -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w] + LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +) AS [s] ON [g].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL +ORDER BY [g].[Nickname], [s].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_with_function_call(bool async) + public override async Task SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(bool async) { - await base.Projecting_property_converted_to_nullable_with_function_call(async); + await base.SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(async); AssertSql( """ -SELECT SUBSTRING(CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END, 0 + 1, 3) -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL """); } - public override async Task Projecting_property_converted_to_nullable_with_function_call2(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(bool async) { - await base.Projecting_property_converted_to_nullable_with_function_call2(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(async); AssertSql( """ -SELECT [t].[Note], SUBSTRING([t].[Note], 0 + 1, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END) AS [Function] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END IS NOT NULL +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] < [w].[Id] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Projecting_property_converted_to_nullable_into_element_init(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(bool async) { - await base.Projecting_property_converted_to_nullable_into_element_init(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([g].[Nickname]) AS int) -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END + 1 -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] <= [w].[Id] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Projecting_property_converted_to_nullable_into_member_assignment(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(bool async) { - await base.Projecting_property_converted_to_nullable_into_member_assignment(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END AS [Id] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] >= [w].[Id] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Projecting_property_converted_to_nullable_into_new_array(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) { - await base.Projecting_property_converted_to_nullable_into_new_array(async); + await base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([g].[Nickname]) AS int) -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END + 1 -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +CROSS APPLY ( + SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[OwnerFullName] <> [g].[FullName] OR [w].[OwnerFullName] IS NULL + ORDER BY [w].[Id] +) AS [w0] +ORDER BY [g].[Nickname], [w0].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) + public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) { - await base.Projecting_property_converted_to_nullable_into_unary(async); + await base.FirstOrDefault_over_int_compared_to_zero(async); AssertSql( """ -SELECT [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END IS NOT NULL AND CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[HasSoulPatch] -END = CAST(0 AS bit) -ORDER BY [t].[Note] +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Delta' AND COALESCE(( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit) + ORDER BY [g].[FullName]), 0) <> 0 """); } - public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) + public override async Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async) { - await base.Projecting_property_converted_to_nullable_into_member_access(async); + await base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async); AssertSql( """ -SELECT [g].[Nickname] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [g1].[ReportName], [g1].[OfficerName], [g1].[Nickname], [g1].[SquadId] FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL -ORDER BY [g].[Nickname] +OUTER APPLY ( + SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +) AS [g1] +WHERE [g].[Discriminator] = N'Officer' +ORDER BY [g].[Nickname], [g].[SquadId], [g1].[Nickname] """); } - public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) + public override async Task Accessing_derived_property_using_hard_and_soft_cast(bool async) { - await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); + await base.Accessing_derived_property_using_hard_and_soft_cast(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] -END IS NOT NULL -ORDER BY CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] -END, [t].[Note] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) +""", + // + """ +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +WHERE [l].[Discriminator] = N'LocustCommander' AND ([l].[HighCommandId] <> 0 OR [l].[HighCommandId] IS NULL) """); } - public override async Task Correlated_collection_with_distinct_projecting_identifier_column(bool async) + public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) { - await base.Correlated_collection_with_distinct_projecting_identifier_column(async); + await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[Name] -FROM [Gears] AS [g] -OUTER APPLY ( - SELECT DISTINCT [w].[Id], [w].[Name] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] -) AS [w0] -ORDER BY [g].[Nickname], [g].[SquadId] +SELECT TOP(1) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +WHERE [l].[Name] LIKE N'%Queen%' """); } - public override async Task Correlated_collection_with_distinct_projecting_identifier_column_and_correlation_key(bool async) + public override async Task Correlated_collection_take(bool async) { - await base.Correlated_collection_with_distinct_projecting_identifier_column_and_correlation_key(async); + await base.Correlated_collection_take(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[Name], [w0].[OwnerFullName] +SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [c].[Location], [c].[Nation] FROM [Gears] AS [g] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN ( - SELECT DISTINCT [w].[Id], [w].[Name], [w].[OwnerFullName] - FROM [Weapons] AS [w] -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId] + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] + FROM [Weapons] AS [w] + ) AS [w0] + WHERE [w0].[row] <= 10 +) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] """); } - public override async Task Correlated_collection_with_distinct_projecting_identifier_column_composite_key(bool async) + public override async Task FirstOrDefault_on_empty_collection_of_DateTime_in_subquery(bool async) { - await base.Correlated_collection_with_distinct_projecting_identifier_column_composite_key(async); + await base.FirstOrDefault_on_empty_collection_of_DateTime_in_subquery(async); AssertSql( """ -SELECT [s].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[HasSoulPatch] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [g0] ON [s].[Id] = [g0].[SquadId] -ORDER BY [s].[Id], [g0].[Nickname] +SELECT [g].[Nickname], COALESCE(( + SELECT TOP(1) [t1].[IssueDate] + FROM [Tags] AS [t1] + WHERE [t1].[GearNickName] = [g].[FullName] + ORDER BY [t1].[Id]), '0001-01-01T00:00:00.0000000') AS [invalidTagIssueDate] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [t].[IssueDate] > COALESCE(( + SELECT TOP(1) [t0].[IssueDate] + FROM [Tags] AS [t0] + WHERE [t0].[GearNickName] = [g].[FullName] + ORDER BY [t0].[Id]), '0001-01-01T00:00:00.0000000') """); } - public override async Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async) + public override async Task Project_shadow_properties(bool async) { - await base.Correlated_collection_with_distinct_not_projecting_identifier_column(async); + await base.Project_shadow_properties(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[IsAutomatic] +SELECT [g].[Nickname], [g].[AssignedCityName] FROM [Gears] AS [g] -OUTER APPLY ( - SELECT DISTINCT [w].[Name], [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] -) AS [w0] -ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] """); } - public override async Task - Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(bool async) + public override async Task Project_discriminator_columns(bool async) { - await base.Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(async); + await base.Project_discriminator_columns(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Key] +SELECT [g].[Nickname], [g].[Discriminator] FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [w].[IsAutomatic] AS [Key] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - GROUP BY [w].[IsAutomatic] -) AS [w0] -ORDER BY [g].[Nickname], [g].[SquadId] +""", + // + """ +SELECT [g].[Nickname], [g].[Discriminator] +FROM [Gears] AS [g] +WHERE [g].[Discriminator] = N'Officer' +""", + // + """ +SELECT [f].[Id], [f].[Discriminator] +FROM [Factions] AS [f] +""", + // + """ +SELECT [f].[Id], [f].[Discriminator] +FROM [Factions] AS [f] +""", + // + """ +SELECT [l].[Name], [l].[Discriminator] +FROM [LocustLeaders] AS [l] +""", + // + """ +SELECT [l].[Name], [l].[Discriminator] +FROM [LocustLeaders] AS [l] +WHERE [l].[Discriminator] = N'LocustCommander' """); } - public override async Task - Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async) + public override async Task Composite_key_entity_equal(bool async) { - await base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async); + await base.Composite_key_entity_equal(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Key], [w0].[Count] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [w].[IsAutomatic] AS [Key], COUNT(*) AS [Count] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - GROUP BY [w].[IsAutomatic] -) AS [w0] -ORDER BY [g].[Nickname], [g].[SquadId] +CROSS JOIN [Gears] AS [g0] +WHERE [g].[Nickname] = [g0].[Nickname] AND [g].[SquadId] = [g0].[SquadId] """); } - public override async Task - Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys( - bool async) + public override async Task Composite_key_entity_not_equal(bool async) { - await base - .Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys( - async); + await base.Composite_key_entity_not_equal(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[IsAutomatic], [w0].[Name], [w0].[Count] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [w].[IsAutomatic], [w].[Name], COUNT(*) AS [Count] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - GROUP BY [w].[IsAutomatic], [w].[Name] -) AS [w0] -ORDER BY [g].[Nickname], [g].[SquadId], [w0].[IsAutomatic] +CROSS JOIN [Gears] AS [g0] +WHERE [g].[Nickname] <> [g0].[Nickname] OR [g].[SquadId] <> [g0].[SquadId] """); } - public override async Task - Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection( - bool async) + public override async Task Composite_key_entity_equal_null(bool async) { - await base - .Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection( - async); + await base.Composite_key_entity_equal_null(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w1].[Key], [w1].[Count] -FROM [Gears] AS [g] -OUTER APPLY ( - SELECT [w0].[Key], COUNT(*) AS [Count] - FROM ( - SELECT CAST(LEN([w].[Name]) AS int) AS [Key] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - GROUP BY [w0].[Key] -) AS [w1] -ORDER BY [g].[Nickname], [g].[SquadId] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +WHERE [l].[Discriminator] = N'LocustCommander' AND ([g].[Nickname] IS NULL OR [g].[SquadId] IS NULL) """); } - public override async Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async) + public override async Task Composite_key_entity_not_equal_null(bool async) { - await base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async); + await base.Composite_key_entity_not_equal_null(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[HasSoulPatch] -FROM [Gears] AS [g] -OUTER APPLY ( - SELECT DISTINCT [g1].[HasSoulPatch] - FROM [Weapons] AS [w] - LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] - LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] - INNER JOIN [Gears] AS [g1] ON [c].[Name] = [g1].[CityOfBirthName] - WHERE [g].[FullName] = [w].[OwnerFullName] -) AS [s] -ORDER BY [g].[Nickname], [g].[SquadId] +SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] +FROM [LocustLeaders] AS [l] +LEFT JOIN [Gears] AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] +WHERE [l].[Discriminator] = N'LocustCommander' AND [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL """); } - public override async Task Correlated_collection_after_distinct_3_levels(bool async) + [ConditionalFact] + [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] + public async Task FreeText_with_binary_column() { - await base.Correlated_collection_after_distinct_3_levels(async); + using var context = CreateContext(); + var result = await context.Missions.SingleAsync( + e => EF.Functions.FreeText(EF.Property(e, "BriefingDocument"), "bombing")); + + Assert.Equal(1, result.Id); AssertSql( """ -SELECT [s0].[Id], [s0].[Name], [s1].[Nickname], [s1].[FullName], [s1].[HasSoulPatch], [s1].[Id], [s1].[Name], [s1].[Nickname0], [s1].[FullName0], [s1].[HasSoulPatch0], [s1].[Id0] -FROM ( - SELECT DISTINCT [s].[Id], [s].[Name] - FROM [Squads] AS [s] -) AS [s0] -OUTER APPLY ( - SELECT [g0].[Nickname], [g0].[FullName], [g0].[HasSoulPatch], [w0].[Id], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[FullName] AS [FullName0], [w0].[HasSoulPatch] AS [HasSoulPatch0], [w0].[Id0] - FROM ( - SELECT DISTINCT [g].[Nickname], [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - WHERE [g].[SquadId] = [s0].[Id] - ) AS [g0] - OUTER APPLY ( - SELECT [s0].[Id], [s0].[Name], [g0].[Nickname], [g0].[FullName], [g0].[HasSoulPatch], [w].[Id] AS [Id0] - FROM [Weapons] AS [w] - WHERE [w].[OwnerFullName] = [g0].[FullName] - ) AS [w0] -) AS [s1] -ORDER BY [s0].[Id], [s1].[Nickname], [s1].[FullName], [s1].[HasSoulPatch] +SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE FREETEXT([m].[BriefingDocument], N'bombing') """); } - public override async Task Correlated_collection_after_distinct_3_levels_without_original_identifiers(bool async) + [ConditionalFact] + [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] + public async Task FreeText_with_binary_column_and_language_term() { - await base.Correlated_collection_after_distinct_3_levels_without_original_identifiers(async); + using var context = CreateContext(); + var result = await context.Missions.SingleAsync( + e => EF.Functions.FreeText(EF.Property(e, "BriefingDocument"), "bombing", 1033)); - AssertSql(); + Assert.Equal(1, result.Id); + + AssertSql( + """ +SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE FREETEXT([m].[BriefingDocument], N'bombing', LANGUAGE 1033) +"""); } - public override async Task Where_DateOnly_Year(bool async) + [ConditionalFact] + [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] + public async Task Contains_with_binary_column() { - await base.Where_DateOnly_Year(async); + using var context = CreateContext(); + var result = await context.Missions.SingleAsync(e => EF.Functions.Contains(EF.Property(e, "BriefingDocument"), "bomb")); + + Assert.Equal(1, result.Id); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] -WHERE DATEPART(year, [m].[Date]) = 1990 +WHERE CONTAINS([m].[BriefingDocument], N'bomb') """); } - public override async Task Where_DateOnly_Month(bool async) + [ConditionalFact] + [SqlServerCondition(SqlServerCondition.SupportsFullTextSearch)] + public async Task Contains_with_binary_column_and_language_term() { - await base.Where_DateOnly_Month(async); + using var context = CreateContext(); + var result = await context.Missions.SingleAsync( + e => EF.Functions.Contains(EF.Property(e, "BriefingDocument"), "bomb", 1033)); + + Assert.Equal(1, result.Id); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +SELECT TOP(2) [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] -WHERE DATEPART(month, [m].[Date]) = 11 +WHERE CONTAINS([m].[BriefingDocument], N'bomb', LANGUAGE 1033) """); } - public override async Task Where_DateOnly_Day(bool async) + public override async Task Projecting_property_converted_to_nullable_with_comparison(bool async) { - await base.Where_DateOnly_Day(async); + await base.Projecting_property_converted_to_nullable_with_comparison(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(day, [m].[Date]) = 10 +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END = 1 """); } - public override async Task Where_DateOnly_DayOfYear(bool async) + public override async Task Projecting_property_converted_to_nullable_with_addition(bool async) { - await base.Where_DateOnly_DayOfYear(async); + await base.Projecting_property_converted_to_nullable_with_addition(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(dayofyear, [m].[Date]) = 314 +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END + 1 = 2 """); } - public override async Task Where_DateOnly_DayOfWeek(bool async) + public override async Task Projecting_property_converted_to_nullable_with_addition_and_final_projection(bool async) { - await AssertTranslationFailed(() => base.Where_DateOnly_DayOfWeek(async)); + await base.Projecting_property_converted_to_nullable_with_addition_and_final_projection(async); - AssertSql(); + AssertSql( + """ +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END + 1 AS [Value] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END IS NOT NULL +"""); } - public override async Task Where_DateOnly_AddYears(bool async) + public override async Task Projecting_property_converted_to_nullable_with_conditional(bool async) { - await base.Where_DateOnly_AddYears(async); + await base.Projecting_property_converted_to_nullable_with_conditional(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' +SELECT CASE + WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] + END + ELSE -1 +END +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Where_DateOnly_AddMonths(bool async) + public override async Task Projecting_property_converted_to_nullable_with_function_call(bool async) { - await base.Where_DateOnly_AddMonths(async); + await base.Projecting_property_converted_to_nullable_with_function_call(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' +SELECT SUBSTRING(CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END, 0 + 1, 3) +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] """); } - public override async Task Where_DateOnly_AddDays(bool async) + public override async Task Projecting_property_converted_to_nullable_with_function_call2(bool async) { - await base.Where_DateOnly_AddDays(async); + await base.Projecting_property_converted_to_nullable_with_function_call2(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' +SELECT [t].[Note], SUBSTRING([t].[Note], 0 + 1, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END) AS [Function] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END IS NOT NULL """); } - public override async Task Where_TimeOnly_Hour(bool async) + public override async Task Projecting_property_converted_to_nullable_into_element_init(bool async) { - await base.Where_TimeOnly_Hour(async); + await base.Projecting_property_converted_to_nullable_into_element_init(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Time]) = 10 +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([g].[Nickname]) AS int) +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END + 1 +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_Minute(bool async) + public override async Task Projecting_property_converted_to_nullable_into_member_assignment(bool async) { - await base.Where_TimeOnly_Minute(async); + await base.Projecting_property_converted_to_nullable_into_member_assignment(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Time]) = 15 +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END AS [Id] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_Second(bool async) + public override async Task Projecting_property_converted_to_nullable_into_new_array(bool async) { - await base.Where_TimeOnly_Second(async); + await base.Projecting_property_converted_to_nullable_into_new_array(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Time]) = 50 +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([g].[Nickname]) AS int) +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END + 1 +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_Millisecond(bool async) + public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) { - await base.Where_TimeOnly_Millisecond(async); + await base.Projecting_property_converted_to_nullable_into_unary(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Time]) = 500 +SELECT [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END IS NOT NULL AND CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[HasSoulPatch] +END = CAST(0 AS bit) +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_AddHours(bool async) + public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) { - await base.Where_TimeOnly_AddHours(async); + await base.Projecting_property_converted_to_nullable_into_member_access(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' +SELECT [g].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL +ORDER BY [g].[Nickname] """); } - public override async Task Where_TimeOnly_AddMinutes(bool async) + public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) { - await base.Where_TimeOnly_AddMinutes(async); + await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +FROM [Tags] AS [t] +LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[Nickname] +END IS NOT NULL +ORDER BY CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [g].[SquadId] +END, [t].[Note] """); } - public override async Task Where_TimeOnly_Add_TimeSpan(bool async) + public override async Task Correlated_collection_with_distinct_projecting_identifier_column(bool async) { - await AssertTranslationFailed(() => base.Where_TimeOnly_Add_TimeSpan(async)); + await base.Correlated_collection_with_distinct_projecting_identifier_column(async); - AssertSql(); + AssertSql( + """ +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[Name] +FROM [Gears] AS [g] +OUTER APPLY ( + SELECT DISTINCT [w].[Id], [w].[Name] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] +) AS [w0] +ORDER BY [g].[Nickname], [g].[SquadId] +"""); } - public override async Task Where_TimeOnly_IsBetween(bool async) + public override async Task Correlated_collection_with_distinct_projecting_identifier_column_and_correlation_key(bool async) { - await base.Where_TimeOnly_IsBetween(async); + await base.Correlated_collection_with_distinct_projecting_identifier_column_and_correlation_key(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CASE - WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END & CASE - WHEN [m].[Time] < '11:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[Name], [w0].[OwnerFullName] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT DISTINCT [w].[Id], [w].[Name], [w].[OwnerFullName] + FROM [Weapons] AS [w] +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Where_TimeOnly_subtract_TimeOnly(bool async) + public override async Task Correlated_collection_with_distinct_projecting_identifier_column_composite_key(bool async) { - await AssertTranslationFailed(() => base.Where_TimeOnly_subtract_TimeOnly(async)); + await base.Correlated_collection_with_distinct_projecting_identifier_column_composite_key(async); - AssertSql(); + AssertSql( + """ +SELECT [s].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[HasSoulPatch] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [g0] ON [s].[Id] = [g0].[SquadId] +ORDER BY [s].[Id], [g0].[Nickname] +"""); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) + public override async Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_property(async); + await base.Correlated_collection_with_distinct_not_projecting_identifier_column(async); AssertSql( """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] -FROM [Tags] AS [t] -CROSS JOIN [Missions] AS [m] -WHERE CAST([t].[IssueDate] AS time) = [m].[Time] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[IsAutomatic] +FROM [Gears] AS [g] +OUTER APPLY ( + SELECT DISTINCT [w].[Name], [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] +) AS [w0] +ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] """); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) + public override async Task + Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); + await base.Correlated_collection_with_groupby_not_projecting_identifier_column_but_only_grouping_key_in_final_projection(async); AssertSql( """ -@time='02:00' (DbType = Time) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] AND [t].[GearSquadId] = [g].[SquadId] -WHERE [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL AND CAST(DATEADD(hour, CAST(CAST([g].[SquadId] AS float) AS int), [t].[IssueDate]) AS time) = @time +SELECT [g].[Nickname], [g].[SquadId], [w0].[Key] +FROM [Gears] AS [g] +OUTER APPLY ( + SELECT [w].[IsAutomatic] AS [Key] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + GROUP BY [w].[IsAutomatic] +) AS [w0] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) + public override async Task + Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); + await base.Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' +SELECT [g].[Nickname], [g].[SquadId], [w0].[Key], [w0].[Count] +FROM [Gears] AS [g] +OUTER APPLY ( + SELECT [w].[IsAutomatic] AS [Key], COUNT(*) AS [Count] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + GROUP BY [w].[IsAutomatic] +) AS [w0] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) + public override async Task + Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys( + bool async) { - await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); + await base + .Correlated_collection_with_groupby_not_projecting_identifier_column_with_group_aggregate_in_final_projection_multiple_grouping_keys( + async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CAST([m].[Duration] AS time) < [m].[Time] +SELECT [g].[Nickname], [g].[SquadId], [w0].[IsAutomatic], [w0].[Name], [w0].[Count] +FROM [Gears] AS [g] +OUTER APPLY ( + SELECT [w].[IsAutomatic], [w].[Name], COUNT(*) AS [Count] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + GROUP BY [w].[IsAutomatic], [w].[Name] +) AS [w0] +ORDER BY [g].[Nickname], [g].[SquadId], [w0].[IsAutomatic] """); } - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + public override async Task + Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection( + bool async) { - await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); + await base + .Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection( + async); AssertSql( """ -@time='01:02' (DbType = Time) - -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CAST([m].[Duration] AS time) = @time +SELECT [g].[Nickname], [g].[SquadId], [w1].[Key], [w1].[Count] +FROM [Gears] AS [g] +OUTER APPLY ( + SELECT [w0].[Key], COUNT(*) AS [Count] + FROM ( + SELECT CAST(LEN([w].[Name]) AS int) AS [Key] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + GROUP BY [w0].[Key] +) AS [w1] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) + public override async Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async) { - await base.Order_by_TimeOnly_FromTimeSpan(async); + await base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async); AssertSql( """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -ORDER BY CAST([m].[Duration] AS time) +SELECT [g].[Nickname], [g].[SquadId], [s].[HasSoulPatch] +FROM [Gears] AS [g] +OUTER APPLY ( + SELECT DISTINCT [g1].[HasSoulPatch] + FROM [Weapons] AS [w] + LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] + LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] + INNER JOIN [Gears] AS [g1] ON [c].[Name] = [g1].[CityOfBirthName] + WHERE [g].[FullName] = [w].[OwnerFullName] +) AS [s] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) + public override async Task Correlated_collection_after_distinct_3_levels(bool async) { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); + await base.Correlated_collection_after_distinct_3_levels(async); AssertSql( """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] -FROM [Tags] AS [t] -CROSS JOIN [Missions] AS [m] -WHERE CAST([t].[IssueDate] AS date) > [m].[Date] +SELECT [s0].[Id], [s0].[Name], [s1].[Nickname], [s1].[FullName], [s1].[HasSoulPatch], [s1].[Id], [s1].[Name], [s1].[Nickname0], [s1].[FullName0], [s1].[HasSoulPatch0], [s1].[Id0] +FROM ( + SELECT DISTINCT [s].[Id], [s].[Name] + FROM [Squads] AS [s] +) AS [s0] +OUTER APPLY ( + SELECT [g0].[Nickname], [g0].[FullName], [g0].[HasSoulPatch], [w0].[Id], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[FullName] AS [FullName0], [w0].[HasSoulPatch] AS [HasSoulPatch0], [w0].[Id0] + FROM ( + SELECT DISTINCT [g].[Nickname], [g].[FullName], [g].[HasSoulPatch] + FROM [Gears] AS [g] + WHERE [g].[SquadId] = [s0].[Id] + ) AS [g0] + OUTER APPLY ( + SELECT [s0].[Id], [s0].[Name], [g0].[Nickname], [g0].[FullName], [g0].[HasSoulPatch], [w].[Id] AS [Id0] + FROM [Weapons] AS [w] + WHERE [w].[OwnerFullName] = [g0].[FullName] + ) AS [w0] +) AS [s1] +ORDER BY [s0].[Id], [s1].[Nickname], [s1].[FullName], [s1].[HasSoulPatch] """); } - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + public override async Task Correlated_collection_after_distinct_3_levels_without_original_identifiers(bool async) { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); - - AssertSql( - """ -@prm='10/11/0002' (DbType = Date) + await base.Correlated_collection_after_distinct_3_levels_without_original_identifiers(async); -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE CAST([t].[IssueDate] AS date) IN (@prm, '0015-03-07') -"""); + AssertSql(); } public override async Task Include_on_entity_that_is_not_present_in_final_projection_but_uses_TypeIs_instead(bool async) @@ -9610,17 +8580,6 @@ FROM [Gears] AS [g] """); } - public override async Task DateTimeOffset_DateAdd_AddYears(bool async) - { - await base.DateTimeOffset_DateAdd_AddYears(async); - - AssertSql( - """ -SELECT DATEADD(year, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] AS [m] -"""); - } - public override async Task Include_on_derived_entity_with_cast(bool async) { await base.Include_on_derived_entity_with_cast(async); @@ -9646,17 +8605,6 @@ WHERE [m].[Rating] IS NULL """); } - public override async Task ToString_guid_property_projection(bool async) - { - await base.ToString_guid_property_projection(async); - - AssertSql( - """ -SELECT [t].[GearNickName] AS [A], CONVERT(varchar(36), [t].[Id]) AS [B] -FROM [Tags] AS [t] -"""); - } - public override async Task Cast_to_derived_followed_by_multiple_includes(bool async) { await base.Cast_to_derived_followed_by_multiple_includes(async); @@ -10182,48 +9130,6 @@ FROM [Squads] AS [s] """); } - public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - await base.DateTimeOffset_to_unix_time_milliseconds(async); - - AssertSql( - """ -@unixEpochMilliseconds='0' - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] -FROM [Gears] AS [g] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochMilliseconds = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - - public override async Task DateTimeOffset_to_unix_time_seconds(bool async) - { - await base.DateTimeOffset_to_unix_time_seconds(async); - - AssertSql( - """ -@unixEpochSeconds='0' - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] -FROM [Gears] AS [g] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochSeconds = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - public override async Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) { await base.Set_operator_with_navigation_in_projection_groupby_aggregate(async); @@ -10531,78 +9437,6 @@ FROM [Missions] AS [m] ); } - public override async Task Where_datetimeoffset_microsecond_component(bool async) - { - await base.Where_datetimeoffset_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Timeline]) % 1000 = 200 -"""); - } - - public override async Task Where_datetimeoffset_nanosecond_component(bool async) - { - await base.Where_datetimeoffset_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Timeline]) % 1000 = 400 -"""); - } - - public override async Task Where_timespan_microsecond_component(bool async) - { - await base.Where_timespan_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Duration]) % 1000 = 200 -"""); - } - - public override async Task Where_timespan_nanosecond_component(bool async) - { - await base.Where_timespan_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Duration]) % 1000 = 400 -"""); - } - - public override async Task Where_timeonly_microsecond_component(bool async) - { - await base.Where_timeonly_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Time]) % 1000 = 200 -"""); - } - - public override async Task Where_timeonly_nanosecond_component(bool async) - { - await base.Where_timeonly_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Time]) % 1000 = 400 -"""); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs index db56f855330..d1cced85865 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServer160Test.cs @@ -21,2721 +21,78 @@ public NorthwindFunctionsQuerySqlServer160Test(Fixture160 fixture, ITestOutputHe public virtual void Check_all_tests_overridden() => TestHelpers.AssertAllMethodsOverridden(GetType()); - public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) - { - await base.TimeSpan_Compare_to_simple_zero(async, compareTo); - - AssertSql( - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] = @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <> @myDatetime OR [o].[OrderDate] IS NULL -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -"""); - } - - #region String.StartsWith - - public override async Task String_StartsWith_Literal(bool async) - { - await base.String_StartsWith_Literal(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'M%' -"""); - } - - public override async Task String_StartsWith_Parameter(bool async) - { - await base.String_StartsWith_Parameter(async); - - AssertSql( - """ -@pattern_startswith='M%' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE @pattern_startswith ESCAPE N'\' -"""); - } - - public override async Task String_StartsWith_Identity(bool async) - { - await base.String_StartsWith_Identity(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_StartsWith_Column(bool async) - { - await base.String_StartsWith_Column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_StartsWith_MethodCall(bool async) - { - await base.String_StartsWith_MethodCall(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'M%' -"""); - } - - public override async Task String_StartsWith_with_StringComparison_Ordinal(bool async) - { - await base.String_StartsWith_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_StartsWith_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_StartsWith_with_StringComparison_unsupported(bool async) - { - await base.String_StartsWith_with_StringComparison_unsupported(async); - - AssertSql(); - } - - #endregion String.StartsWith - - #region String.EndsWith - - public override async Task String_EndsWith_Literal(bool async) - { - await base.String_EndsWith_Literal(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%b' -"""); - } - - public override async Task String_EndsWith_Parameter(bool async) - { - await base.String_EndsWith_Parameter(async); - - AssertSql( - """ -@pattern_endswith='%b' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE @pattern_endswith ESCAPE N'\' -"""); - } - - public override async Task String_EndsWith_Identity(bool async) - { - await base.String_EndsWith_Identity(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_EndsWith_Column(bool async) - { - await base.String_EndsWith_Column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_EndsWith_MethodCall(bool async) - { - await base.String_EndsWith_MethodCall(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%m' -"""); - } - - public override async Task String_EndsWith_with_StringComparison_Ordinal(bool async) - { - await base.String_EndsWith_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_EndsWith_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_EndsWith_with_StringComparison_unsupported(bool async) - { - await base.String_EndsWith_with_StringComparison_unsupported(async); - - AssertSql(); - } - - #endregion String.EndsWith - - public override async Task String_Contains_Literal(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M")), // case-insensitive - ss => ss.Set().Where(c => c.ContactName.Contains("M") || c.ContactName.Contains("m"))); // case-sensitive - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%M%' -"""); - } - - public override async Task String_Contains_Identity(bool async) - { - await base.String_Contains_Identity(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND (CHARINDEX([c].[ContactName], [c].[ContactName]) > 0 OR [c].[ContactName] LIKE N'') -"""); - } - - public override async Task String_Contains_Column(bool async) - { - await base.String_Contains_Column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND (CHARINDEX([c].[ContactName], [c].[CompanyName]) > 0 OR [c].[ContactName] LIKE N'') -"""); - } - - public override async Task String_Contains_constant_with_whitespace(bool async) - { - await base.String_Contains_constant_with_whitespace(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'% %' -"""); - } - - public override async Task String_Contains_parameter_with_whitespace(bool async) - { - await base.String_Contains_parameter_with_whitespace(async); - - AssertSql( - """ -@pattern_contains='% %' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE @pattern_contains ESCAPE N'\' -"""); - } - - public override async Task String_FirstOrDefault_MethodCall(bool async) - { - await base.String_FirstOrDefault_MethodCall(async); - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[ContactName], 1, 1) = N'A' -"""); - } - - public override async Task String_LastOrDefault_MethodCall(bool async) - { - await base.String_LastOrDefault_MethodCall(async); - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[ContactName], LEN([c].[ContactName]), 1) = N's' -"""); - } - - public override async Task String_Contains_MethodCall(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains(LocalMethod1())), // case-insensitive - ss => ss.Set().Where( - c => c.ContactName.Contains(LocalMethod1().ToLower()) - || c.ContactName.Contains(LocalMethod1().ToUpper()))); // case-sensitive - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%M%' -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_over_non_nullable_column(bool async) - { - await base.String_Join_over_non_nullable_column(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG([c].[CustomerID], N'|'), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_over_nullable_column(bool async) - { - await base.String_Join_over_nullable_column(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG(COALESCE([c].[Region], N''), N'|'), N'') AS [Regions] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_with_predicate(bool async) - { - await base.String_Join_with_predicate(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG(CASE - WHEN CAST(LEN([c].[ContactName]) AS int) > 10 THEN [c].[CustomerID] -END, N'|'), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_with_ordering(bool async) - { - await base.String_Join_with_ordering(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG([c].[CustomerID], N'|') WITHIN GROUP (ORDER BY [c].[CustomerID] DESC), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_non_aggregate(bool async) - { - await base.String_Join_non_aggregate(async); - - AssertSql( - """ -@foo='foo' (Size = 4000) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CONCAT_WS(N'|', [c].[CompanyName], @foo, N'', N'bar') = N'Around the Horn|foo||bar' -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Concat(bool async) - { - await base.String_Concat(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG([c].[CustomerID], N''), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - public override async Task String_Compare_simple_zero(bool async) - { - await base.String_Compare_simple_zero(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -"""); - } - - public override async Task String_Compare_simple_one(bool async) - { - await base.String_Compare_simple_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -"""); - } - - public override async Task String_compare_with_parameter(bool async) - { - await base.String_compare_with_parameter(async); - - AssertSql( - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -"""); - } - - public override async Task String_Compare_simple_more_than_one(bool async) - { - await base.String_Compare_simple_more_than_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END = 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END > 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE 42 > CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END -"""); - } - - public override async Task String_Compare_nested(bool async) - { - await base.String_Compare_nested(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > REPLACE(N'ALFKI', N'ALF', [c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < REPLACE(N'ALFKI', N'ALF', [c].[CustomerID]) -"""); - } - - public override async Task String_Compare_multi_predicate(bool async) - { - await base.String_Compare_multi_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'ALFKI' AND [c].[CustomerID] < N'CACTU' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactTitle] = N'Owner' AND ([c].[Country] <> N'USA' OR [c].[Country] IS NULL) -"""); - } - - public override async Task String_Compare_to_simple_zero(bool async) - { - await base.String_Compare_to_simple_zero(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -"""); - } - - public override async Task String_Compare_to_simple_one(bool async) - { - await base.String_Compare_to_simple_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -"""); - } - - public override async Task String_compare_to_with_parameter(bool async) - { - await base.String_compare_to_with_parameter(async); - - AssertSql( - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -"""); - } - - public override async Task String_Compare_to_simple_more_than_one(bool async) - { - await base.String_Compare_to_simple_more_than_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END = 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END > 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE 42 > CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END -"""); - } - - public override async Task String_Compare_to_nested(bool async) - { - await base.String_Compare_to_nested(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > REPLACE(N'AROUT', N'OUT', [c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < REPLACE(N'AROUT', N'OUT', [c].[CustomerID]) -"""); - } - - public override async Task String_Compare_to_multi_predicate(bool async) - { - await base.String_Compare_to_multi_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'ALFKI' AND [c].[CustomerID] < N'CACTU' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactTitle] = N'Owner' AND ([c].[Country] <> N'USA' OR [c].[Country] IS NULL) -"""); - } - - public override async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) - { - await base.DateTime_Compare_to_simple_zero(async, compareTo); - - AssertSql( - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] = @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <> @myDatetime OR [o].[OrderDate] IS NULL -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -"""); - } - - public override async Task Int_Compare_to_simple_zero(bool async) - { - await base.Int_Compare_to_simple_zero(async); - - AssertSql( - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] = @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] <> @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] > @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] <= @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] > @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] <= @orderId -"""); - } - - public override async Task Where_math_abs1(bool async) - { - await base.Where_math_abs1(async); - - AssertSql( - """ -SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -FROM [Products] AS [p] -WHERE ABS([p].[ProductID]) > 10 -"""); - } - - public override async Task Where_math_abs2(bool async) - { - await base.Where_math_abs2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND ABS([o].[Quantity]) > CAST(10 AS smallint) -"""); - } - - public override async Task Where_math_abs3(bool async) - { - await base.Where_math_abs3(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND ABS([o].[UnitPrice]) > 10.0 -"""); - } - - public override async Task Where_math_abs_uncorrelated(bool async) - { - await base.Where_math_abs_uncorrelated(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND 10 < [o].[ProductID] -"""); - } - - public override async Task Where_math_ceiling1(bool async) - { - await base.Where_math_ceiling1(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND CEILING(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_ceiling2(bool async) - { - await base.Where_math_ceiling2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND CEILING([o].[UnitPrice]) > 10.0 -"""); - } - - public override async Task Where_math_floor(bool async) - { - await base.Where_math_floor(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND FLOOR([o].[UnitPrice]) > 10.0 -"""); - } - - public override async Task Where_math_power(bool async) - { - await base.Where_math_power(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER(CAST([o].[Discount] AS float), 3.0E0) > 0.004999999888241291E0 -"""); - } - - public override async Task Where_math_square(bool async) - { - await base.Where_math_square(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER(CAST([o].[Discount] AS float), 2.0E0) > 0.05000000074505806E0 -"""); - } - - public override async Task Where_math_round(bool async) - { - await base.Where_math_round(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND ROUND([o].[UnitPrice], 0) > 10.0 -"""); - } - - public override async Task Sum_over_round_works_correctly_in_projection(bool async) - { - await base.Sum_over_round_works_correctly_in_projection(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 2)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Sum_over_round_works_correctly_in_projection_2(bool async) - { - await base.Sum_over_round_works_correctly_in_projection_2(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 2)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Sum_over_truncate_works_correctly_in_projection(bool async) - { - await base.Sum_over_truncate_works_correctly_in_projection(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 0, 1)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Sum_over_truncate_works_correctly_in_projection_2(bool async) - { - await base.Sum_over_truncate_works_correctly_in_projection_2(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 0, 1)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Select_math_round_int(bool async) - { - await base.Select_math_round_int(async); - - AssertSql( - """ -SELECT ROUND(CAST([o].[OrderID] AS float), 0) AS [A] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -"""); - } - - public override async Task Select_math_truncate_int(bool async) - { - await base.Select_math_truncate_int(async); - - AssertSql( - """ -SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -"""); - } - - public override async Task Where_math_round2(bool async) - { - await base.Where_math_round2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE ROUND([o].[UnitPrice], 2) > 100.0 -"""); - } - - public override async Task Where_math_truncate(bool async) - { - await base.Where_math_truncate(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND ROUND([o].[UnitPrice], 0, 1) > 10.0 -"""); - } - - public override async Task Where_math_exp(bool async) - { - await base.Where_math_exp(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND EXP(CAST([o].[Discount] AS float)) > 1.0E0 -"""); - } - - public override async Task Where_math_log10(bool async) - { - await base.Where_math_log10(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG10(CAST([o].[Discount] AS float)) < 0.0E0 -"""); - } - - public override async Task Where_math_log(bool async) - { - await base.Where_math_log(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG(CAST([o].[Discount] AS float)) < 0.0E0 -"""); - } - - public override async Task Where_math_log_new_base(bool async) - { - await base.Where_math_log_new_base(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG(CAST([o].[Discount] AS float), 7.0E0) < -1.0E0 -"""); - } - - public override async Task Where_math_sqrt(bool async) - { - await base.Where_math_sqrt(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SQRT(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_acos(bool async) - { - await base.Where_math_acos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ACOS(CAST([o].[Discount] AS float)) > 1.0E0 -"""); - } - - public override async Task Where_math_asin(bool async) - { - await base.Where_math_asin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ASIN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_atan(bool async) - { - await base.Where_math_atan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATAN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_atan2(bool async) - { - await base.Where_math_atan2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATN2(CAST([o].[Discount] AS float), 1.0E0) > 0.0E0 -"""); - } - - public override async Task Where_math_cos(bool async) - { - await base.Where_math_cos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND COS(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_sin(bool async) - { - await base.Where_math_sin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_tan(bool async) - { - await base.Where_math_tan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND TAN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_sign(bool async) - { - await base.Where_math_sign(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIGN([o].[Discount]) > 0 -"""); - } - - public override async Task Where_math_min(bool async) - { - await base.Where_math_min(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND LEAST([o].[OrderID], [o].[ProductID]) = [o].[ProductID] -"""); - } - - public override async Task Where_math_min_nested(bool async) - { - await base.Where_math_min_nested(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND LEAST([o].[OrderID], [o].[ProductID], 99999) = [o].[ProductID] -"""); - } - - public override async Task Where_math_min_nested_twice(bool async) - { - await base.Where_math_min_nested_twice(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND LEAST(99999, [o].[OrderID], 99998, [o].[ProductID]) = [o].[ProductID] -"""); - } - - public override async Task Where_math_max(bool async) - { - await base.Where_math_max(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND GREATEST([o].[OrderID], [o].[ProductID]) = [o].[OrderID] -"""); - } - - public override async Task Where_math_max_nested(bool async) - { - await base.Where_math_max_nested(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND GREATEST([o].[OrderID], [o].[ProductID], 1) = [o].[OrderID] -"""); - } - - public override async Task Where_math_max_nested_twice(bool async) - { - await base.Where_math_max_nested_twice(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND GREATEST(1, [o].[OrderID], 2, [o].[ProductID]) = [o].[OrderID] -"""); - } - - public override async Task Where_math_degrees(bool async) - { - await base.Where_math_degrees(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND DEGREES(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_radians(bool async) - { - await base.Where_math_radians(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND RADIANS(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_mathf_abs1(bool async) - { - await base.Where_mathf_abs1(async); - - AssertSql( - """ -SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -FROM [Products] AS [p] -WHERE ABS(CAST([p].[ProductID] AS real)) > CAST(10 AS real) -"""); - } - - public override async Task Where_mathf_ceiling1(bool async) - { - await base.Where_mathf_ceiling1(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND CEILING([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_floor(bool async) - { - await base.Where_mathf_floor(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND FLOOR(CAST([o].[UnitPrice] AS real)) > CAST(10 AS real) -"""); - } - - public override async Task Where_mathf_power(bool async) - { - await base.Where_mathf_power(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER([o].[Discount], CAST(3 AS real)) > CAST(0.005 AS real) -"""); - } - - public override async Task Where_mathf_square(bool async) - { - await base.Where_mathf_square(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER([o].[Discount], CAST(2 AS real)) > CAST(0.05 AS real) -"""); - } - - public override async Task Where_mathf_round2(bool async) - { - await base.Where_mathf_round2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE CAST(ROUND(CAST([o].[UnitPrice] AS real), 2) AS real) > CAST(100 AS real) -"""); - } - - public override async Task Select_mathf_round(bool async) - { - await base.Select_mathf_round(async); - - AssertSql( - """ -SELECT CAST(ROUND(CAST([o].[OrderID] AS real), 0) AS real) -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -"""); - } - - public override async Task Select_mathf_round2(bool async) - { - await base.Select_mathf_round2(async); - - AssertSql( - """ -SELECT CAST(ROUND(CAST([o].[UnitPrice] AS real), 2) AS real) -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) -"""); - } - - public override async Task Where_mathf_truncate(bool async) - { - await base.Where_mathf_truncate(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND CAST(ROUND(CAST([o].[UnitPrice] AS real), 0, 1) AS real) > CAST(10 AS real) -"""); - } - - public override async Task Select_mathf_truncate(bool async) - { - await base.Select_mathf_truncate(async); - - AssertSql( - """ -SELECT CAST(ROUND(CAST([o].[UnitPrice] AS real), 0, 1) AS real) -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) -"""); - } - - public override async Task Where_mathf_exp(bool async) - { - await base.Where_mathf_exp(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND EXP([o].[Discount]) > CAST(1 AS real) -"""); - } - - public override async Task Where_mathf_log10(bool async) - { - await base.Where_mathf_log10(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG10([o].[Discount]) < CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_log(bool async) - { - await base.Where_mathf_log(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG([o].[Discount]) < CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_log_new_base(bool async) - { - await base.Where_mathf_log_new_base(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG([o].[Discount], CAST(7 AS real)) < CAST(-1 AS real) -"""); - } - - public override async Task Where_mathf_sqrt(bool async) - { - await base.Where_mathf_sqrt(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SQRT([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_acos(bool async) - { - await base.Where_mathf_acos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ACOS([o].[Discount]) > CAST(1 AS real) -"""); - } - - public override async Task Where_mathf_asin(bool async) - { - await base.Where_mathf_asin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ASIN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_atan(bool async) - { - await base.Where_mathf_atan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATAN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_atan2(bool async) - { - await base.Where_mathf_atan2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATN2([o].[Discount], CAST(1 AS real)) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_cos(bool async) - { - await base.Where_mathf_cos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND COS([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_sin(bool async) - { - await base.Where_mathf_sin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_tan(bool async) - { - await base.Where_mathf_tan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND TAN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_sign(bool async) - { - await base.Where_mathf_sign(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIGN([o].[Discount]) > 0 -"""); - } - - public override async Task Where_mathf_degrees(bool async) - { - await base.Where_mathf_degrees(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND DEGREES([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_radians(bool async) - { - await base.Where_mathf_radians(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND RADIANS([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_guid_newguid(bool async) - { - await base.Where_guid_newguid(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE NEWID() <> '00000000-0000-0000-0000-000000000000' -"""); - } - - public override async Task Where_string_to_upper(bool async) - { - await base.Where_string_to_upper(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE UPPER([c].[CustomerID]) = N'ALFKI' -"""); - } - - public override async Task Where_string_to_lower(bool async) - { - await base.Where_string_to_lower(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE LOWER([c].[CustomerID]) = N'alfki' -"""); - } - - public override async Task Where_functions_nested(bool async) - { - await base.Where_functions_nested(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE POWER(CAST(CAST(LEN([c].[CustomerID]) AS int) AS float), 2.0E0) = 25.0E0 -"""); - } - - public override async Task Convert_ToBoolean(bool async) - { - await base.Convert_ToBoolean(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(bit, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(tinyint, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(decimal(18, 2), [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(float, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CAST(CONVERT(float, [o].[OrderID] % 3) AS real)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(smallint, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(int, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(bigint, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(int, [o].[OrderID] % 3)) = CAST(1 AS bit) -"""); - } - - public override async Task Convert_ToByte(bool async) - { - await base.Convert_ToByte(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(bit, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -"""); - } - - public override async Task Convert_ToDecimal(bool async) - { - await base.Convert_ToDecimal(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(bit, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(float, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(int, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0 -"""); - } - - public override async Task Convert_ToDouble(bool async) - { - await base.Convert_ToDouble(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(bit, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(float, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(int, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0E0 -"""); - } - - public override async Task Convert_ToInt16(bool async) - { - await base.Convert_ToInt16(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(bit, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS smallint) -"""); - } - - public override async Task Convert_ToInt32(bool async) - { - await base.Convert_ToInt32(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(bit, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(float, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(smallint, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(int, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(bigint, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0 -"""); - } - - public override async Task Convert_ToInt64(bool async) - { - await base.Convert_ToInt64(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(bit, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS bigint) -"""); - } - - public override async Task Convert_ToString(bool async) - { - await base.Convert_ToString(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(bit, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(tinyint, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(float, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(smallint, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(int, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(bigint, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(nvarchar(max), [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(nvarchar(max), [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND (CONVERT(nvarchar(max), [o].[OrderDate]) LIKE N'%1997%' OR CONVERT(nvarchar(max), [o].[OrderDate]) LIKE N'%1998%') -"""); - } - - public override async Task Indexof_with_emptystring(bool async) - { - await base.Indexof_with_emptystring(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[Region] IS NOT NULL THEN 0 -END = 0 -"""); - } - - public override async Task Indexof_with_one_constant_arg(bool async) - { - await base.Indexof_with_one_constant_arg(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(N'a', [c].[ContactName]) - 1 = 1 -"""); - } - - public override async Task Indexof_with_one_parameter_arg(bool async) - { - await base.Indexof_with_one_parameter_arg(async); - - AssertSql( - """ -@pattern='a' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(@pattern, [c].[ContactName]) - CASE - WHEN @pattern = N'' THEN 0 - ELSE 1 -END = 1 -"""); - } - - public override async Task Indexof_with_constant_starting_position(bool async) - { - await base.Indexof_with_constant_starting_position(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(N'a', [c].[ContactName], 3) - 1 = 4 -"""); - } - - public override async Task Indexof_with_parameter_starting_position(bool async) - { - await base.Indexof_with_parameter_starting_position(async); - - AssertSql( - """ -@start='2' - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(N'a', [c].[ContactName], @start + 1) - 1 = 4 -"""); - } - - public override async Task Replace_with_emptystring(bool async) - { - await base.Replace_with_emptystring(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE REPLACE([c].[ContactName], N'ia', N'') = N'Mar Anders' -"""); - } - - public override async Task Replace_using_property_arguments(bool async) - { - await base.Replace_using_property_arguments(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE REPLACE([c].[ContactName], [c].[ContactName], [c].[CustomerID]) = [c].[CustomerID] -"""); - } - - public override async Task Substring_with_one_arg_with_zero_startindex(bool async) - { - await base.Substring_with_one_arg_with_zero_startindex(async); - - AssertSql( - """ -SELECT [c].[ContactName] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[CustomerID], 0 + 1, LEN([c].[CustomerID])) = N'ALFKI' -"""); - } - - public override async Task Substring_with_one_arg_with_constant(bool async) - { - await base.Substring_with_one_arg_with_constant(async); - - AssertSql( - """ -SELECT [c].[ContactName] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[CustomerID], 1 + 1, LEN([c].[CustomerID])) = N'LFKI' -"""); - } - - public override async Task Substring_with_one_arg_with_closure(bool async) - { - await base.Substring_with_one_arg_with_closure(async); - - AssertSql( - """ -@start='2' - -SELECT [c].[ContactName] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[CustomerID], @start + 1, LEN([c].[CustomerID])) = N'FKI' -"""); - } - - public override async Task Substring_with_two_args_with_zero_startindex(bool async) - { - await base.Substring_with_two_args_with_zero_startindex(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], 0 + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_zero_length(bool async) - { - await base.Substring_with_two_args_with_zero_length(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], 2 + 1, 0) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_constant(bool async) - { - await base.Substring_with_two_args_with_constant(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], 1 + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_closure(bool async) - { - await base.Substring_with_two_args_with_closure(async); - - AssertSql( - """ -@start='2' - -SELECT SUBSTRING([c].[ContactName], @start + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_Index_of(bool async) - { - await base.Substring_with_two_args_with_Index_of(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], (CHARINDEX(N'a', [c].[ContactName]) - 1) + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task IsNullOrEmpty_in_predicate(bool async) - { - await base.IsNullOrEmpty_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[Region] IS NULL OR [c].[Region] LIKE N'' -"""); - } - - public override async Task IsNullOrEmpty_in_projection(bool async) - { - await base.IsNullOrEmpty_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[Region] IS NULL OR [c].[Region] LIKE N'' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -"""); - } - - public override async Task IsNullOrEmpty_negated_in_predicate(bool async) - { - await base.IsNullOrEmpty_negated_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[Region] IS NOT NULL AND [c].[Region] NOT LIKE N'' -"""); - } - - public override async Task IsNullOrEmpty_negated_in_projection(bool async) - { - await base.IsNullOrEmpty_negated_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[Region] IS NOT NULL AND [c].[Region] NOT LIKE N'' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -"""); - } - - public override async Task IsNullOrWhiteSpace_in_predicate(bool async) - { - await base.IsNullOrWhiteSpace_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[Region] IS NULL OR [c].[Region] = N'' -"""); - } - - public override async Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(bool async) - { - await base.IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'' -"""); - } - - public override async Task TrimStart_without_arguments_in_predicate(bool async) - { - await base.TrimStart_without_arguments_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE LTRIM([c].[ContactTitle]) = N'Owner' -"""); - } - - public override async Task TrimStart_with_char_argument_in_predicate(bool async) - { - await base.TrimStart_with_char_argument_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE LTRIM([c].[ContactTitle], N'O') = N'wner' -"""); - } - - public override async Task TrimStart_with_char_array_argument_in_predicate(bool async) + public override async Task Sum_over_round_works_correctly_in_projection(bool async) { - await base.TrimStart_with_char_array_argument_in_predicate(async); + await base.Sum_over_round_works_correctly_in_projection(async); AssertSql( """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE LTRIM([c].[ContactTitle], N'Ow') = N'ner' +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 2)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] +FROM [Orders] AS [o] +WHERE [o].[OrderID] < 10300 """); } - public override async Task TrimEnd_without_arguments_in_predicate(bool async) + public override async Task Sum_over_round_works_correctly_in_projection_2(bool async) { - await base.TrimEnd_without_arguments_in_predicate(async); + await base.Sum_over_round_works_correctly_in_projection_2(async); AssertSql( """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE RTRIM([c].[ContactTitle]) = N'Owner' +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 2)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] +FROM [Orders] AS [o] +WHERE [o].[OrderID] < 10300 """); } - public override async Task TrimEnd_with_char_argument_in_predicate(bool async) + public override async Task Sum_over_truncate_works_correctly_in_projection(bool async) { - await base.TrimEnd_with_char_argument_in_predicate(async); + await base.Sum_over_truncate_works_correctly_in_projection(async); AssertSql( """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE RTRIM([c].[ContactTitle], N'r') = N'Owne' +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 0, 1)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] +FROM [Orders] AS [o] +WHERE [o].[OrderID] < 10300 """); } - public override async Task TrimEnd_with_char_array_argument_in_predicate(bool async) + public override async Task Sum_over_truncate_works_correctly_in_projection_2(bool async) { - await base.TrimEnd_with_char_array_argument_in_predicate(async); + await base.Sum_over_truncate_works_correctly_in_projection_2(async); AssertSql( """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE RTRIM([c].[ContactTitle], N'er') = N'Own' +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 0, 1)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] +FROM [Orders] AS [o] +WHERE [o].[OrderID] < 10300 """); } - public override async Task Trim_without_argument_in_predicate(bool async) + public override async Task Where_functions_nested(bool async) { - await base.Trim_without_argument_in_predicate(async); + await base.Where_functions_nested(async); AssertSql( """ SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] FROM [Customers] AS [c] -WHERE LTRIM(RTRIM([c].[ContactTitle])) = N'Owner' +WHERE POWER(CAST(CAST(LEN([c].[CustomerID]) AS int) AS float), 2.0E0) = 25.0E0 """); } - public override async Task Trim_with_char_argument_in_predicate(bool async) - { - // String.Trim with parameters. Issue #22927. - await AssertTranslationFailed(() => base.Trim_with_char_argument_in_predicate(async)); - - AssertSql(); - } - - public override async Task Trim_with_char_array_argument_in_predicate(bool async) - { - // String.Trim with parameters. Issue #22927. - await AssertTranslationFailed(() => base.Trim_with_char_array_argument_in_predicate(async)); - - AssertSql(); - } - public override async Task Order_by_length_twice(bool async) { await base.Order_by_length_twice(async); @@ -2761,18 +118,6 @@ ORDER BY CAST(LEN([c].[CustomerID]) AS int), [c].[CustomerID] """); } - public override async Task Static_string_equals_in_predicate(bool async) - { - await base.Static_string_equals_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ANATR' -"""); - } - public override async Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) { await base.Static_equals_nullable_datetime_compared_to_non_nullable(async); @@ -2799,142 +144,6 @@ FROM [Orders] AS [o] """); } - public override async Task Where_DateOnly_FromDateTime(bool async) - { - await base.Where_DateOnly_FromDateTime(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] IS NOT NULL AND CAST([o].[OrderDate] AS date) = '1996-09-16' -"""); - } - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) - => await base.Projecting_Math_Truncate_and_ordering_by_it_twice(async); - - // issue #16038 - // AssertSql( - // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] - //FROM [Orders] AS [o] - //WHERE [o].[OrderID] < 10250 - //ORDER BY [A]"); - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) - => await base.Projecting_Math_Truncate_and_ordering_by_it_twice2(async); - - // issue #16038 - // AssertSql( - // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] - //FROM [Orders] AS [o] - //WHERE [o].[OrderID] < 10250 - //ORDER BY [A] DESC"); - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) - => await base.Projecting_Math_Truncate_and_ordering_by_it_twice3(async); - - // issue #16038 - // AssertSql( - // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] - //FROM [Orders] AS [o] - //WHERE [o].[OrderID] < 10250 - //ORDER BY [A] DESC"); - public override Task Regex_IsMatch_MethodCall(bool async) - => AssertTranslationFailed(() => base.Regex_IsMatch_MethodCall(async)); - - public override Task Regex_IsMatch_MethodCall_constant_input(bool async) - => AssertTranslationFailed(() => base.Regex_IsMatch_MethodCall_constant_input(async)); - - public override Task Datetime_subtraction_TotalDays(bool async) - => AssertTranslationFailed(() => base.Datetime_subtraction_TotalDays(async)); - - public override async Task Select_ToString_IndexOf(bool async) - { - await base.Select_ToString_IndexOf(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE CHARINDEX('123', CONVERT(varchar(11), [o].[OrderID])) - 1 = -1 -"""); - } - - public override async Task Select_IndexOf_ToString(bool async) - { - await base.Select_IndexOf_ToString(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE CHARINDEX(CONVERT(varchar(11), [o].[OrderID]), '123') - CASE - WHEN CONVERT(varchar(11), [o].[OrderID]) = '' THEN 0 - ELSE 1 -END = -1 -"""); - } - - public override async Task String_Contains_in_projection(bool async) - { - await base.String_Contains_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[ContactName] IS NOT NULL AND (CHARINDEX([c].[ContactName], [c].[CompanyName]) > 0 OR [c].[ContactName] LIKE N'') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -"""); - } - - public override async Task String_Contains_negated_in_predicate(bool async) - { - await base.String_Contains_negated_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NULL OR (CHARINDEX([c].[ContactName], [c].[CompanyName]) <= 0 AND [c].[ContactName] NOT LIKE N'') -"""); - } - - public override async Task String_Contains_negated_in_projection(bool async) - { - await base.String_Contains_negated_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[ContactName] IS NULL OR (CHARINDEX([c].[ContactName], [c].[CompanyName]) <= 0 AND [c].[ContactName] NOT LIKE N'') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -"""); - } - - public override async Task String_Contains_with_StringComparison_Ordinal(bool async) - { - await base.String_Contains_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_Contains_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_Contains_with_StringComparison_unsupported(bool async) - { - await base.String_Contains_with_StringComparison_unsupported(async); - - AssertSql(); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task StandardDeviation(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs index a8b407ad3d3..865c6f77c6f 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindFunctionsQuerySqlServerTest.cs @@ -23,2631 +23,48 @@ public NorthwindFunctionsQuerySqlServerTest( public virtual void Check_all_tests_overridden() => TestHelpers.AssertAllMethodsOverridden(GetType()); - public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) + public override async Task Client_evaluation_of_uncorrelated_method_call(bool async) { - await base.TimeSpan_Compare_to_simple_zero(async, compareTo); + await base.Client_evaluation_of_uncorrelated_method_call(async); AssertSql( """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] = @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <> @myDatetime OR [o].[OrderDate] IS NULL -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -"""); - } - - #region String.StartsWith - - public override async Task String_StartsWith_Literal(bool async) - { - await base.String_StartsWith_Literal(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'M%' -"""); - } - - public override async Task String_StartsWith_Parameter(bool async) - { - await base.String_StartsWith_Parameter(async); - - AssertSql( - """ -@pattern_startswith='M%' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE @pattern_startswith ESCAPE N'\' -"""); - } - - public override async Task String_StartsWith_Identity(bool async) - { - await base.String_StartsWith_Identity(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_StartsWith_Column(bool async) - { - await base.String_StartsWith_Column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND LEFT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_StartsWith_MethodCall(bool async) - { - await base.String_StartsWith_MethodCall(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'M%' -"""); - } - - public override async Task String_StartsWith_with_StringComparison_Ordinal(bool async) - { - await base.String_StartsWith_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_StartsWith_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_StartsWith_with_StringComparison_unsupported(bool async) - { - await base.String_StartsWith_with_StringComparison_unsupported(async); - - AssertSql(); - } - - #endregion String.StartsWith - - #region String.EndsWith - - public override async Task String_EndsWith_Literal(bool async) - { - await base.String_EndsWith_Literal(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%b' -"""); - } - - public override async Task String_EndsWith_Parameter(bool async) - { - await base.String_EndsWith_Parameter(async); - - AssertSql( - """ -@pattern_endswith='%b' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE @pattern_endswith ESCAPE N'\' -"""); - } - - public override async Task String_EndsWith_Identity(bool async) - { - await base.String_EndsWith_Identity(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_EndsWith_Column(bool async) - { - await base.String_EndsWith_Column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND RIGHT([c].[ContactName], LEN([c].[ContactName])) = [c].[ContactName] -"""); - } - - public override async Task String_EndsWith_MethodCall(bool async) - { - await base.String_EndsWith_MethodCall(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%m' -"""); - } - - public override async Task String_EndsWith_with_StringComparison_Ordinal(bool async) - { - await base.String_EndsWith_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_EndsWith_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_EndsWith_with_StringComparison_unsupported(bool async) - { - await base.String_EndsWith_with_StringComparison_unsupported(async); - - AssertSql(); - } - - #endregion String.EndsWith - - public override async Task String_Contains_Literal(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains("M")), // case-insensitive - ss => ss.Set().Where(c => c.ContactName.Contains("M") || c.ContactName.Contains("m"))); // case-sensitive - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%M%' -"""); - } - - public override async Task String_Contains_Identity(bool async) - { - await base.String_Contains_Identity(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND (CHARINDEX([c].[ContactName], [c].[ContactName]) > 0 OR [c].[ContactName] LIKE N'') -"""); - } - - public override async Task String_Contains_Column(bool async) - { - await base.String_Contains_Column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NOT NULL AND (CHARINDEX([c].[ContactName], [c].[CompanyName]) > 0 OR [c].[ContactName] LIKE N'') -"""); - } - - public override async Task String_Contains_constant_with_whitespace(bool async) - { - await base.String_Contains_constant_with_whitespace(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'% %' -"""); - } - - public override async Task String_Contains_parameter_with_whitespace(bool async) - { - await base.String_Contains_parameter_with_whitespace(async); - - AssertSql( - """ -@pattern_contains='% %' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE @pattern_contains ESCAPE N'\' -"""); - } - - public override async Task String_FirstOrDefault_MethodCall(bool async) - { - await base.String_FirstOrDefault_MethodCall(async); - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[ContactName], 1, 1) = N'A' -"""); - } - - public override async Task String_LastOrDefault_MethodCall(bool async) - { - await base.String_LastOrDefault_MethodCall(async); - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[ContactName], LEN([c].[ContactName]), 1) = N's' -"""); - } - - public override async Task String_Contains_MethodCall(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(c => c.ContactName.Contains(LocalMethod1())), // case-insensitive - ss => ss.Set().Where( - c => c.ContactName.Contains(LocalMethod1().ToLower()) - || c.ContactName.Contains(LocalMethod1().ToUpper()))); // case-sensitive - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] LIKE N'%M%' -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_over_non_nullable_column(bool async) - { - await base.String_Join_over_non_nullable_column(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG([c].[CustomerID], N'|'), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_over_nullable_column(bool async) - { - await base.String_Join_over_nullable_column(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG(COALESCE([c].[Region], N''), N'|'), N'') AS [Regions] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_with_predicate(bool async) - { - await base.String_Join_with_predicate(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG(CASE - WHEN CAST(LEN([c].[ContactName]) AS int) > 10 THEN [c].[CustomerID] -END, N'|'), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_with_ordering(bool async) - { - await base.String_Join_with_ordering(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG([c].[CustomerID], N'|') WITHIN GROUP (ORDER BY [c].[CustomerID] DESC), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Join_non_aggregate(bool async) - { - await base.String_Join_non_aggregate(async); - - AssertSql( - """ -@foo='foo' (Size = 4000) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CONCAT_WS(N'|', [c].[CompanyName], @foo, N'', N'bar') = N'Around the Horn|foo||bar' -"""); - } - - [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] - public override async Task String_Concat(bool async) - { - await base.String_Concat(async); - - AssertSql( - """ -SELECT [c].[City], COALESCE(STRING_AGG([c].[CustomerID], N''), N'') AS [Customers] -FROM [Customers] AS [c] -GROUP BY [c].[City] -"""); - } - - public override async Task String_Compare_simple_zero(bool async) - { - await base.String_Compare_simple_zero(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -"""); - } - - public override async Task String_Compare_simple_one(bool async) - { - await base.String_Compare_simple_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -"""); - } - - public override async Task String_compare_with_parameter(bool async) - { - await base.String_compare_with_parameter(async); - - AssertSql( - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -"""); - } - - public override async Task String_Compare_simple_more_than_one(bool async) - { - await base.String_Compare_simple_more_than_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END = 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END > 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE 42 > CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END -"""); - } - - public override async Task String_Compare_nested(bool async) - { - await base.String_Compare_nested(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > REPLACE(N'ALFKI', N'ALF', [c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < REPLACE(N'ALFKI', N'ALF', [c].[CustomerID]) -"""); - } - - public override async Task String_Compare_multi_predicate(bool async) - { - await base.String_Compare_multi_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'ALFKI' AND [c].[CustomerID] < N'CACTU' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactTitle] = N'Owner' AND ([c].[Country] <> N'USA' OR [c].[Country] IS NULL) -"""); - } - - public override async Task String_Compare_to_simple_zero(bool async) - { - await base.String_Compare_to_simple_zero(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -"""); - } - - public override async Task String_Compare_to_simple_one(bool async) - { - await base.String_Compare_to_simple_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'AROUT' -"""); - } - - public override async Task String_compare_to_with_parameter(bool async) - { - await base.String_compare_to_with_parameter(async); - - AssertSql( - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -""", - // - """ -@customer_CustomerID='AROUT' (Size = 5) (DbType = StringFixedLength) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= @customer_CustomerID -"""); - } - - public override async Task String_Compare_to_simple_more_than_one(bool async) - { - await base.String_Compare_to_simple_more_than_one(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END = 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END > 42 -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE 42 > CASE - WHEN [c].[CustomerID] = N'ALFKI' THEN 0 - WHEN [c].[CustomerID] > N'ALFKI' THEN 1 - WHEN [c].[CustomerID] < N'ALFKI' THEN -1 -END -"""); - } - - public override async Task String_Compare_to_nested(bool async) - { - await base.String_Compare_to_nested(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <> N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > REPLACE(N'AROUT', N'OUT', [c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] <= N'M' + [c].[CustomerID] -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] > UPPER([c].[CustomerID]) -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] < REPLACE(N'AROUT', N'OUT', [c].[CustomerID]) -"""); - } - - public override async Task String_Compare_to_multi_predicate(bool async) - { - await base.String_Compare_to_multi_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] >= N'ALFKI' AND [c].[CustomerID] < N'CACTU' -""", - // - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactTitle] = N'Owner' AND ([c].[Country] <> N'USA' OR [c].[Country] IS NULL) -"""); - } - - public override async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) - { - await base.DateTime_Compare_to_simple_zero(async, compareTo); - - AssertSql( - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] = @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <> @myDatetime OR [o].[OrderDate] IS NULL -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] > @myDatetime -""", - // - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] <= @myDatetime -"""); - } - - public override async Task Int_Compare_to_simple_zero(bool async) - { - await base.Int_Compare_to_simple_zero(async); - - AssertSql( - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] = @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] <> @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] > @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] <= @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] > @orderId -""", - // - """ -@orderId='10250' - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderID] <= @orderId -"""); - } - - public override async Task Where_math_abs1(bool async) - { - await base.Where_math_abs1(async); - - AssertSql( - """ -SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -FROM [Products] AS [p] -WHERE ABS([p].[ProductID]) > 10 -"""); - } - - public override async Task Where_math_abs2(bool async) - { - await base.Where_math_abs2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND ABS([o].[Quantity]) > CAST(10 AS smallint) -"""); - } - - public override async Task Where_math_abs3(bool async) - { - await base.Where_math_abs3(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND ABS([o].[UnitPrice]) > 10.0 -"""); - } - - public override async Task Where_math_abs_uncorrelated(bool async) - { - await base.Where_math_abs_uncorrelated(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND 10 < [o].[ProductID] -"""); - } - - public override async Task Where_math_ceiling1(bool async) - { - await base.Where_math_ceiling1(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND CEILING(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_ceiling2(bool async) - { - await base.Where_math_ceiling2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND CEILING([o].[UnitPrice]) > 10.0 -"""); - } - - public override async Task Where_math_floor(bool async) - { - await base.Where_math_floor(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND FLOOR([o].[UnitPrice]) > 10.0 -"""); - } - - public override async Task Where_math_power(bool async) - { - await base.Where_math_power(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER(CAST([o].[Discount] AS float), 3.0E0) > 0.004999999888241291E0 -"""); - } - - public override async Task Where_math_square(bool async) - { - await base.Where_math_square(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER(CAST([o].[Discount] AS float), 2.0E0) > 0.05000000074505806E0 -"""); - } - - public override async Task Where_math_round(bool async) - { - await base.Where_math_round(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND ROUND([o].[UnitPrice], 0) > 10.0 -"""); - } - - public override async Task Sum_over_round_works_correctly_in_projection(bool async) - { - await base.Sum_over_round_works_correctly_in_projection(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 2)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Sum_over_round_works_correctly_in_projection_2(bool async) - { - await base.Sum_over_round_works_correctly_in_projection_2(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 2)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Sum_over_truncate_works_correctly_in_projection(bool async) - { - await base.Sum_over_truncate_works_correctly_in_projection(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 0, 1)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Sum_over_truncate_works_correctly_in_projection_2(bool async) - { - await base.Sum_over_truncate_works_correctly_in_projection_2(async); - - AssertSql( - """ -SELECT [o].[OrderID], ( - SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 0, 1)), 0.0) - FROM [Order Details] AS [o0] - WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10300 -"""); - } - - public override async Task Select_math_round_int(bool async) - { - await base.Select_math_round_int(async); - - AssertSql( - """ -SELECT ROUND(CAST([o].[OrderID] AS float), 0) AS [A] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -"""); - } - - public override async Task Select_math_truncate_int(bool async) - { - await base.Select_math_truncate_int(async); - - AssertSql( - """ -SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -"""); - } - - public override async Task Where_math_round2(bool async) - { - await base.Where_math_round2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE ROUND([o].[UnitPrice], 2) > 100.0 -"""); - } - - public override async Task Where_math_truncate(bool async) - { - await base.Where_math_truncate(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND ROUND([o].[UnitPrice], 0, 1) > 10.0 -"""); - } - - public override async Task Where_math_exp(bool async) - { - await base.Where_math_exp(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND EXP(CAST([o].[Discount] AS float)) > 1.0E0 -"""); - } - - public override async Task Where_math_log10(bool async) - { - await base.Where_math_log10(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG10(CAST([o].[Discount] AS float)) < 0.0E0 -"""); - } - - public override async Task Where_math_log(bool async) - { - await base.Where_math_log(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG(CAST([o].[Discount] AS float)) < 0.0E0 -"""); - } - - public override async Task Where_math_log_new_base(bool async) - { - await base.Where_math_log_new_base(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG(CAST([o].[Discount] AS float), 7.0E0) < -1.0E0 -"""); - } - - public override async Task Where_math_sqrt(bool async) - { - await base.Where_math_sqrt(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SQRT(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_acos(bool async) - { - await base.Where_math_acos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ACOS(CAST([o].[Discount] AS float)) > 1.0E0 -"""); - } - - public override async Task Where_math_asin(bool async) - { - await base.Where_math_asin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ASIN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_atan(bool async) - { - await base.Where_math_atan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATAN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_atan2(bool async) - { - await base.Where_math_atan2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATN2(CAST([o].[Discount] AS float), 1.0E0) > 0.0E0 -"""); - } - - public override async Task Where_math_cos(bool async) - { - await base.Where_math_cos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND COS(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_sin(bool async) - { - await base.Where_math_sin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_tan(bool async) - { - await base.Where_math_tan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND TAN(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_sign(bool async) - { - await base.Where_math_sign(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIGN([o].[Discount]) > 0 -"""); - } - - public override Task Where_math_min(bool async) - => AssertTranslationFailed(() => base.Where_math_min(async)); - - public override Task Where_math_min_nested(bool async) - => AssertTranslationFailed(() => base.Where_math_min_nested(async)); - - public override Task Where_math_min_nested_twice(bool async) - => AssertTranslationFailed(() => base.Where_math_min_nested_twice(async)); - - public override Task Where_math_max(bool async) - => AssertTranslationFailed(() => base.Where_math_max(async)); - - public override Task Where_math_max_nested(bool async) - => AssertTranslationFailed(() => base.Where_math_max_nested(async)); - - public override Task Where_math_max_nested_twice(bool async) - => AssertTranslationFailed(() => base.Where_math_max_nested_twice(async)); - - public override async Task Where_math_degrees(bool async) - { - await base.Where_math_degrees(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND DEGREES(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_math_radians(bool async) - { - await base.Where_math_radians(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND RADIANS(CAST([o].[Discount] AS float)) > 0.0E0 -"""); - } - - public override async Task Where_mathf_abs1(bool async) - { - await base.Where_mathf_abs1(async); - - AssertSql( - """ -SELECT [p].[ProductID], [p].[Discontinued], [p].[ProductName], [p].[SupplierID], [p].[UnitPrice], [p].[UnitsInStock] -FROM [Products] AS [p] -WHERE ABS(CAST([p].[ProductID] AS real)) > CAST(10 AS real) -"""); - } - - public override async Task Where_mathf_ceiling1(bool async) - { - await base.Where_mathf_ceiling1(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[UnitPrice] < 7.0 AND CEILING([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_floor(bool async) - { - await base.Where_mathf_floor(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND FLOOR(CAST([o].[UnitPrice] AS real)) > CAST(10 AS real) -"""); - } - - public override async Task Where_mathf_power(bool async) - { - await base.Where_mathf_power(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER([o].[Discount], CAST(3 AS real)) > CAST(0.005 AS real) -"""); - } - - public override async Task Where_mathf_square(bool async) - { - await base.Where_mathf_square(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE POWER([o].[Discount], CAST(2 AS real)) > CAST(0.05 AS real) -"""); - } - - public override async Task Where_mathf_round2(bool async) - { - await base.Where_mathf_round2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE CAST(ROUND(CAST([o].[UnitPrice] AS real), 2) AS real) > CAST(100 AS real) -"""); - } - - public override async Task Select_mathf_round(bool async) - { - await base.Select_mathf_round(async); - - AssertSql( - """ -SELECT CAST(ROUND(CAST([o].[OrderID] AS real), 0) AS real) -FROM [Orders] AS [o] -WHERE [o].[OrderID] < 10250 -"""); - } - - public override async Task Select_mathf_round2(bool async) - { - await base.Select_mathf_round2(async); - - AssertSql( - """ -SELECT CAST(ROUND(CAST([o].[UnitPrice] AS real), 2) AS real) -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) -"""); - } - - public override async Task Where_mathf_truncate(bool async) - { - await base.Where_mathf_truncate(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) AND CAST(ROUND(CAST([o].[UnitPrice] AS real), 0, 1) AS real) > CAST(10 AS real) -"""); - } - - public override async Task Select_mathf_truncate(bool async) - { - await base.Select_mathf_truncate(async); - - AssertSql( - """ -SELECT CAST(ROUND(CAST([o].[UnitPrice] AS real), 0, 1) AS real) -FROM [Order Details] AS [o] -WHERE [o].[Quantity] < CAST(5 AS smallint) -"""); - } - - public override async Task Where_mathf_exp(bool async) - { - await base.Where_mathf_exp(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND EXP([o].[Discount]) > CAST(1 AS real) -"""); - } - - public override async Task Where_mathf_log10(bool async) - { - await base.Where_mathf_log10(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG10([o].[Discount]) < CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_log(bool async) - { - await base.Where_mathf_log(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG([o].[Discount]) < CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_log_new_base(bool async) - { - await base.Where_mathf_log_new_base(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND [o].[Discount] > CAST(0 AS real) AND LOG([o].[Discount], CAST(7 AS real)) < CAST(-1 AS real) -"""); - } - - public override async Task Where_mathf_sqrt(bool async) - { - await base.Where_mathf_sqrt(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SQRT([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_acos(bool async) - { - await base.Where_mathf_acos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ACOS([o].[Discount]) > CAST(1 AS real) -"""); - } - - public override async Task Where_mathf_asin(bool async) - { - await base.Where_mathf_asin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ASIN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_atan(bool async) - { - await base.Where_mathf_atan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATAN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_atan2(bool async) - { - await base.Where_mathf_atan2(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND ATN2([o].[Discount], CAST(1 AS real)) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_cos(bool async) - { - await base.Where_mathf_cos(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND COS([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_sin(bool async) - { - await base.Where_mathf_sin(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_tan(bool async) - { - await base.Where_mathf_tan(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND TAN([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_sign(bool async) - { - await base.Where_mathf_sign(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND SIGN([o].[Discount]) > 0 -"""); - } - - public override async Task Where_mathf_degrees(bool async) - { - await base.Where_mathf_degrees(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND DEGREES([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_mathf_radians(bool async) - { - await base.Where_mathf_radians(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] -FROM [Order Details] AS [o] -WHERE [o].[OrderID] = 11077 AND RADIANS([o].[Discount]) > CAST(0 AS real) -"""); - } - - public override async Task Where_guid_newguid(bool async) - { - await base.Where_guid_newguid(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE NEWID() <> '00000000-0000-0000-0000-000000000000' -"""); - } - - public override async Task Where_string_to_upper(bool async) - { - await base.Where_string_to_upper(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE UPPER([c].[CustomerID]) = N'ALFKI' -"""); - } - - public override async Task Where_string_to_lower(bool async) - { - await base.Where_string_to_lower(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE LOWER([c].[CustomerID]) = N'alfki' -"""); - } - - public override async Task Where_functions_nested(bool async) - { - await base.Where_functions_nested(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE POWER(CAST(CAST(LEN([c].[CustomerID]) AS int) AS float), 2.0E0) = 25.0E0 -"""); - } - - public override async Task Convert_ToBoolean(bool async) - { - await base.Convert_ToBoolean(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(bit, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(tinyint, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(decimal(18, 2), [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(float, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CAST(CONVERT(float, [o].[OrderID] % 3) AS real)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(smallint, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(int, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(bigint, [o].[OrderID] % 3)) = CAST(1 AS bit) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bit, CONVERT(int, [o].[OrderID] % 3)) = CAST(1 AS bit) -"""); - } - - public override async Task Convert_ToByte(bool async) - { - await base.Convert_ToByte(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(bit, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(tinyint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS tinyint) -"""); - } - - public override async Task Convert_ToDecimal(bool async) - { - await base.Convert_ToDecimal(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(bit, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(float, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(int, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(decimal(18, 2), CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0 -"""); - } - - public override async Task Convert_ToDouble(bool async) - { - await base.Convert_ToDouble(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(bit, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(float, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(smallint, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(int, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(bigint, [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0E0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(float, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0.0E0 -"""); - } - - public override async Task Convert_ToInt16(bool async) - { - await base.Convert_ToInt16(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(bit, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS smallint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(smallint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS smallint) -"""); - } - - public override async Task Convert_ToInt32(bool async) - { - await base.Convert_ToInt32(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(bit, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(tinyint, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(float, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(smallint, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(int, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(bigint, [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0 -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(int, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= 0 -"""); - } - - public override async Task Convert_ToInt64(bool async) - { - await base.Convert_ToInt64(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(bit, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(tinyint, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(decimal(18, 2), [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(float, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(smallint, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(int, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(bigint, [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS bigint) -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(bigint, CONVERT(nvarchar(max), [o].[OrderID] % 1)) >= CAST(0 AS bigint) -"""); - } - - public override async Task Convert_ToString(bool async) - { - await base.Convert_ToString(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(bit, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(tinyint, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(decimal(18, 2), [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(float, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CAST(CONVERT(float, [o].[OrderID] % 1) AS real)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(smallint, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(int, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(bigint, [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(nvarchar(max), [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND CONVERT(nvarchar(max), CONVERT(nvarchar(max), [o].[OrderID] % 1)) <> N'10' -""", - // - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[CustomerID] = N'ALFKI' AND (CONVERT(nvarchar(max), [o].[OrderDate]) LIKE N'%1997%' OR CONVERT(nvarchar(max), [o].[OrderDate]) LIKE N'%1998%') -"""); - } - - public override async Task Indexof_with_emptystring(bool async) - { - await base.Indexof_with_emptystring(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CASE - WHEN [c].[Region] IS NOT NULL THEN 0 -END = 0 -"""); - } - - public override async Task Indexof_with_one_constant_arg(bool async) - { - await base.Indexof_with_one_constant_arg(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(N'a', [c].[ContactName]) - 1 = 1 -"""); - } - - public override async Task Indexof_with_one_parameter_arg(bool async) - { - await base.Indexof_with_one_parameter_arg(async); - - AssertSql( - """ -@pattern='a' (Size = 30) - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(@pattern, [c].[ContactName]) - CASE - WHEN @pattern = N'' THEN 0 - ELSE 1 -END = 1 -"""); - } - - public override async Task Indexof_with_constant_starting_position(bool async) - { - await base.Indexof_with_constant_starting_position(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(N'a', [c].[ContactName], 3) - 1 = 4 -"""); - } - - public override async Task Indexof_with_parameter_starting_position(bool async) - { - await base.Indexof_with_parameter_starting_position(async); - - AssertSql( - """ -@start='2' - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(N'a', [c].[ContactName], @start + 1) - 1 = 4 -"""); - } - - public override async Task Replace_with_emptystring(bool async) - { - await base.Replace_with_emptystring(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE REPLACE([c].[ContactName], N'ia', N'') = N'Mar Anders' -"""); - } - - public override async Task Replace_using_property_arguments(bool async) - { - await base.Replace_using_property_arguments(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE REPLACE([c].[ContactName], [c].[ContactName], [c].[CustomerID]) = [c].[CustomerID] -"""); - } - - public override async Task Substring_with_one_arg_with_zero_startindex(bool async) - { - await base.Substring_with_one_arg_with_zero_startindex(async); - - AssertSql( - """ -SELECT [c].[ContactName] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[CustomerID], 0 + 1, LEN([c].[CustomerID])) = N'ALFKI' -"""); - } - - public override async Task Substring_with_one_arg_with_constant(bool async) - { - await base.Substring_with_one_arg_with_constant(async); - - AssertSql( - """ -SELECT [c].[ContactName] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[CustomerID], 1 + 1, LEN([c].[CustomerID])) = N'LFKI' -"""); - } - - public override async Task Substring_with_one_arg_with_closure(bool async) - { - await base.Substring_with_one_arg_with_closure(async); - - AssertSql( - """ -@start='2' - -SELECT [c].[ContactName] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[CustomerID], @start + 1, LEN([c].[CustomerID])) = N'FKI' -"""); - } - - public override async Task Substring_with_two_args_with_zero_startindex(bool async) - { - await base.Substring_with_two_args_with_zero_startindex(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], 0 + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_zero_length(bool async) - { - await base.Substring_with_two_args_with_zero_length(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], 2 + 1, 0) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_constant(bool async) - { - await base.Substring_with_two_args_with_constant(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], 1 + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_closure(bool async) - { - await base.Substring_with_two_args_with_closure(async); - - AssertSql( - """ -@start='2' - -SELECT SUBSTRING([c].[ContactName], @start + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_Index_of(bool async) - { - await base.Substring_with_two_args_with_Index_of(async); - - AssertSql( - """ -SELECT SUBSTRING([c].[ContactName], (CHARINDEX(N'a', [c].[ContactName]) - 1) + 1, 3) -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ALFKI' -"""); - } - - public override async Task IsNullOrEmpty_in_predicate(bool async) - { - await base.IsNullOrEmpty_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[Region] IS NULL OR [c].[Region] LIKE N'' -"""); - } - - public override async Task IsNullOrEmpty_in_projection(bool async) - { - await base.IsNullOrEmpty_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[Region] IS NULL OR [c].[Region] LIKE N'' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -"""); - } - - public override async Task IsNullOrEmpty_negated_in_predicate(bool async) - { - await base.IsNullOrEmpty_negated_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[Region] IS NOT NULL AND [c].[Region] NOT LIKE N'' -"""); - } - - public override async Task IsNullOrEmpty_negated_in_projection(bool async) - { - await base.IsNullOrEmpty_negated_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[Region] IS NOT NULL AND [c].[Region] NOT LIKE N'' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -"""); - } - - public override async Task IsNullOrWhiteSpace_in_predicate(bool async) - { - await base.IsNullOrWhiteSpace_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[Region] IS NULL OR [c].[Region] = N'' -"""); - } - - public override async Task IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(bool async) - { - await base.IsNullOrWhiteSpace_in_predicate_on_non_nullable_column(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'' -"""); - } - - public override async Task TrimStart_without_arguments_in_predicate(bool async) - { - await base.TrimStart_without_arguments_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE LTRIM([c].[ContactTitle]) = N'Owner' +SELECT [o].[OrderID], [o].[ProductID], [o].[Discount], [o].[Quantity], [o].[UnitPrice] +FROM [Order Details] AS [o] +WHERE [o].[UnitPrice] < 7.0 AND 10 < [o].[ProductID] """); } - public override Task TrimStart_with_char_argument_in_predicate(bool async) - => AssertTranslationFailed(() => base.TrimStart_with_char_argument_in_predicate(async)); - - public override Task TrimStart_with_char_array_argument_in_predicate(bool async) - => AssertTranslationFailed(() => base.TrimStart_with_char_array_argument_in_predicate(async)); - - public override async Task TrimEnd_without_arguments_in_predicate(bool async) + public override async Task Sum_over_round_works_correctly_in_projection(bool async) { - await base.TrimEnd_without_arguments_in_predicate(async); + await base.Sum_over_round_works_correctly_in_projection(async); AssertSql( """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE RTRIM([c].[ContactTitle]) = N'Owner' +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 2)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] +FROM [Orders] AS [o] +WHERE [o].[OrderID] < 10300 """); } - public override Task TrimEnd_with_char_argument_in_predicate(bool async) - => AssertTranslationFailed(() => base.TrimEnd_with_char_argument_in_predicate(async)); - - public override Task TrimEnd_with_char_array_argument_in_predicate(bool async) - => AssertTranslationFailed(() => base.TrimEnd_with_char_array_argument_in_predicate(async)); - - public override async Task Trim_without_argument_in_predicate(bool async) + public override async Task Sum_over_round_works_correctly_in_projection_2(bool async) { - await base.Trim_without_argument_in_predicate(async); + await base.Sum_over_round_works_correctly_in_projection_2(async); AssertSql( """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE LTRIM(RTRIM([c].[ContactTitle])) = N'Owner' +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 2)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] +FROM [Orders] AS [o] +WHERE [o].[OrderID] < 10300 """); } - public override async Task Trim_with_char_argument_in_predicate(bool async) - { - // String.Trim with parameters. Issue #22927. - await AssertTranslationFailed(() => base.Trim_with_char_argument_in_predicate(async)); - - AssertSql(); - } - - public override async Task Trim_with_char_array_argument_in_predicate(bool async) - { - // String.Trim with parameters. Issue #22927. - await AssertTranslationFailed(() => base.Trim_with_char_array_argument_in_predicate(async)); - - AssertSql(); - } - public override async Task Order_by_length_twice(bool async) { await base.Order_by_length_twice(async); @@ -2673,180 +90,74 @@ ORDER BY CAST(LEN([c].[CustomerID]) AS int), [c].[CustomerID] """); } - public override async Task Static_string_equals_in_predicate(bool async) - { - await base.Static_string_equals_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] = N'ANATR' -"""); - } - - public override async Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) + public override async Task Sum_over_truncate_works_correctly_in_projection(bool async) { - await base.Static_equals_nullable_datetime_compared_to_non_nullable(async); + await base.Sum_over_truncate_works_correctly_in_projection(async); AssertSql( """ -@arg='1996-07-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice], 0, 1)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] FROM [Orders] AS [o] -WHERE [o].[OrderDate] = @arg +WHERE [o].[OrderID] < 10300 """); } - public override async Task Static_equals_int_compared_to_long(bool async) + public override async Task Sum_over_truncate_works_correctly_in_projection_2(bool async) { - await base.Static_equals_int_compared_to_long(async); + await base.Sum_over_truncate_works_correctly_in_projection_2(async); AssertSql( """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] +SELECT [o].[OrderID], ( + SELECT COALESCE(SUM(ROUND([o0].[UnitPrice] * [o0].[UnitPrice], 0, 1)), 0.0) + FROM [Order Details] AS [o0] + WHERE [o].[OrderID] = [o0].[OrderID]) AS [Sum] FROM [Orders] AS [o] -WHERE 0 = 1 +WHERE [o].[OrderID] < 10300 """); } - public override async Task Where_DateOnly_FromDateTime(bool async) + public override async Task Where_functions_nested(bool async) { - await base.Where_DateOnly_FromDateTime(async); + await base.Where_functions_nested(async); AssertSql( """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE [o].[OrderDate] IS NOT NULL AND CAST([o].[OrderDate] AS date) = '1996-09-16' +SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] +FROM [Customers] AS [c] +WHERE POWER(CAST(CAST(LEN([c].[CustomerID]) AS int) AS float), 2.0E0) = 25.0E0 """); } - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) - => await base.Projecting_Math_Truncate_and_ordering_by_it_twice(async); - - // issue #16038 - // AssertSql( - // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] - //FROM [Orders] AS [o] - //WHERE [o].[OrderID] < 10250 - //ORDER BY [A]"); - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) - => await base.Projecting_Math_Truncate_and_ordering_by_it_twice2(async); - - // issue #16038 - // AssertSql( - // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] - //FROM [Orders] AS [o] - //WHERE [o].[OrderID] < 10250 - //ORDER BY [A] DESC"); - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) - => await base.Projecting_Math_Truncate_and_ordering_by_it_twice3(async); - - // issue #16038 - // AssertSql( - // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] - //FROM [Orders] AS [o] - //WHERE [o].[OrderID] < 10250 - //ORDER BY [A] DESC"); - public override Task Regex_IsMatch_MethodCall(bool async) - => AssertTranslationFailed(() => base.Regex_IsMatch_MethodCall(async)); - - public override Task Regex_IsMatch_MethodCall_constant_input(bool async) - => AssertTranslationFailed(() => base.Regex_IsMatch_MethodCall_constant_input(async)); - - public override Task Datetime_subtraction_TotalDays(bool async) - => AssertTranslationFailed(() => base.Datetime_subtraction_TotalDays(async)); - - public override async Task Select_ToString_IndexOf(bool async) + public override async Task Static_equals_nullable_datetime_compared_to_non_nullable(bool async) { - await base.Select_ToString_IndexOf(async); + await base.Static_equals_nullable_datetime_compared_to_non_nullable(async); AssertSql( """ +@arg='1996-07-04T00:00:00.0000000' (DbType = DateTime) + SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE CHARINDEX('123', CONVERT(varchar(11), [o].[OrderID])) - 1 = -1 +WHERE [o].[OrderDate] = @arg """); } - public override async Task Select_IndexOf_ToString(bool async) + public override async Task Static_equals_int_compared_to_long(bool async) { - await base.Select_IndexOf_ToString(async); + await base.Static_equals_int_compared_to_long(async); AssertSql( """ SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] FROM [Orders] AS [o] -WHERE CHARINDEX(CONVERT(varchar(11), [o].[OrderID]), '123') - CASE - WHEN CONVERT(varchar(11), [o].[OrderID]) = '' THEN 0 - ELSE 1 -END = -1 -"""); - } - - public override async Task String_Contains_in_projection(bool async) - { - await base.String_Contains_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[ContactName] IS NOT NULL AND (CHARINDEX([c].[ContactName], [c].[CompanyName]) > 0 OR [c].[ContactName] LIKE N'') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] -"""); - } - - public override async Task String_Contains_negated_in_predicate(bool async) - { - await base.String_Contains_negated_in_predicate(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[ContactName] IS NULL OR (CHARINDEX([c].[ContactName], [c].[CompanyName]) <= 0 AND [c].[ContactName] NOT LIKE N'') -"""); - } - - public override async Task String_Contains_negated_in_projection(bool async) - { - await base.String_Contains_negated_in_projection(async); - - AssertSql( - """ -SELECT [c].[CustomerID] AS [Id], CASE - WHEN [c].[ContactName] IS NULL OR (CHARINDEX([c].[ContactName], [c].[CompanyName]) <= 0 AND [c].[ContactName] NOT LIKE N'') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Value] -FROM [Customers] AS [c] +WHERE 0 = 1 """); } - public override async Task String_Contains_with_StringComparison_Ordinal(bool async) - { - await base.String_Contains_with_StringComparison_Ordinal(async); - - AssertSql(); - } - - public override async Task String_Contains_with_StringComparison_OrdinalIgnoreCase(bool async) - { - await base.String_Contains_with_StringComparison_OrdinalIgnoreCase(async); - - AssertSql(); - } - - public override async Task String_Contains_with_StringComparison_unsupported(bool async) - { - await base.String_Contains_with_StringComparison_unsupported(async); - - AssertSql(); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task StandardDeviation(bool async) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs index 66aa05c2f4a..c8baa1104c4 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/NorthwindWhereQuerySqlServerTest.cs @@ -588,18 +588,6 @@ FROM [Customers] AS [c0] """); } - public override async Task Where_equals_method_string(bool async) - { - await base.Where_equals_method_string(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[City] = N'London' -"""); - } - public override async Task Where_equals_method_int(bool async) { await base.Where_equals_method_int(async); @@ -778,253 +766,6 @@ WHERE [e].[ReportsTo] IS NULL """); } - public override async Task Where_string_length(bool async) - { - await base.Where_string_length(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CAST(LEN([c].[City]) AS int) = 6 -"""); - } - - public override async Task Where_string_indexof(bool async) - { - await base.Where_string_indexof(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CHARINDEX(N'Sea', [c].[City]) - 1 <> -1 OR [c].[City] IS NULL -"""); - } - - public override async Task Where_string_replace(bool async) - { - await base.Where_string_replace(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE REPLACE([c].[City], N'Sea', N'Rea') = N'Reattle' -"""); - } - - public override async Task Where_string_substring(bool async) - { - await base.Where_string_substring(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE SUBSTRING([c].[City], 1 + 1, 2) = N'ea' -"""); - } - - public override async Task Where_datetime_now(bool async) - { - await base.Where_datetime_now(async); - - AssertSql( - """ -@myDatetime='2015-04-10T00:00:00.0000000' - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE GETDATE() <> @myDatetime -"""); - } - - public override async Task Where_datetime_utcnow(bool async) - { - await base.Where_datetime_utcnow(async); - - AssertSql( - """ -@myDatetime='2015-04-10T00:00:00.0000000' - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE GETUTCDATE() <> @myDatetime -"""); - } - - public override async Task Where_datetimeoffset_utcnow(bool async) - { - await base.Where_datetimeoffset_utcnow(async); - - AssertSql( - """ -@myDatetimeOffset='2015-04-10T00:00:00.0000000-08:00' - -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE CAST(SYSUTCDATETIME() AS datetimeoffset) <> @myDatetimeOffset -"""); - } - - public override async Task Where_datetime_today(bool async) - { - await base.Where_datetime_today(async); - - AssertSql( - """ -SELECT [e].[EmployeeID], [e].[City], [e].[Country], [e].[FirstName], [e].[ReportsTo], [e].[Title] -FROM [Employees] AS [e] -"""); - } - - public override async Task Where_datetime_date_component(bool async) - { - await base.Where_datetime_date_component(async); - - AssertSql( - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE CONVERT(date, [o].[OrderDate]) = @myDatetime -"""); - } - - public override async Task Where_date_add_year_constant_component(bool async) - { - await base.Where_date_add_year_constant_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(year, DATEADD(year, CAST(-1 AS int), [o].[OrderDate])) = 1997 -"""); - } - - public override async Task Where_datetime_year_component(bool async) - { - await base.Where_datetime_year_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(year, [o].[OrderDate]) = 1998 -"""); - } - - public override async Task Where_datetime_month_component(bool async) - { - await base.Where_datetime_month_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(month, [o].[OrderDate]) = 4 -"""); - } - - public override async Task Where_datetime_dayOfYear_component(bool async) - { - await base.Where_datetime_dayOfYear_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(dayofyear, [o].[OrderDate]) = 68 -"""); - } - - public override async Task Where_datetime_day_component(bool async) - { - await base.Where_datetime_day_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(day, [o].[OrderDate]) = 4 -"""); - } - - public override async Task Where_datetime_hour_component(bool async) - { - await base.Where_datetime_hour_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(hour, [o].[OrderDate]) = 0 -"""); - } - - public override async Task Where_datetime_minute_component(bool async) - { - await base.Where_datetime_minute_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(minute, [o].[OrderDate]) = 0 -"""); - } - - public override async Task Where_datetime_second_component(bool async) - { - await base.Where_datetime_second_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(second, [o].[OrderDate]) = 0 -"""); - } - - public override async Task Where_datetime_millisecond_component(bool async) - { - await base.Where_datetime_millisecond_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE DATEPART(millisecond, [o].[OrderDate]) = 0 -"""); - } - - public override async Task Where_datetimeoffset_now_component(bool async) - { - await base.Where_datetimeoffset_now_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE CAST([o].[OrderDate] AS datetimeoffset) < SYSDATETIMEOFFSET() -"""); - } - - public override async Task Where_datetimeoffset_utcnow_component(bool async) - { - await base.Where_datetimeoffset_utcnow_component(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE CAST([o].[OrderDate] AS datetimeoffset) <> CAST(SYSUTCDATETIME() AS datetimeoffset) OR [o].[OrderDate] IS NULL -"""); - } - public override async Task Where_simple_reversed(bool async) { await base.Where_simple_reversed(async); @@ -1537,120 +1278,6 @@ FROM [Customers] AS [c] """); } - public override async Task Where_concat_string_int_comparison1(bool async) - { - await base.Where_concat_string_int_comparison1(async); - - AssertSql( - """ -@i='10' - -SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] + CAST(@i AS nvarchar(max)) = [c].[CompanyName] -"""); - } - - public override async Task Where_concat_string_int_comparison2(bool async) - { - await base.Where_concat_string_int_comparison2(async); - - AssertSql( - """ -@i='10' - -SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE CAST(@i AS nvarchar(max)) + [c].[CustomerID] = [c].[CompanyName] -"""); - } - - public override async Task Where_concat_string_int_comparison3(bool async) - { - await base.Where_concat_string_int_comparison3(async); - - AssertSql( - """ -@p='30' -@j='21' - -SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE CAST(@p AS nvarchar(max)) + [c].[CustomerID] + CAST(@j AS nvarchar(max)) + CAST(42 AS nvarchar(max)) = [c].[CompanyName] -"""); - } - - public override async Task Where_concat_string_int_comparison4(bool async) - { - await base.Where_concat_string_int_comparison4(async); - - AssertSql( - """ -SELECT [o].[CustomerID] -FROM [Orders] AS [o] -WHERE CAST([o].[OrderID] AS nvarchar(max)) + COALESCE([o].[CustomerID], N'') = [o].[CustomerID] -"""); - } - - public override async Task Where_concat_string_string_comparison(bool async) - { - await base.Where_concat_string_string_comparison(async); - - AssertSql( - """ -@i='A' (Size = 4000) - -SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE @i + [c].[CustomerID] = N'AALFKI' -"""); - } - - public override async Task Where_string_concat_method_comparison(bool async) - { - await base.Where_string_concat_method_comparison(async); - - AssertSql( - """ -@i='A' (Size = 4000) - -SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE @i + [c].[CustomerID] = N'AAROUT' -"""); - } - - public override async Task Where_string_concat_method_comparison_2(bool async) - { - await base.Where_string_concat_method_comparison_2(async); - - AssertSql( - """ -@i='A' (Size = 4000) -@j='B' (Size = 4000) - -SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE @i + @j + [c].[CustomerID] = N'ABANATR' -"""); - } - - public override async Task Where_string_concat_method_comparison_3(bool async) - { - await base.Where_string_concat_method_comparison_3(async); - - AssertSql( - """ -@i='A' (Size = 4000) -@j='B' (Size = 4000) -@k='C' (Size = 4000) - -SELECT [c].[CustomerID] -FROM [Customers] AS [c] -WHERE @i + @j + @k + [c].[CustomerID] = N'ABCANTON' -"""); - } - public override async Task Where_ternary_boolean_condition_true(bool async) { await base.Where_ternary_boolean_condition_true(async); @@ -1987,17 +1614,6 @@ FROM [Orders] AS [o] """); } - public override async Task Time_of_day_datetime(bool async) - { - await base.Time_of_day_datetime(async); - - AssertSql( - """ -SELECT CONVERT(time, [o].[OrderDate]) -FROM [Orders] AS [o] -"""); - } - public override async Task TypeBinary_short_circuit(bool async) { await base.TypeBinary_short_circuit(async); @@ -2104,30 +1720,6 @@ FROM [Orders] AS [o] """); } - public override async Task Like_with_non_string_column_using_ToString(bool async) - { - await base.Like_with_non_string_column_using_ToString(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE CONVERT(varchar(11), [o].[OrderID]) LIKE '%20%' -"""); - } - - public override async Task Like_with_non_string_column_using_double_cast(bool async) - { - await base.Like_with_non_string_column_using_double_cast(async); - - AssertSql( - """ -SELECT [o].[OrderID], [o].[CustomerID], [o].[EmployeeID], [o].[OrderDate] -FROM [Orders] AS [o] -WHERE CAST([o].[OrderID] AS nvarchar(max)) LIKE N'%20%' -"""); - } - [ConditionalTheory] public override async Task Using_same_parameter_twice_in_query_generates_one_sql_parameter(bool async) { @@ -2971,30 +2563,6 @@ FROM OPENJSON(@customerIds) WITH ([value] nchar(5) '$') AS [c0] """); } - public override async Task Where_Like_and_comparison(bool async) - { - await base.Where_Like_and_comparison(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] LIKE N'F%' AND [c].[City] = N'Seattle' -"""); - } - - public override async Task Where_Like_or_comparison(bool async) - { - await base.Where_Like_or_comparison(async); - - AssertSql( - """ -SELECT [c].[CustomerID], [c].[Address], [c].[City], [c].[CompanyName], [c].[ContactName], [c].[ContactTitle], [c].[Country], [c].[Fax], [c].[Phone], [c].[PostalCode], [c].[Region] -FROM [Customers] AS [c] -WHERE [c].[CustomerID] LIKE N'F%' OR [c].[City] = N'Seattle' -"""); - } - public override async Task GetType_on_non_hierarchy1(bool async) { await base.GetType_on_non_hierarchy1(async); @@ -3215,13 +2783,6 @@ public override async Task Where_bool_client_side_negated(bool async) AssertSql(); } - public override async Task Where_equals_method_string_with_ignore_case(bool async) - { - await base.Where_equals_method_string_with_ignore_case(async); - - AssertSql(); - } - public override async Task Where_nested_field_access_closure_via_query_cache_error_null(bool async) { await base.Where_nested_field_access_closure_via_query_cache_error_null(async); diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs index e077388d662..182be105b6d 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCGearsOfWarQuerySqlServerTest.cs @@ -517,9 +517,9 @@ WHERE [u].[Nickname] <> N'Paduk' OR [u].[Nickname] IS NULL """); } - public override async Task Where_enum(bool async) + public override async Task Where_count_subquery_without_collision(bool async) { - await base.Where_enum(async); + await base.Where_count_subquery_without_collision(async); AssertSql( """ @@ -531,237 +531,218 @@ 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 [u].[Rank] = 4 +WHERE ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]) = 2 """); } - public override async Task Where_nullable_enum_with_constant(bool async) + public override async Task Where_any_subquery_without_collision(bool async) { - await base.Where_nullable_enum_with_constant(async); + await base.Where_any_subquery_without_collision(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = 1 +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]) """); } - public override async Task Where_nullable_enum_with_null_constant(bool async) + public override async Task Select_inverted_boolean(bool async) { - await base.Where_nullable_enum_with_null_constant(async); + await base.Select_inverted_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], ~[w].[IsAutomatic] AS [Manual] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL +WHERE [w].[IsAutomatic] = CAST(1 AS bit) """); } - public override async Task Where_nullable_enum_with_non_nullable_parameter(bool async) + public override async Task Select_inverted_nullable_boolean(bool async) { - await base.Where_nullable_enum_with_non_nullable_parameter(async); + await base.Select_inverted_nullable_boolean(async); AssertSql( """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType +SELECT [l].[Id], ~[l].[Eradicated] AS [Alive] +FROM [LocustHordes] AS [l] """); } - public override async Task Where_nullable_enum_with_nullable_parameter(bool async) + public override async Task Select_comparison_with_null(bool async) { - await base.Where_nullable_enum_with_nullable_parameter(async); + await base.Select_comparison_with_null(async); AssertSql( """ @ammunitionType='1' (Nullable = true) -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] = @ammunitionType AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] = @ammunitionType """, // """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL """); } - public override async Task Where_bitwise_and_enum(bool async) + public override async Task Select_null_parameter(bool async) { - await base.Where_bitwise_and_enum(async); + await base.Select_null_parameter(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Rank] & 2 > 0 +@ammunitionType='1' (Nullable = true) + +SELECT [w].[Id], @ammunitionType AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Rank] & 2 = 2 -"""); - } - - public override async Task Where_bitwise_and_integral(bool async) - { - await base.Where_bitwise_and_integral(async); - - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Rank] & 1 = 1 +SELECT [w].[Id], NULL AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 CAST([u].[Rank] AS bigint) & CAST(1 AS bigint) = CAST(1 AS bigint) +@ammunitionType='2' (Nullable = true) + +SELECT [w].[Id], @ammunitionType AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 CAST([u].[Rank] AS smallint) & CAST(1 AS smallint) = CAST(1 AS smallint) +SELECT [w].[Id], NULL AS [AmmoType] +FROM [Weapons] AS [w] """); } - public override async Task Where_bitwise_and_nullable_enum_with_constant(bool async) + public override async Task Select_ternary_operation_with_boolean(bool async) { - await base.Where_bitwise_and_nullable_enum_with_constant(async); + await base.Select_ternary_operation_with_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 + ELSE 0 +END AS [Num] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & 1 > 0 """); } - public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) + public override async Task Select_ternary_operation_with_inverted_boolean(bool async) { - await base.Where_bitwise_and_nullable_enum_with_null_constant(async); + await base.Select_ternary_operation_with_inverted_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN 1 + ELSE 0 +END AS [Num] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 """); } - public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) + public override async Task Select_ternary_operation_with_has_value_not_null(bool async) { - await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); + await base.Select_ternary_operation_with_has_value_not_null(async); AssertSql( """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 +WHERE [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 """); } - public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) + public override async Task Select_ternary_operation_multiple_conditions(bool async) { - await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); + await base.Select_ternary_operation_multiple_conditions(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] = 2 AND [w].[SynergyWithId] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 -""", - // +"""); + } + + public override async Task Select_ternary_operation_multiple_conditions_2(bool async) + { + await base.Select_ternary_operation_multiple_conditions_2(async); + + AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 """); } - public override async Task Where_bitwise_or_enum(bool async) + public override async Task Select_multiple_conditions(bool async) { - await base.Where_bitwise_or_enum(async); + await base.Select_multiple_conditions(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Rank] | 2 > 0 +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [IsCartridge] +FROM [Weapons] AS [w] """); } - public override async Task Bitwise_projects_values_in_select(bool async) + public override async Task Select_nested_ternary_operations(bool async) { - await base.Bitwise_projects_values_in_select(async); + await base.Select_nested_ternary_operations(async); AssertSql( """ -SELECT TOP(1) ~CAST(([u].[Rank] & 2) ^ 2 AS bit) AS [BitwiseTrue], ~CAST(([u].[Rank] & 2) ^ 4 AS bit) AS [BitwiseFalse], [u].[Rank] & 2 AS [BitwiseValue] -FROM ( - SELECT [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Rank] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[Rank] & 2 = 2 +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CASE + WHEN [w].[AmmunitionType] = 1 THEN N'ManualCartridge' + ELSE N'Manual' + END + ELSE N'Auto' +END AS [IsManualCartridge] +FROM [Weapons] AS [w] """); } - public override async Task Where_enum_has_flag(bool async) + public override async Task Null_propagation_optimization1(bool async) { - await base.Where_enum_has_flag(async); + await base.Null_propagation_optimization1(async); AssertSql( """ @@ -773,21 +754,16 @@ 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 [u].[Rank] & 2 = 2 -""", - // - """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Rank] & 18 = 18 -""", - // +WHERE [u].[LeaderNickname] = N'Marcus' +"""); + } + + public override async Task Null_propagation_optimization2(bool async) + { + await base.Null_propagation_optimization2(async); + + // issue #16050 + AssertSql( """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( @@ -797,9 +773,20 @@ 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 [u].[Rank] & 1 = 1 -""", - // +WHERE CASE + WHEN [u].[LeaderNickname] IS NULL THEN NULL + WHEN [u].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) +"""); + } + + public override async Task Null_propagation_optimization3(bool async) + { + await base.Null_propagation_optimization3(async); + + // issue #16050 + AssertSql( """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( @@ -809,9 +796,21 @@ 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 [u].[Rank] & 1 = 1 -""", - // +WHERE CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN CASE + WHEN [u].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END +END = CAST(1 AS bit) +"""); + } + + public override async Task Null_propagation_optimization4(bool async) + { + await base.Null_propagation_optimization4(async); + + // issue #16050 + AssertSql( """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( @@ -821,14 +820,18 @@ 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 2 & [u].[Rank] = [u].[Rank] +WHERE CASE + WHEN [u].[LeaderNickname] IS NULL THEN NULL + ELSE CAST(LEN([u].[LeaderNickname]) AS int) +END = 5 """); } - public override async Task Where_enum_has_flag_subquery(bool async) + public override async Task Null_propagation_optimization5(bool async) { - await base.Where_enum_has_flag_subquery(async); + await base.Null_propagation_optimization5(async); + // issue #16050 AssertSql( """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] @@ -839,27 +842,18 @@ 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 [u].[Rank] & COALESCE(( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]), 0) -""", - // +WHERE CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(LEN([u].[LeaderNickname]) AS int) +END = 5 +"""); + } + + public override async Task Null_propagation_optimization6(bool async) + { + await base.Null_propagation_optimization6(async); + + // issue #16050 + AssertSql( """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( @@ -869,1533 +863,1511 @@ 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 2 & COALESCE(( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]), 0) +WHERE CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(LEN([u].[LeaderNickname]) AS int) +END = 5 """); } - public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async) + public override async Task Select_null_propagation_optimization7(bool async) { - await base.Where_enum_has_flag_subquery_with_pushdown(async); + await base.Select_null_propagation_optimization7(async); + // issue #16050 AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN [u].[LeaderNickname] + [u].[LeaderNickname] +END FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[LeaderNickname] FROM [Gears] AS [g] 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] + SELECT [o].[LeaderNickname] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[Rank] & ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) = ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) OR ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) IS NULL -""", - // +"""); + } + + public override async Task Select_null_propagation_optimization8(bool async) + { + await base.Select_null_propagation_optimization8(async); + + AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT COALESCE([u].[LeaderNickname], N'') + COALESCE([u].[LeaderNickname], N'') FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[LeaderNickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[LeaderNickname] FROM [Officers] AS [o] ) AS [u] -WHERE 2 & ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) = ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) OR ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) IS NULL """); } - public override async Task Where_enum_has_flag_subquery_client_eval(bool async) + public override async Task Select_null_propagation_optimization9(bool async) { - await base.Where_enum_has_flag_subquery_client_eval(async); + await base.Select_null_propagation_optimization9(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT CAST(LEN([u].[FullName]) AS int) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[Rank] & ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) = ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) OR ( - SELECT TOP(1) [u0].[Rank] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - ORDER BY [u0].[Nickname], [u0].[SquadId]) IS NULL """); } - public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool async) + public override async Task Select_null_propagation_negative1(bool async) { - await base.Where_enum_has_flag_with_non_nullable_parameter(async); + await base.Select_null_propagation_negative1(async); AssertSql( """ -@parameter='2' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) +END FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[LeaderNickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[LeaderNickname] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[Rank] & @parameter = @parameter """); } - public override async Task Where_has_flag_with_nullable_parameter(bool async) + public override async Task Select_null_propagation_negative2(bool async) { - await base.Where_has_flag_with_nullable_parameter(async); + await base.Select_null_propagation_negative2(async); AssertSql( """ -@parameter='2' (Nullable = true) - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN [u0].[LeaderNickname] +END FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[LeaderNickname] FROM [Gears] AS [g] 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] + SELECT [o].[LeaderNickname] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[Rank] & @parameter = @parameter +CROSS JOIN ( + SELECT [g0].[LeaderNickname] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[LeaderNickname] + FROM [Officers] AS [o0] +) AS [u0] """); } - public override async Task Select_enum_has_flag(bool async) + public override async Task Select_null_propagation_negative3(bool async) { - await base.Select_enum_has_flag(async); + await base.Select_null_propagation_negative3(async); AssertSql( """ -SELECT TOP(1) ~CAST(([u].[Rank] & 2) ^ 2 AS bit) AS [hasFlagTrue], ~CAST(([u].[Rank] & 4) ^ 4 AS bit) AS [hasFlagFalse] +SELECT [u0].[Nickname], CASE + WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CASE + WHEN [u0].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END +END AS [Condition] FROM ( - SELECT [g].[Rank] + SELECT [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Rank] + SELECT [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[Rank] & 2 = 2 +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[LeaderNickname] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[LeaderNickname] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [u0].[Nickname] """); } - public override async Task Where_count_subquery_without_collision(bool async) + public override async Task Select_null_propagation_negative4(bool async) { - await base.Where_count_subquery_without_collision(async); + await base.Select_null_propagation_negative4(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT CASE + WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u0].[Nickname] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -WHERE ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]) = 2 +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [u0].[Nickname] """); } - public override async Task Where_any_subquery_without_collision(bool async) + public override async Task Select_null_propagation_negative5(bool async) { - await base.Where_any_subquery_without_collision(async); + await base.Select_null_propagation_negative5(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT CASE + WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u0].[Nickname] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -WHERE EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]) +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [u0].[Nickname] """); } - public override async Task Select_inverted_boolean(bool async) + public override async Task Select_null_propagation_negative6(bool async) { - await base.Select_inverted_boolean(async); + await base.Select_null_propagation_negative6(async); AssertSql( """ -SELECT [w].[Id], ~[w].[IsAutomatic] AS [Manual] -FROM [Weapons] AS [w] -WHERE [w].[IsAutomatic] = CAST(1 AS bit) +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(0 AS bit) +END +FROM ( + SELECT [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task Select_inverted_nullable_boolean(bool async) + public override async Task Select_null_propagation_negative7(bool async) { - await base.Select_inverted_nullable_boolean(async); + await base.Select_null_propagation_negative7(async); AssertSql( """ -SELECT [l].[Id], ~[l].[Eradicated] AS [Alive] -FROM [LocustHordes] AS [l] +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) +END +FROM ( + SELECT [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task Select_comparison_with_null(bool async) + public override async Task Select_null_propagation_negative8(bool async) { - await base.Select_comparison_with_null(async); + await base.Select_null_propagation_negative8(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = @ammunitionType AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Cartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType -""", - // - """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Cartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL +SELECT CASE + WHEN [s].[Id] IS NOT NULL THEN [c].[Name] +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] +LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] """); } - public override async Task Select_null_parameter(bool async) + public override async Task Select_null_propagation_negative9(bool async) { - await base.Select_null_parameter(async); + await base.Select_null_propagation_negative9(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], @ammunitionType AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -SELECT [w].[Id], NULL AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -@ammunitionType='2' (Nullable = true) - -SELECT [w].[Id], @ammunitionType AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -SELECT [w].[Id], NULL AS [AmmoType] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) +END +FROM ( + SELECT [g].[Nickname], [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task Select_ternary_operation_with_boolean(bool async) + public override async Task Select_null_propagation_works_for_navigations_with_composite_keys(bool async) { - await base.Select_ternary_operation_with_boolean(async); + await base.Select_null_propagation_works_for_navigations_with_composite_keys(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 - ELSE 0 -END AS [Num] -FROM [Weapons] AS [w] +SELECT [u].[Nickname] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Select_ternary_operation_with_inverted_boolean(bool async) + public override async Task Select_null_propagation_works_for_multiple_navigations_with_composite_keys(bool async) { - await base.Select_ternary_operation_with_inverted_boolean(async); + await base.Select_null_propagation_works_for_multiple_navigations_with_composite_keys(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN 1 - ELSE 0 -END AS [Num] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [c].[Name] IS NOT NULL THEN [c].[Name] +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN [Tags] AS [t0] ON ([u].[Nickname] = [t0].[GearNickName] OR ([u].[Nickname] IS NULL AND [t0].[GearNickName] IS NULL)) AND ([u].[SquadId] = [t0].[GearSquadId] OR ([u].[SquadId] IS NULL AND [t0].[GearSquadId] IS NULL)) +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName] + FROM [Officers] AS [o0] +) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] +LEFT JOIN [Cities] AS [c] ON [u0].[AssignedCityName] = [c].[Name] """); } - public override async Task Select_ternary_operation_with_has_value_not_null(bool async) + public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) { - await base.Select_ternary_operation_with_has_value_not_null(async); + await base.Select_conditional_with_anonymous_type_and_null_constant(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u].[HasSoulPatch] +FROM ( + SELECT [g].[Nickname], [g].[HasSoulPatch], [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[HasSoulPatch], [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] +ORDER BY [u].[Nickname] """); } - public override async Task Select_ternary_operation_multiple_conditions(bool async) + public override async Task Select_conditional_with_anonymous_types(bool async) { - await base.Select_ternary_operation_multiple_conditions(async); + await base.Select_conditional_with_anonymous_types(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = 2 AND [w].[SynergyWithId] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u].[Nickname], [u].[FullName] +FROM ( + SELECT [g].[Nickname], [g].[FullName], [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[FullName], [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] +ORDER BY [u].[Nickname] """); } - public override async Task Select_ternary_operation_multiple_conditions_2(bool async) + public override async Task Where_conditional_equality_1(bool async) { - await base.Select_ternary_operation_multiple_conditions_2(async); + await base.Where_conditional_equality_1(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT [u].[Nickname] +FROM ( + SELECT [g].[Nickname], [g].[HasSoulPatch], [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[HasSoulPatch], [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] +WHERE [u].[LeaderNickname] IS NULL +ORDER BY [u].[Nickname] """); } - public override async Task Select_multiple_conditions(bool async) + public override async Task Where_conditional_equality_2(bool async) { - await base.Select_multiple_conditions(async); + await base.Where_conditional_equality_2(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT [u].[Nickname] +FROM ( + SELECT [g].[Nickname], [g].[HasSoulPatch], [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[HasSoulPatch], [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] +WHERE [u].[LeaderNickname] IS NULL +ORDER BY [u].[Nickname] """); } - public override async Task Select_nested_ternary_operations(bool async) + public override async Task Where_conditional_equality_3(bool async) { - await base.Select_nested_ternary_operations(async); + await base.Where_conditional_equality_3(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CASE - WHEN [w].[AmmunitionType] = 1 THEN N'ManualCartridge' - ELSE N'Manual' - END - ELSE N'Auto' -END AS [IsManualCartridge] -FROM [Weapons] AS [w] +SELECT [u].[Nickname] +FROM ( + SELECT [g].[Nickname], [g].[LeaderNickname] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[LeaderNickname] + FROM [Officers] AS [o] +) AS [u] +ORDER BY [u].[Nickname] """); } - public override async Task Null_propagation_optimization1(bool async) + public override async Task Select_coalesce_with_anonymous_types(bool async) { - await base.Null_propagation_optimization1(async); + await base.Select_coalesce_with_anonymous_types(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[LeaderNickname], [u].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[FullName], [g].[LeaderNickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[FullName], [o].[LeaderNickname] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[LeaderNickname] = N'Marcus' +ORDER BY [u].[Nickname] """); } - public override async Task Null_propagation_optimization2(bool async) + public override async Task Where_compare_anonymous_types(bool async) { - await base.Null_propagation_optimization2(async); + await base.Where_compare_anonymous_types(async); + + AssertSql(); + } + + public override async Task Where_member_access_on_anonymous_type(bool async) + { + await base.Where_member_access_on_anonymous_type(async); - // issue #16050 AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[LeaderNickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[LeaderNickname] FROM [Officers] AS [o] ) AS [u] -WHERE CASE - WHEN [u].[LeaderNickname] IS NULL THEN NULL - WHEN [u].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +WHERE [u].[LeaderNickname] = N'Marcus' """); } - public override async Task Null_propagation_optimization3(bool async) + public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) { - await base.Null_propagation_optimization3(async); + await base.Where_compare_anonymous_types_with_uncorrelated_members(async); - // issue #16050 AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname] FROM [Officers] AS [o] ) AS [u] -WHERE CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CASE - WHEN [u].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END -END = CAST(1 AS bit) +WHERE 0 = 1 """); } - public override async Task Null_propagation_optimization4(bool async) + public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool async) { - await base.Null_propagation_optimization4(async); + await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(async); - // issue #16050 AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] -WHERE CASE - WHEN [u].[LeaderNickname] IS NULL THEN NULL - ELSE CAST(LEN([u].[LeaderNickname]) AS int) -END = 5 +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] +WHERE [u].[Nickname] = [u0].[Nickname] OR ([u].[Nickname] IS NULL AND [u0].[Nickname] IS NULL) """); } - public override async Task Null_propagation_optimization5(bool async) + public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) { - await base.Null_propagation_optimization5(async); + await base.Select_Singleton_Navigation_With_Member_Access(async); - // issue #16050 AssertSql( """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( +FROM [Tags] AS [t] +LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] 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 +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[Nickname] = N'Marcus' AND ([u].[CityOfBirthName] <> N'Ephyra' OR [u].[CityOfBirthName] IS NULL) """); } - public override async Task Null_propagation_optimization6(bool async) + public override async Task Select_Where_Navigation(bool async) { - await base.Null_propagation_optimization6(async); + await base.Select_Where_Navigation(async); - // issue #16050 AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] -WHERE CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(LEN([u].[LeaderNickname]) AS int) -END = 5 +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[Nickname] = N'Marcus' """); } - public override async Task Select_null_propagation_optimization7(bool async) + public override async Task Select_Where_Navigation_Equals_Navigation(bool async) { - await base.Select_null_propagation_optimization7(async); + await base.Select_Where_Navigation_Equals_Navigation(async); - // issue #16050 AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN [u].[LeaderNickname] + [u].[LeaderNickname] -END -FROM ( - SELECT [g].[LeaderNickname] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[LeaderNickname] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] +WHERE ([u].[Nickname] = [u0].[Nickname] OR ([u].[Nickname] IS NULL AND [u0].[Nickname] IS NULL)) AND ([u].[SquadId] = [u0].[SquadId] OR ([u].[SquadId] IS NULL AND [u0].[SquadId] IS NULL)) """); } - public override async Task Select_null_propagation_optimization8(bool async) + public override async Task Select_Where_Navigation_Null(bool async) { - await base.Select_null_propagation_optimization8(async); + await base.Select_Where_Navigation_Null(async); AssertSql( """ -SELECT COALESCE([u].[LeaderNickname], N'') + COALESCE([u].[LeaderNickname], N'') -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[LeaderNickname] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[LeaderNickname] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[Nickname] IS NULL OR [u].[SquadId] IS NULL """); } - public override async Task Select_null_propagation_optimization9(bool async) + public override async Task Select_Where_Navigation_Null_Reverse(bool async) { - await base.Select_null_propagation_optimization9(async); + await base.Select_Where_Navigation_Null_Reverse(async); AssertSql( """ -SELECT CAST(LEN([u].[FullName]) AS int) -FROM ( - SELECT [g].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[Nickname] IS NULL OR [u].[SquadId] IS NULL """); } - public override async Task Select_null_propagation_negative1(bool async) + public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool async) { - await base.Select_null_propagation_negative1(async); + await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) -END -FROM ( - SELECT [g].[Nickname], [g].[LeaderNickname] +SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[LeaderNickname] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] +WHERE [u].[Nickname] = [u0].[Nickname] OR ([u].[Nickname] IS NULL AND [u0].[Nickname] IS NULL) """); } - public override async Task Select_null_propagation_negative2(bool async) + public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool async) { - await base.Select_null_propagation_negative2(async); + await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN [u0].[LeaderNickname] -END -FROM ( - SELECT [g].[LeaderNickname] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[LeaderNickname] - FROM [Officers] AS [o] -) AS [u] -CROSS JOIN ( - SELECT [g0].[LeaderNickname] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[LeaderNickname] - FROM [Officers] AS [o0] -) AS [u0] +SELECT TOP(1) COALESCE([w0].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w].[Id] """); } - public override async Task Select_null_propagation_negative3(bool async) + public override async Task Where_subquery_boolean(bool async) { - await base.Select_null_propagation_negative3(async); + await base.Where_subquery_boolean(async); AssertSql( """ -SELECT [u0].[Nickname], CASE - WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CASE - WHEN [u0].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END -END AS [Condition] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[HasSoulPatch] + 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[LeaderNickname] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[LeaderNickname] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [u0].[Nickname] +WHERE COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_negative4(bool async) + public override async Task Where_subquery_boolean_with_pushdown(bool async) { - await base.Select_null_propagation_negative4(async); + await base.Where_subquery_boolean_with_pushdown(async); AssertSql( """ -SELECT CASE - WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u0].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[HasSoulPatch] + 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [u0].[Nickname] +WHERE ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_negative5(bool async) + public override async Task Where_subquery_distinct_firstordefault_boolean(bool async) { - await base.Select_null_propagation_negative5(async); + await base.Where_subquery_distinct_firstordefault_boolean(async); AssertSql( """ -SELECT CASE - WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u0].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[HasSoulPatch] + 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [u0].[Nickname] -"""); +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +"""); } - public override async Task Select_null_propagation_negative6(bool async) + public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) { - await base.Select_null_propagation_negative6(async); + await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(0 AS bit) -END +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[LeaderNickname] + 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_negative7(bool async) + public override async Task Where_subquery_distinct_first_boolean(bool async) { - await base.Select_null_propagation_negative7(async); + await base.Where_subquery_distinct_first_boolean(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) -END +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[LeaderNickname] + 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) +ORDER BY [u].[Nickname] """); } - public override async Task Select_null_propagation_negative8(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean1(bool async) { - await base.Select_null_propagation_negative8(async); + await base.Where_subquery_distinct_singleordefault_boolean1(async); AssertSql( """ -SELECT CASE - WHEN [s].[Id] IS NOT NULL THEN [c].[Name] -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]), CAST(0 AS bit)) = CAST(1 AS bit) +ORDER BY [u].[Nickname] """); } - public override async Task Select_null_propagation_negative9(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean2(bool async) { - await base.Select_null_propagation_negative9(async); + await base.Where_subquery_distinct_singleordefault_boolean2(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) -END +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[LeaderNickname] + 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) = CAST(1 AS bit) +ORDER BY [u].[Nickname] """); } - public override async Task Select_null_propagation_works_for_navigations_with_composite_keys(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { - await base.Select_null_propagation_works_for_navigations_with_composite_keys(async); + await base.Where_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [u].[Nickname] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]) = CAST(1 AS bit) +ORDER BY [u].[Nickname] """); } - public override async Task Select_null_propagation_works_for_multiple_navigations_with_composite_keys(bool async) + public override async Task Where_subquery_distinct_lastordefault_boolean(bool async) { - await base.Select_null_propagation_works_for_multiple_navigations_with_composite_keys(async); + await base.Where_subquery_distinct_lastordefault_boolean(async); AssertSql( """ -SELECT CASE - WHEN [c].[Name] IS NOT NULL THEN [c].[Name] -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN [Tags] AS [t0] ON ([u].[Nickname] = [t0].[GearNickName] OR ([u].[Nickname] IS NULL AND [t0].[GearNickName] IS NULL)) AND ([u].[SquadId] = [t0].[GearSquadId] OR ([u].[SquadId] IS NULL AND [t0].[GearSquadId] IS NULL)) -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName] - FROM [Officers] AS [o0] -) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] -LEFT JOIN [Cities] AS [c] ON [u0].[AssignedCityName] = [c].[Name] +) AS [u] +WHERE ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id] DESC) = CAST(0 AS bit) +ORDER BY [u].[Nickname] """); } - public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) + public override async Task Where_subquery_distinct_last_boolean(bool async) { - await base.Select_conditional_with_anonymous_type_and_null_constant(async); + await base.Where_subquery_distinct_last_boolean(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[HasSoulPatch], [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[HasSoulPatch], [o].[LeaderNickname] + 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 [u].[HasSoulPatch] = CAST(0 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id] DESC) = CAST(1 AS bit) ORDER BY [u].[Nickname] """); } - public override async Task Select_conditional_with_anonymous_types(bool async) + public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool async) { - await base.Select_conditional_with_anonymous_types(async); + await base.Where_subquery_distinct_orderby_firstordefault_boolean(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u].[Nickname], [u].[FullName] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[FullName], [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[FullName], [o].[LeaderNickname] + 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] -ORDER BY [u].[Nickname] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Where_conditional_equality_1(bool async) + public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool async) { - await base.Where_conditional_equality_1(async); + await base.Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[HasSoulPatch], [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[HasSoulPatch], [o].[LeaderNickname] + 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 [u].[LeaderNickname] IS NULL -ORDER BY [u].[Nickname] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) """); } - public override async Task Where_conditional_equality_2(bool async) + public override async Task Where_subquery_union_firstordefault_boolean(bool async) { - await base.Where_conditional_equality_2(async); + await base.Where_subquery_union_firstordefault_boolean(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[HasSoulPatch], [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[HasSoulPatch], [o].[LeaderNickname] + 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 [u].[LeaderNickname] IS NULL -ORDER BY [u].[Nickname] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [u0].[IsAutomatic] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + UNION + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [u].[FullName] = [w0].[OwnerFullName] + ) AS [u0] + ORDER BY [u0].[Id]) = CAST(1 AS bit) """); } - public override async Task Where_conditional_equality_3(bool async) + public override async Task Where_subquery_join_firstordefault_boolean(bool async) { - await base.Where_conditional_equality_3(async); + await base.Where_subquery_join_firstordefault_boolean(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[LeaderNickname] + 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] -ORDER BY [u].[Nickname] -"""); - } - - public override async Task Select_coalesce_with_anonymous_types(bool async) - { - await base.Select_coalesce_with_anonymous_types(async); - - AssertSql( - """ -SELECT [u].[LeaderNickname], [u].[FullName] -FROM ( - SELECT [g].[Nickname], [g].[FullName], [g].[LeaderNickname] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[FullName], [o].[LeaderNickname] - FROM [Officers] AS [o] -) AS [u] -ORDER BY [u].[Nickname] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + INNER JOIN ( + SELECT [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [u].[FullName] = [w0].[OwnerFullName] + ) AS [w1] ON [w].[Id] = [w1].[Id] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Where_compare_anonymous_types(bool async) - { - await base.Where_compare_anonymous_types(async); - - AssertSql(); - } - - public override async Task Where_member_access_on_anonymous_type(bool async) + public override async Task Where_subquery_left_join_firstordefault_boolean(bool async) { - await base.Where_member_access_on_anonymous_type(async); + await base.Where_subquery_left_join_firstordefault_boolean(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[LeaderNickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[LeaderNickname] + 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 [u].[LeaderNickname] = N'Marcus' +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [u].[FullName] = [w0].[OwnerFullName] + ) AS [w1] ON [w].[Id] = [w1].[Id] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) + public override async Task Where_subquery_concat_firstordefault_boolean(bool async) { - await base.Where_compare_anonymous_types_with_uncorrelated_members(async); + await base.Where_subquery_concat_firstordefault_boolean(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname] + 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 0 = 1 +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [u0].[IsAutomatic] + FROM ( + SELECT [w].[Id], [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + UNION ALL + SELECT [w0].[Id], [w0].[IsAutomatic] + FROM [Weapons] AS [w0] + WHERE [u].[FullName] = [w0].[OwnerFullName] + ) AS [u0] + ORDER BY [u0].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool async) + public override async Task Concat_with_count(bool async) { - await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(async); + await base.Concat_with_count(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT 1 AS empty FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] + UNION ALL + SELECT 1 AS empty FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] + SELECT 1 AS empty FROM [Officers] AS [o0] -) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] -WHERE [u].[Nickname] = [u0].[Nickname] OR ([u].[Nickname] IS NULL AND [u0].[Nickname] IS NULL) +) AS [u1] """); } - public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) + public override async Task Concat_scalars_with_count(bool async) { - await base.Select_Singleton_Navigation_With_Member_Access(async); + await base.Concat_scalars_with_count(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty FROM [Gears] AS [g] 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] + SELECT 1 AS empty FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] = N'Marcus' AND ([u].[CityOfBirthName] <> N'Ephyra' OR [u].[CityOfBirthName] IS NULL) + UNION ALL + SELECT 1 AS empty + FROM [Gears] AS [g0] + UNION ALL + SELECT 1 AS empty + FROM [Officers] AS [o0] +) AS [u1] """); } - public override async Task Select_Where_Navigation(bool async) + public override async Task Concat_anonymous_with_count(bool async) { - await base.Select_Where_Navigation(async); + await base.Concat_anonymous_with_count(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty + FROM ( + SELECT 1 AS empty + FROM [Gears] AS [g] + UNION ALL + SELECT 1 AS empty + FROM [Officers] AS [o] + ) AS [u] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] = N'Marcus' + SELECT 1 AS empty + FROM ( + SELECT 1 AS empty + FROM [Gears] AS [g0] + UNION ALL + SELECT 1 AS empty + FROM [Officers] AS [o0] + ) AS [u0] +) AS [u1] """); } - public override async Task Select_Where_Navigation_Equals_Navigation(bool async) + public override async Task Concat_with_scalar_projection(bool async) { - await base.Select_Where_Navigation_Equals_Navigation(async); + await base.Concat_with_scalar_projection(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] -) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] -WHERE ([u].[Nickname] = [u0].[Nickname] OR ([u].[Nickname] IS NULL AND [u0].[Nickname] IS NULL)) AND ([u].[SquadId] = [u0].[SquadId] OR ([u].[SquadId] IS NULL AND [u0].[SquadId] IS NULL)) +SELECT [g].[Nickname] +FROM [Gears] AS [g] +UNION ALL +SELECT [o].[Nickname] +FROM [Officers] AS [o] +UNION ALL +SELECT [g0].[Nickname] +FROM [Gears] AS [g0] +UNION ALL +SELECT [o0].[Nickname] +FROM [Officers] AS [o0] """); } - public override async Task Select_Where_Navigation_Null(bool async) + public override async Task Select_navigation_with_concat_and_count(bool async) { - await base.Select_Where_Navigation_Null(async); + await base.Select_navigation_with_concat_and_count(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT ( + SELECT COUNT(*) + FROM ( + SELECT 1 AS empty + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + UNION ALL + SELECT 1 AS empty + FROM [Weapons] AS [w0] + WHERE [u].[FullName] = [w0].[OwnerFullName] + ) AS [u0]) +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] IS NULL OR [u].[SquadId] IS NULL +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Select_Where_Navigation_Null_Reverse(bool async) + public override async Task Concat_with_collection_navigations(bool async) { - await base.Select_Where_Navigation_Null_Reverse(async); + await base.Concat_with_collection_navigations(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT ( + SELECT COUNT(*) + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + UNION + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [u].[FullName] = [w0].[OwnerFullName] + ) AS [u0]) +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] IS NULL OR [u].[SquadId] IS NULL +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool async) + public override async Task Union_with_collection_navigations(bool async) { - await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(async); + await base.Union_with_collection_navigations(async); AssertSql( """ -SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] -) AS [u0] ON [t0].[GearNickName] = [u0].[Nickname] AND [t0].[GearSquadId] = [u0].[SquadId] -WHERE [u].[Nickname] = [u0].[Nickname] OR ([u].[Nickname] IS NULL AND [u0].[Nickname] IS NULL) -"""); - } - - public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool async) - { - await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(async); - - AssertSql( - """ -SELECT TOP(1) COALESCE([w0].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w].[Id] +SELECT ( + SELECT COUNT(*) + FROM ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] + UNION + SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o1] + ) AS [u1] + WHERE [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] + ) AS [u2]) +FROM ( + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task Where_subquery_boolean(bool async) + public override async Task Select_subquery_distinct_firstordefault(bool async) { - await base.Where_subquery_boolean(async); + await base.Select_subquery_distinct_firstordefault(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT ( + SELECT TOP(1) [w0].[Name] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -WHERE COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Where_subquery_boolean_with_pushdown(bool async) + public override async Task Singleton_Navigation_With_Member_Access(bool async) { - await base.Where_subquery_boolean_with_pushdown(async); + await base.Singleton_Navigation_With_Member_Access(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT [u].[CityOfBirthName] AS [B] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName] FROM [Officers] AS [o] -) AS [u] -WHERE ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[Nickname] = N'Marcus' AND ([u].[CityOfBirthName] <> N'Ephyra' OR [u].[CityOfBirthName] IS NULL) """); } - public override async Task Where_subquery_distinct_firstordefault_boolean(bool async) + public override async Task GroupJoin_Composite_Key(bool async) { - await base.Where_subquery_distinct_firstordefault_boolean(async); + await base.GroupJoin_Composite_Key(async); AssertSql( """ SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( +FROM [Tags] AS [t] +INNER JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) + public override async Task Join_navigation_translated_to_subquery_composite_key(bool async) { - await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); + await base.Join_navigation_translated_to_subquery_composite_key(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[FullName], [s].[Note] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) +INNER JOIN ( + SELECT [t].[Note], [u0].[FullName] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] ON [t].[GearNickName] = [u0].[Nickname] AND [t].[GearSquadId] = [u0].[SquadId] +) AS [s] ON [u].[FullName] = [s].[FullName] """); } - public override async Task Where_subquery_distinct_first_boolean(bool async) + public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) { - await base.Where_subquery_distinct_first_boolean(async); + await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[FullName], [s].[Note] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) -ORDER BY [u].[Nickname] +INNER JOIN ( + SELECT [t].[Note], [u0].[FullName] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] ON [t].[GearNickName] = [u0].[Nickname] AND [t].[GearSquadId] = [u0].[SquadId] +) AS [s] ON [u].[FullName] = [s].[FullName] """); } - public override async Task Where_subquery_distinct_singleordefault_boolean1(bool async) + public override async Task Join_with_order_by_without_skip_or_take(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean1(async); + await base.Join_with_order_by_without_skip_or_take(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [w].[Name], [u].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]), CAST(0 AS bit)) = CAST(1 AS bit) -ORDER BY [u].[Nickname] +INNER JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] """); } - public override async Task Where_subquery_distinct_singleordefault_boolean2(bool async) + public override async Task Join_with_order_by_without_skip_or_take_nested(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean2(async); + await base.Join_with_order_by_without_skip_or_take_nested(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT [w].[Name], [u].[FullName] +FROM [Squads] AS [s] +INNER JOIN ( + SELECT [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) = CAST(1 AS bit) -ORDER BY [u].[Nickname] +) AS [u] ON [s].[Id] = [u].[SquadId] +INNER JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] """); } - public override async Task Where_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) + public override async Task Collection_with_inheritance_and_join_include_joined(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean_with_pushdown(async); + await base.Collection_with_inheritance_and_join_include_joined(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - UNION ALL +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +INNER JOIN ( 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]) = CAST(1 AS bit) -ORDER BY [u].[Nickname] +) AS [u] ON [t].[GearSquadId] = [u].[SquadId] AND [t].[GearNickName] = [u].[Nickname] +LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] """); } - public override async Task Where_subquery_distinct_lastordefault_boolean(bool async) + public override async Task Collection_with_inheritance_and_join_include_source(bool async) { - await base.Where_subquery_distinct_lastordefault_boolean(async); + await base.Collection_with_inheritance_and_join_include_source(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id] DESC) = CAST(0 AS bit) -ORDER BY [u].[Nickname] +INNER JOIN [Tags] AS [t] ON [u].[SquadId] = [t].[GearSquadId] AND [u].[Nickname] = [t].[GearNickName] +LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] """); } - public override async Task Where_subquery_distinct_last_boolean(bool async) + public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_distinct_last_boolean(async); + await base.Non_unicode_string_literal_is_used_for_non_unicode_column(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[HasSoulPatch] = CAST(0 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id] DESC) = CAST(1 AS bit) -ORDER BY [u].[Nickname] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' """); } - public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column_right(bool async) { - await base.Where_subquery_distinct_orderby_firstordefault_boolean(async); + await base.Non_unicode_string_literal_is_used_for_non_unicode_column_right(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE 'Unknown' = [c].[Location] """); } - public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool async) + public override async Task Non_unicode_parameter_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(async); + await base.Non_unicode_parameter_is_used_for_non_unicode_column(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) +@value='Unknown' (Size = 100) (DbType = AnsiString) + +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = @value """); } - public override async Task Where_subquery_union_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_union_firstordefault_boolean(async); + await base.Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [u0].[IsAutomatic] +@cities='["Unknown","Jacinto\u0027s location","Ephyra\u0027s location"]' (Size = 4000) + +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] IN ( + SELECT [c0].[value] + FROM OPENJSON(@cities) WITH ([value] varchar(100) '$') AS [c0] +) +"""); + } + + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(bool async) + { + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(async); + + AssertSql( + """ +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' AND ( + SELECT COUNT(*) FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - UNION - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [u].[FullName] = [w0].[OwnerFullName] - ) AS [u0] - ORDER BY [u0].[Id]) = CAST(1 AS bit) + SELECT [g].[Nickname], [g].[CityOfBirthName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[CityOfBirthName] + FROM [Officers] AS [o] + ) AS [u] + WHERE [c].[Name] = [u].[CityOfBirthName] AND [u].[Nickname] = N'Paduk') = 1 """); } - public override async Task Where_subquery_join_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(bool async) { - await base.Where_subquery_join_firstordefault_boolean(async); + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(async); AssertSql( """ @@ -2407,26 +2379,43 @@ 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - INNER JOIN ( - SELECT [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [u].[FullName] = [w0].[OwnerFullName] - ) AS [w1] ON [w].[Id] = [w1].[Id] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] +WHERE [u].[Nickname] = N'Marcus' AND [c].[Location] = 'Jacinto''s location' """); } - public override async Task Where_subquery_left_join_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(bool async) { - await base.Where_subquery_left_join_firstordefault_boolean(async); + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] LIKE '%Jacinto%' +"""); + } + + public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) + { + await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); + + AssertSql( + """ +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE COALESCE([c].[Location], N'') + N'Added' LIKE N'%Add%' +"""); + } + + public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() + { + base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); + + // Issue#16897 + AssertSql( + """ +SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -2434,26 +2423,26 @@ 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [u].[FullName] = [w0].[OwnerFullName] - ) AS [w1] ON [w].[Id] = [w1].[Id] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId] """); } - public override async Task Where_subquery_concat_firstordefault_boolean(bool async) + public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() { - await base.Where_subquery_concat_firstordefault_boolean(async); + base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); + // Issue#16897 AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -2461,634 +2450,662 @@ 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 [u].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [u0].[IsAutomatic] - FROM ( - SELECT [w].[Id], [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - UNION ALL - SELECT [w0].[Id], [w0].[IsAutomatic] - FROM [Weapons] AS [w0] - WHERE [u].[FullName] = [w0].[OwnerFullName] - ) AS [u0] - ORDER BY [u0].[Id]) = CAST(1 AS bit) +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId] """); } - public override async Task Concat_with_count(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) { - await base.Concat_with_count(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(async); + // Issue#16897 AssertSql( """ -SELECT COUNT(*) +SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT 1 AS empty + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT 1 AS empty + 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] - UNION ALL - SELECT 1 AS empty +) AS [u] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g0] UNION ALL - SELECT 1 AS empty + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o0] -) AS [u1] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id] """); } - public override async Task Concat_scalars_with_count(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) { - await base.Concat_scalars_with_count(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async); + // Issue#16897 AssertSql( """ -SELECT COUNT(*) +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] FROM ( - SELECT 1 AS empty + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT 1 AS empty + 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] - UNION ALL - SELECT 1 AS empty +) AS [u] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g0] UNION ALL - SELECT 1 AS empty + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o0] -) AS [u1] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Weapons] AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] +LEFT JOIN [Weapons] AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id] """); } - public override async Task Concat_anonymous_with_count(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) { - await base.Concat_anonymous_with_count(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); + // Issue#16897 AssertSql( """ -SELECT COUNT(*) +SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT 1 AS empty - FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Officers] AS [o] - ) AS [u] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] UNION ALL - SELECT 1 AS empty - FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g0] - UNION ALL - SELECT 1 AS empty - FROM [Officers] AS [o0] - ) AS [u0] -) AS [u1] + 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] +LEFT JOIN ( + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id] """); } - public override async Task Concat_with_scalar_projection(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) { - await base.Concat_with_scalar_projection(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(async); + // Issue#16897 AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -UNION ALL -SELECT [o].[Nickname] -FROM [Officers] AS [o] -UNION ALL -SELECT [g0].[Nickname] -FROM [Gears] AS [g0] -UNION ALL -SELECT [o0].[Nickname] -FROM [Officers] AS [o0] +SELECT CASE + WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id] """); } - public override async Task Select_navigation_with_concat_and_count(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async) { - await base.Select_navigation_with_concat_and_count(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async); AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT 1 AS empty - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - UNION ALL - SELECT 1 AS empty - FROM [Weapons] AS [w0] - WHERE [u].[FullName] = [w0].[OwnerFullName] - ) AS [u0]) +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId], CASE + WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w3].[Id], [w3].[AmmunitionType], [w3].[IsAutomatic], [w3].[Name], [w3].[OwnerFullName], [w3].[SynergyWithId], [w4].[Id], [w4].[AmmunitionType], [w4].[IsAutomatic], [w4].[Name], [w4].[OwnerFullName], [w4].[SynergyWithId] FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] + 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 [u].[HasSoulPatch] = CAST(0 AS bit) +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Weapons] AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] +LEFT JOIN [Weapons] AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] +LEFT JOIN [Weapons] AS [w3] ON [u0].[FullName] = [w3].[OwnerFullName] +LEFT JOIN [Weapons] AS [w4] ON [u].[FullName] = [w4].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id], [w2].[Id], [w3].[Id] """); } - public override async Task Concat_with_collection_navigations(bool async) + public override async Task Coalesce_operator_in_predicate(bool async) { - await base.Concat_with_collection_navigations(async); + await base.Coalesce_operator_in_predicate(async); AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - UNION - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [u].[FullName] = [w0].[OwnerFullName] - ) AS [u0]) -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Union_with_collection_navigations(bool async) + public override async Task Coalesce_operator_in_predicate_with_other_conditions(bool async) { - await base.Union_with_collection_navigations(async); + await base.Coalesce_operator_in_predicate_with_other_conditions(async); AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] - UNION - SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o1] - ) AS [u1] - WHERE [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] - ) AS [u2]) -FROM ( - SELECT [o].[Nickname], [o].[SquadId] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Select_subquery_distinct_firstordefault(bool async) + public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) { - await base.Select_subquery_distinct_firstordefault(async); + await base.Coalesce_operator_in_projection_with_other_conditions(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[Name] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] +SELECT CASE + WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Singleton_Navigation_With_Member_Access(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate(bool async) { - await base.Singleton_Navigation_With_Member_Access(async); + await base.Optional_navigation_type_compensation_works_with_predicate(async); AssertSql( """ -SELECT [u].[CityOfBirthName] AS [B] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] = N'Marcus' AND ([u].[CityOfBirthName] <> N'Ephyra' OR [u].[CityOfBirthName] IS NULL) +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task GroupJoin_Composite_Key(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate2(bool async) { - await base.GroupJoin_Composite_Key(async); + await base.Optional_navigation_type_compensation_works_with_predicate2(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] -INNER JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Join_navigation_translated_to_subquery_composite_key(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated(bool async) { - await base.Join_navigation_translated_to_subquery_composite_key(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated(async); AssertSql( """ -SELECT [u].[FullName], [s].[Note] -FROM ( - SELECT [g].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] -INNER JOIN ( - SELECT [t].[Note], [u0].[FullName] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] ON [t].[GearNickName] = [u0].[Nickname] AND [t].[GearSquadId] = [u0].[SquadId] -) AS [s] ON [u].[FullName] = [s].[FullName] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool async) { - await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(async); AssertSql( """ -SELECT [u].[FullName], [s].[Note] -FROM ( - SELECT [g].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] -INNER JOIN ( - SELECT [t].[Note], [u0].[FullName] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] ON [t].[GearNickName] = [u0].[Nickname] AND [t].[GearSquadId] = [u0].[SquadId] -) AS [s] ON [u].[FullName] = [s].[FullName] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [u].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE [u].[HasSoulPatch] +END = CAST(0 AS bit) """); } - public override async Task Join_with_order_by_without_skip_or_take(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool async) { - await base.Join_with_order_by_without_skip_or_take(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(async); AssertSql( """ -SELECT [w].[Name], [u].[FullName] -FROM ( - SELECT [g].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] -INNER JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [u].[HasSoulPatch] = CAST(0 AS bit) THEN CAST(0 AS bit) + ELSE [u].[HasSoulPatch] +END = CAST(0 AS bit) """); } - public override async Task Join_with_order_by_without_skip_or_take_nested(bool async) + public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool async) { - await base.Join_with_order_by_without_skip_or_take_nested(async); + await base.Optional_navigation_type_compensation_works_with_conditional_expression(async); AssertSql( """ -SELECT [w].[Name], [u].[FullName] -FROM [Squads] AS [s] -INNER JOIN ( - SELECT [g].[SquadId], [g].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[SquadId], [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [s].[Id] = [u].[SquadId] -INNER JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [u].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Collection_with_inheritance_and_join_include_joined(bool async) + public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) { - await base.Collection_with_inheritance_and_join_include_joined(async); + await base.Optional_navigation_type_compensation_works_with_binary_expression(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] -INNER JOIN ( - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearSquadId] = [u].[SquadId] AND [t].[GearNickName] = [u].[Nickname] -LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) OR [t].[Note] LIKE N'%Cole%' """); } - public override async Task Collection_with_inheritance_and_join_include_source(bool async) + public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) { - await base.Collection_with_inheritance_and_join_include_source(async); + await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] +SELECT CASE + WHEN [u].[HasSoulPatch] = CAST(1 AS bit) AND [t].[Note] LIKE N'%Cole%' AND [t].[Note] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] -INNER JOIN [Tags] AS [t] ON [u].[SquadId] = [t].[GearSquadId] AND [u].[Nickname] = [t].[GearNickName] -LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_projection(bool async) { - await base.Non_unicode_string_literal_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_projection(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' +SELECT [u].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column_right(bool async) + public override async Task Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(bool async) { - await base.Non_unicode_string_literal_is_used_for_non_unicode_column_right(async); + await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE 'Unknown' = [c].[Location] +SELECT [u].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Non_unicode_parameter_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) { - await base.Non_unicode_parameter_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_DTOs(async); AssertSql( """ -@value='Unknown' (Size = 100) (DbType = AnsiString) - -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = @value +SELECT [u].[SquadId] AS [Id] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_list_initializers(bool async) { - await base.Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_list_initializers(async); AssertSql( """ -@cities='["Unknown","Jacinto\u0027s location","Ephyra\u0027s location"]' (Size = 4000) - -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] IN ( - SELECT [c0].[value] - FROM OPENJSON(@cities) WITH ([value] varchar(100) '$') AS [c0] -) +SELECT [u].[SquadId], [u].[SquadId] + 1 +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +ORDER BY [t].[Note] """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(bool async) + public override async Task Optional_navigation_type_compensation_works_with_array_initializers(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(async); + await base.Optional_navigation_type_compensation_works_with_array_initializers(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' AND ( - SELECT COUNT(*) - FROM ( - SELECT [g].[Nickname], [g].[CityOfBirthName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[CityOfBirthName] - FROM [Officers] AS [o] - ) AS [u] - WHERE [c].[Name] = [u].[CityOfBirthName] AND [u].[Nickname] = N'Paduk') = 1 +SELECT [u].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(bool async) + public override async Task Optional_navigation_type_compensation_works_with_orderby(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(async); + await base.Optional_navigation_type_compensation_works_with_orderby(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] -INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -WHERE [u].[Nickname] = N'Marcus' AND [c].[Location] = 'Jacinto''s location' +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +ORDER BY [u].[SquadId] """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(bool async) + public override async Task Optional_navigation_type_compensation_works_with_all(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(async); + await base.Optional_navigation_type_compensation_works_with_all(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] LIKE '%Jacinto%' +SELECT CASE + WHEN NOT EXISTS ( + SELECT 1 + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] + WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) + public override async Task Optional_navigation_type_compensation_works_with_negated_predicate(bool async) { - await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); + await base.Optional_navigation_type_compensation_works_with_negated_predicate(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE COALESCE([c].[Location], N'') + N'Added' LIKE N'%Add%' +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(0 AS bit) """); } - public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() + public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) { - base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); + await base.Optional_navigation_type_compensation_works_with_contains(async); - // Issue#16897 AssertSql( """ -SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[SquadId] IN ( + SELECT [g0].[SquadId] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[SquadId] FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId] +) """); } - public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() + public override async Task Optional_navigation_type_compensation_works_with_skip(bool async) { - base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); + await base.Optional_navigation_type_compensation_works_with_skip(async); + + AssertSql(); + } + + public override async Task Optional_navigation_type_compensation_works_with_take(bool async) + { + await base.Optional_navigation_type_compensation_works_with_take(async); + + AssertSql(); + } + + public override async Task Select_correlated_filtered_collection(bool async) + { + await base.Select_correlated_filtered_collection(async); - // Issue#16897 AssertSql( """ -SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [c].[Name], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName], [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName], [o].[FullName] FROM [Officers] AS [o] ) AS [u] +INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [c].[Name] IN (N'Ephyra', N'Hanover') +ORDER BY [u].[Nickname], [u].[SquadId], [c].[Name] """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) + public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(async); + await base.Select_correlated_filtered_collection_with_composite_key(async); - // Issue#16897 AssertSql( """ -SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[Nickname], [u].[SquadId], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id] + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u0].[Nickname] <> N'Dom' +) AS [u1] ON [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) + public override async Task Select_correlated_filtered_collection_works_with_caching(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async); + await base.Select_correlated_filtered_collection_works_with_caching(async); - // Issue#16897 AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] -FROM ( +SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM [Tags] AS [t] +LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] -LEFT JOIN [Weapons] AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] -LEFT JOIN [Weapons] AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] +ORDER BY [t].[Note], [t].[Id], [u].[Nickname] """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) + public override async Task Join_predicate_value_equals_condition(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); + await base.Join_predicate_value_equals_condition(async); - // Issue#16897 AssertSql( """ -SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -3096,27 +3113,17 @@ 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] -LEFT JOIN ( - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id] +INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) + public override async Task Join_predicate_value(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(async); + await base.Join_predicate_value(async); - // Issue#16897 AssertSql( """ -SELECT CASE - WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -3124,29 +3131,17 @@ 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id] +INNER JOIN [Weapons] AS [w] ON [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async) + public override async Task Join_predicate_condition_equals_condition(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async); + await base.Join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId], CASE - WHEN [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w3].[Id], [w3].[AmmunitionType], [w3].[IsAutomatic], [w3].[Name], [w3].[OwnerFullName], [w3].[SynergyWithId], [w4].[Id], [w4].[AmmunitionType], [w4].[IsAutomatic], [w4].[Name], [w4].[OwnerFullName], [w4].[SynergyWithId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -3154,555 +3149,418 @@ 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] -LEFT JOIN [Weapons] AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] -LEFT JOIN [Weapons] AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] -LEFT JOIN [Weapons] AS [w3] ON [u0].[FullName] = [w3].[OwnerFullName] -LEFT JOIN [Weapons] AS [w4] ON [u].[FullName] = [w4].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [w].[Id], [w0].[Id], [w1].[Id], [w2].[Id], [w3].[Id] +INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Coalesce_operator_in_predicate(bool async) + public override async Task Left_join_predicate_value_equals_condition(bool async) { - await base.Coalesce_operator_in_predicate(async); + await base.Left_join_predicate_value_equals_condition(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Coalesce_operator_in_predicate_with_other_conditions(bool async) + public override async Task Left_join_predicate_value(bool async) { - await base.Coalesce_operator_in_predicate_with_other_conditions(async); + await base.Left_join_predicate_value(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) + public override async Task Left_join_predicate_condition_equals_condition(bool async) { - await base.Coalesce_operator_in_projection_with_other_conditions(async); + await base.Left_join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT CASE - WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([u].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate(bool async) + public override async Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( + bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate(async); + await base.Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(async); - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(1 AS bit) -"""); + AssertSql(); } - public override async Task Optional_navigation_type_compensation_works_with_predicate2(bool async) + public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_property(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate2(async); + await base.Complex_predicate_with_AndAlso_and_nullable_bool_property(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +) AS [u] ON [w].[OwnerFullName] = [u].[FullName] +WHERE [w].[Id] <> 50 AND [u].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated(bool async) + public override async Task Distinct_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated(async); + await base.Distinct_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( +SELECT DISTINCT [u].[HasSoulPatch] +FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[HasSoulPatch] = CAST(0 AS bit) +) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool async) + public override async Task Sum_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(async); + await base.Sum_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +SELECT COALESCE(SUM([u].[SquadId]), 0) +FROM ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [u].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE [u].[HasSoulPatch] -END = CAST(0 AS bit) +) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool async) + public override async Task Count_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(async); + await base.Count_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +SELECT COUNT(*) +FROM ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [u].[HasSoulPatch] = CAST(0 AS bit) THEN CAST(0 AS bit) - ELSE [u].[HasSoulPatch] -END = CAST(0 AS bit) +) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool async) + public override async Task FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_conditional_expression(async); + await base.FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] +SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + SELECT [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[SquadId] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [u].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +) AS [u] ON [s].[Id] = [u].[SquadId] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) + public override async Task Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_binary_expression(async); + await base.Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) OR [t].[Note] LIKE N'%Cole%' +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE NOT EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] + ) AS [u] + LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] + WHERE [s].[Id] = [u].[SquadId] AND [t].[Note] = N'Dom''s Tag') """); } - public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) + public override async Task All_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); + await base.All_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ SELECT CASE - WHEN [u].[HasSoulPatch] = CAST(1 AS bit) AND [t].[Note] LIKE N'%Cole%' AND [t].[Note] IS NOT NULL THEN CAST(1 AS bit) + WHEN NOT EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] + ) AS [u] + LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] + WHERE [t].[Note] = N'Foo') THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Optional_navigation_type_compensation_works_with_projection(bool async) + public override async Task Contains_with_local_nullable_guid_list_closure(bool async) { - await base.Optional_navigation_type_compensation_works_with_projection(async); + await base.Contains_with_local_nullable_guid_list_closure(async); AssertSql( """ -SELECT [u].[SquadId] +@ids='["df36f493-463f-4123-83f9-6b135deeb7ba","23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3","ab1b82d7-88db-42bd-a132-7eef9aa68af4"]' (Size = 4000) + +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +WHERE [t].[Id] IN ( + SELECT [i].[value] + FROM OPENJSON(@ids) WITH ([value] uniqueidentifier '$') AS [i] +) """); } - public override async Task Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(bool async) + public override async Task Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(bool async) { - await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(async); + await base.Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(async); AssertSql( """ -SELECT [u].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[FullName] +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [u].[Rank] """); } - public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) + public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(bool async) { - await base.Optional_navigation_type_compensation_works_with_DTOs(async); + await base.Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(async); AssertSql( """ -SELECT [u].[SquadId] AS [Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[FullName] +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [u].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_list_initializers(bool async) + public override async Task Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(bool async) { - await base.Optional_navigation_type_compensation_works_with_list_initializers(async); + await base.Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(async); AssertSql( """ -SELECT [u].[SquadId], [u].[SquadId] + 1 -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[FullName] +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -ORDER BY [t].[Note] +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [u].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_array_initializers(bool async) + public override async Task Where_is_properly_lifted_from_subquery_created_by_include(bool async) { - await base.Optional_navigation_type_compensation_works_with_array_initializers(async); + await base.Where_is_properly_lifted_from_subquery_created_by_include(async); AssertSql( """ -SELECT [u].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +WHERE [u].[FullName] <> N'Augustus Cole' AND [u].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [u].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_orderby(bool async) + public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMany(bool async) { - await base.Optional_navigation_type_compensation_works_with_orderby(async); + await base.Subquery_is_lifted_from_main_from_clause_of_SelectMany(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -ORDER BY [u].[SquadId] -"""); - } - - public override async Task Optional_navigation_type_compensation_works_with_all(bool async) - { - await base.Optional_navigation_type_compensation_works_with_all(async); - - AssertSql( - """ -SELECT CASE - WHEN NOT EXISTS ( - SELECT 1 - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] - WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -"""); - } - - public override async Task Optional_navigation_type_compensation_works_with_negated_predicate(bool async) - { - await base.Optional_navigation_type_compensation_works_with_negated_predicate(async); - - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[HasSoulPatch] = CAST(0 AS bit) -"""); - } - - public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) - { - await base.Optional_navigation_type_compensation_works_with_contains(async); - - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[FullName] AS [Name1], [u0].[FullName] AS [Name2] +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [u].[SquadId] IN ( - SELECT [g0].[SquadId] +) AS [u] +CROSS JOIN ( + SELECT [g0].[FullName], [g0].[HasSoulPatch] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[SquadId] + SELECT [o0].[FullName], [o0].[HasSoulPatch] FROM [Officers] AS [o0] -) +) AS [u0] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND [u0].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [u].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_skip(bool async) - { - await base.Optional_navigation_type_compensation_works_with_skip(async); - - AssertSql(); - } - - public override async Task Optional_navigation_type_compensation_works_with_take(bool async) - { - await base.Optional_navigation_type_compensation_works_with_take(async); - - AssertSql(); - } - - public override async Task Select_correlated_filtered_collection(bool async) + public override async Task Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(bool async) { - await base.Select_correlated_filtered_collection(async); + await base.Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [c].[Name], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName], [g].[FullName] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName], [o].[FullName] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [c].[Name] IN (N'Ephyra', N'Hanover') -ORDER BY [u].[Nickname], [u].[SquadId], [c].[Name] +CROSS JOIN [Tags] AS [t] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [u].[FullName] """); } - public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) + public override async Task Subquery_containing_join_projecting_main_from_clause_gets_lifted(bool async) { - await base.Select_correlated_filtered_collection_with_composite_key(async); + await base.Subquery_containing_join_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] +SELECT [u].[Nickname] FROM ( - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u0].[Nickname] <> N'Dom' -) AS [u1] ON [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] -"""); - } - - public override async Task Select_correlated_filtered_collection_works_with_caching(bool async) - { - await base.Select_correlated_filtered_collection_works_with_caching(async); - - AssertSql( - """ -SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] -ORDER BY [t].[Note], [t].[Id], [u].[Nickname] +) AS [u] +INNER JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] +ORDER BY [u].[Nickname] """); } - public override async Task Join_predicate_value_equals_condition(bool async) + public override async Task Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(bool async) { - await base.Join_predicate_value_equals_condition(async); + await base.Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname] FROM [Officers] AS [o] ) AS [u] -INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] +ORDER BY [u].[Nickname] """); } - public override async Task Join_predicate_value(bool async) + public override async Task Subquery_containing_join_gets_lifted_clashing_names(bool async) { - await base.Join_predicate_value(async); + await base.Subquery_containing_join_gets_lifted_clashing_names(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname] FROM [Officers] AS [o] ) AS [u] -INNER JOIN [Weapons] AS [w] ON [u].[HasSoulPatch] = CAST(1 AS bit) +INNER JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] +INNER JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] +WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL +ORDER BY [u].[Nickname], [t0].[Id] """); } - public override async Task Join_predicate_condition_equals_condition(bool async) + public override async Task Subquery_created_by_include_gets_lifted_nested(bool async) { - await base.Join_predicate_condition_equals_condition(async); + await base.Subquery_created_by_include_gets_lifted_nested(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [c].[Name], [c].[Location], [c].[Nation] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -3710,348 +3568,430 @@ 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] -INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] +WHERE EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]) AND [u].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [u].[Nickname] """); } - public override async Task Left_join_predicate_value_equals_condition(bool async) + public override async Task Subquery_is_lifted_from_additional_from_clause(bool async) { - await base.Left_join_predicate_value_equals_condition(async); + await base.Subquery_is_lifted_from_additional_from_clause(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[FullName] AS [Name1], [u0].[FullName] AS [Name2] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +CROSS JOIN ( + SELECT [g0].[FullName], [g0].[HasSoulPatch] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[FullName], [o0].[HasSoulPatch] + FROM [Officers] AS [o0] +) AS [u0] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND [u0].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [u].[FullName] """); } - public override async Task Left_join_predicate_value(bool async) + public override async Task Subquery_with_result_operator_is_not_lifted(bool async) { - await base.Left_join_predicate_value(async); + await base.Subquery_with_result_operator_is_not_lifted(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +@p='2' + +SELECT [u0].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -LEFT JOIN [Weapons] AS [w] ON [u].[HasSoulPatch] = CAST(1 AS bit) + SELECT TOP(@p) [u].[FullName], [u].[Rank] + FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(0 AS bit) + ORDER BY [u].[FullName] +) AS [u0] +ORDER BY [u0].[Rank] """); } - public override async Task Left_join_predicate_condition_equals_condition(bool async) + public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down(bool async) { - await base.Left_join_predicate_condition_equals_condition(async); + await base.Skip_with_orderby_followed_by_orderBy_is_pushed_down(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +@p='1' + +SELECT [u0].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL + SELECT [u].[FullName], [u].[Rank] + FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(0 AS bit) + ORDER BY [u].[FullName] + OFFSET @p ROWS +) AS [u0] +ORDER BY [u0].[Rank] """); } - public override async Task Where_datetimeoffset_now(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) { - await base.Where_datetimeoffset_now(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] <> SYSDATETIMEOFFSET() -"""); - } - - public override async Task Where_datetimeoffset_utcnow(bool async) - { - await base.Where_datetimeoffset_utcnow(async); +@p='999' - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) +SELECT [u0].[FullName] +FROM ( + SELECT TOP(@p) [u].[FullName], [u].[Rank] + FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(0 AS bit) +) AS [u0] +ORDER BY [u0].[Rank] """); } - public override async Task Where_datetimeoffset_date_component(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) { - await base.Where_datetimeoffset_date_component(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); AssertSql( """ -@Date='0001-01-01T00:00:00.0000000' +@p='999' -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONVERT(date, [m].[Timeline]) > @Date +SELECT [u0].[FullName] +FROM ( + SELECT TOP(@p) [u].[FullName], [u].[Rank] + FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(0 AS bit) +) AS [u0] +ORDER BY [u0].[Rank] """); } - public override async Task Where_datetimeoffset_year_component(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) { - await base.Where_datetimeoffset_year_component(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(year, [m].[Timeline]) = 2 +@p='999' + +SELECT [u0].[FullName] +FROM ( + SELECT TOP(@p) [u].[FullName], [u].[Rank] + FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(0 AS bit) +) AS [u0] +ORDER BY [u0].[FullName], [u0].[Rank] """); } - public override async Task Where_datetimeoffset_month_component(bool async) + public override async Task Select_length_of_string_property(bool async) { - await base.Where_datetimeoffset_month_component(async); + await base.Select_length_of_string_property(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(month, [m].[Timeline]) = 1 +SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] +FROM [Weapons] AS [w] """); } - public override async Task Where_datetimeoffset_dayofyear_component(bool async) + public override async Task Client_method_on_collection_navigation_in_outer_join_key(bool async) { - await base.Where_datetimeoffset_dayofyear_component(async); + await base.Client_method_on_collection_navigation_in_outer_join_key(async); - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(dayofyear, [m].[Timeline]) = 2 -"""); + AssertSql(); } - public override async Task Where_datetimeoffset_day_component(bool async) + public override async Task Member_access_on_derived_entity_using_cast(bool async) { - await base.Where_datetimeoffset_day_component(async); + await base.Member_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(day, [m].[Timeline]) = 2 +SELECT [l].[Name], [l].[Eradicated] +FROM [LocustHordes] AS [l] +ORDER BY [l].[Name] """); } - public override async Task Where_datetimeoffset_hour_component(bool async) + public override async Task Member_access_on_derived_materialized_entity_using_cast(bool async) { - await base.Where_datetimeoffset_hour_component(async); + await base.Member_access_on_derived_materialized_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Timeline]) = 10 +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] +FROM [LocustHordes] AS [l] +ORDER BY [l].[Name] """); } - public override async Task Where_datetimeoffset_minute_component(bool async) + public override async Task Member_access_on_derived_entity_using_cast_and_let(bool async) { - await base.Where_datetimeoffset_minute_component(async); + await base.Member_access_on_derived_entity_using_cast_and_let(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Timeline]) = 0 +SELECT [l].[Name], [l].[Eradicated] +FROM [LocustHordes] AS [l] +ORDER BY [l].[Name] """); } - public override async Task Where_datetimeoffset_second_component(bool async) + public override async Task Property_access_on_derived_entity_using_cast(bool async) { - await base.Where_datetimeoffset_second_component(async); + await base.Property_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Timeline]) = 0 +SELECT [l].[Name], [l].[Eradicated] +FROM [LocustHordes] AS [l] +ORDER BY [l].[Name] """); } - public override async Task Where_datetimeoffset_millisecond_component(bool async) + public override async Task Navigation_access_on_derived_entity_using_cast(bool async) { - await base.Where_datetimeoffset_millisecond_component(async); + await base.Navigation_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Timeline]) = 0 +SELECT [l].[Name], [l0].[ThreatLevel] AS [Threat] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +ORDER BY [l].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddMonths(bool async) + public override async Task Navigation_access_on_derived_materialized_entity_using_cast(bool async) { - await base.DateTimeOffset_DateAdd_AddMonths(async); + await base.Navigation_access_on_derived_materialized_entity_using_cast(async); AssertSql( """ -SELECT DATEADD(month, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[ThreatLevel] AS [Threat] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +ORDER BY [l].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddDays(bool async) + public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) { - await base.DateTimeOffset_DateAdd_AddDays(async); + await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); AssertSql( """ -SELECT DATEADD(day, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [l].[Name], [l0].[ThreatLevel] AS [Threat] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +ORDER BY [l].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddHours(bool async) + public override async Task Navigation_access_fk_on_derived_entity_using_cast(bool async) { - await base.DateTimeOffset_DateAdd_AddHours(async); + await base.Navigation_access_fk_on_derived_entity_using_cast(async); AssertSql( """ -SELECT DATEADD(hour, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [l].[Name], [l0].[Name] AS [CommanderName] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +ORDER BY [l].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddMinutes(bool async) + public override async Task Collection_navigation_access_on_derived_entity_using_cast(bool async) { - await base.DateTimeOffset_DateAdd_AddMinutes(async); + await base.Collection_navigation_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT DATEADD(minute, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [l].[Name], ( + SELECT COUNT(*) + FROM ( + SELECT [l0].[LocustHordeId] + FROM [LocustLeaders] AS [l0] + UNION ALL + SELECT [l1].[LocustHordeId] + FROM [LocustCommanders] AS [l1] + ) AS [u] + WHERE [l].[Id] = [u].[LocustHordeId]) AS [LeadersCount] +FROM [LocustHordes] AS [l] +ORDER BY [l].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddSeconds(bool async) + public override async Task Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(bool async) { - await base.DateTimeOffset_DateAdd_AddSeconds(async); + await base.Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(async); AssertSql( """ -SELECT DATEADD(second, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [l].[Name], [u].[Name] AS [LeaderName] +FROM [LocustHordes] AS [l] +INNER JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId] + FROM [LocustLeaders] AS [l0] + UNION ALL + SELECT [l1].[Name], [l1].[LocustHordeId] + FROM [LocustCommanders] AS [l1] +) AS [u] ON [l].[Id] = [u].[LocustHordeId] +ORDER BY [u].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) + public override async Task Include_on_derived_entity_using_OfType(bool async) { - await base.DateTimeOffset_DateAdd_AddMilliseconds(async); + await base.Include_on_derived_entity_using_OfType(async); AssertSql( """ -SELECT DATEADD(millisecond, CAST(300.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +LEFT JOIN ( + SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l2] +) AS [u] ON [l].[Id] = [u].[LocustHordeId] +ORDER BY [l].[Name], [l].[Id], [l0].[Name] """); } - public override async Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) + public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) { - await base.Where_datetimeoffset_milliseconds_parameter_and_constant(async); + await base.Distinct_on_subquery_doesnt_get_lifted(async); AssertSql( """ -SELECT COUNT(*) -FROM [Missions] AS [m] -WHERE [m].[Timeline] = '1902-01-02T10:00:00.1234567+01:30' +SELECT [u0].[HasSoulPatch] +FROM ( + SELECT DISTINCT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +) AS [u0] """); } - public override async Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( - bool async) - { - await base.Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(async); - - AssertSql(); - } - - public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_property(bool async) + public override async Task Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(bool async) { - await base.Complex_predicate_with_AndAlso_and_nullable_bool_property(async); + await base.Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [w].[OwnerFullName] = [u].[FullName] -WHERE [w].[Id] <> 50 AND [u].[HasSoulPatch] = CAST(0 AS bit) +SELECT [l].[Eradicated] +FROM [LocustHordes] AS [l] """); } - public override async Task Distinct_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Comparing_two_collection_navigations_composite_key(bool async) { - await base.Distinct_with_optional_navigation_is_translated_to_sql(async); + await base.Comparing_two_collection_navigations_composite_key(async); AssertSql( """ -SELECT DISTINCT [u].[HasSoulPatch] +SELECT [u].[Nickname] AS [Nickname1], [u0].[Nickname] AS [Nickname2] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] +WHERE [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] +ORDER BY [u].[Nickname] """); } - public override async Task Sum_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Comparing_two_collection_navigations_inheritance(bool async) { - await base.Sum_with_optional_navigation_is_translated_to_sql(async); + await base.Comparing_two_collection_navigations_inheritance(async); AssertSql( """ -SELECT COALESCE(SUM([u].[SquadId]), 0) -FROM ( +SELECT [l].[Name], [u].[Nickname] +FROM [LocustHordes] AS [l] +CROSS JOIN ( + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] ON [l0].[DefeatedByNickname] = [u0].[Nickname] AND [l0].[DefeatedBySquadId] = [u0].[SquadId] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND [u0].[Nickname] = [u].[Nickname] AND [u0].[SquadId] = [u].[SquadId] """); } - public override async Task Count_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Comparing_entities_using_Equals_inheritance(bool async) { - await base.Count_with_optional_navigation_is_translated_to_sql(async); + await base.Comparing_entities_using_Equals_inheritance(async); AssertSql( """ -SELECT COUNT(*) +SELECT [u].[Nickname] AS [Nickname1], [u0].[Nickname] AS [Nickname2] FROM ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] @@ -4059,281 +3999,332 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +CROSS JOIN ( + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] +) AS [u0] +WHERE [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] +ORDER BY [u].[Nickname], [u0].[Nickname] """); } - public override async Task FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(bool async) + public override async Task Contains_on_nullable_array_produces_correct_sql(bool async) { - await base.FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(async); + await base.Contains_on_nullable_array_produces_correct_sql(async); AssertSql( """ -SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g].[SquadId] +@cities_without_nulls='["Ephyra"]' (Size = 4000) + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[SquadId] + 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] ON [s].[Id] = [u].[SquadId] -WHERE [s].[Name] = N'Kilo' +) AS [u] +LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] +WHERE [u].[SquadId] < 2 AND ([c].[Name] IN ( + SELECT [c0].[value] + FROM OPENJSON(@cities_without_nulls) AS [c0] +) OR [c].[Name] IS NULL) """); } - public override async Task Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(bool async) + public override async Task Optional_navigation_with_collection_composite_key(bool async) { - await base.Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(async); + await base.Optional_navigation_with_collection_composite_key(async); AssertSql( """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE NOT EXISTS ( - SELECT 1 +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], N'Officer' AS [Discriminator] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE [u].[Discriminator] = N'Officer' AND ( + SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] + SELECT [g0].[Nickname], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] - ) AS [u] - LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] - WHERE [s].[Id] = [u].[SquadId] AND [t].[Note] = N'Dom''s Tag') + SELECT [o0].[Nickname], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] IS NOT NULL AND [u].[SquadId] IS NOT NULL AND [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] AND [u0].[Nickname] = N'Dom') > 0 """); } - public override async Task All_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Select_null_conditional_with_inheritance(bool async) { - await base.All_with_optional_navigation_is_translated_to_sql(async); + await base.Select_null_conditional_with_inheritance(async); AssertSql( """ SELECT CASE - WHEN NOT EXISTS ( - SELECT 1 - FROM ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] - ) AS [u] - LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] - WHERE [t].[Note] = N'Foo') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [l].[CommanderName] IS NOT NULL THEN [l].[CommanderName] END +FROM [LocustHordes] AS [l] """); } - public override async Task Contains_with_local_nullable_guid_list_closure(bool async) + public override async Task Select_null_conditional_with_inheritance_negative(bool async) { - await base.Contains_with_local_nullable_guid_list_closure(async); + await base.Select_null_conditional_with_inheritance_negative(async); AssertSql( """ -@ids='["df36f493-463f-4123-83f9-6b135deeb7ba","23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3","ab1b82d7-88db-42bd-a132-7eef9aa68af4"]' (Size = 4000) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] IN ( - SELECT [i].[value] - FROM OPENJSON(@ids) WITH ([value] uniqueidentifier '$') AS [i] -) +SELECT CASE + WHEN [l].[CommanderName] IS NOT NULL THEN [l].[Eradicated] +END +FROM [LocustHordes] AS [l] """); } - public override async Task Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(bool async) + public override async Task Project_collection_navigation_with_inheritance1(bool async) { - await base.Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(async); + await base.Project_collection_navigation_with_inheritance1(async); AssertSql( """ -SELECT [u].[FullName] -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] - FROM [Gears] AS [g] +SELECT [l].[Id], [l0].[Name], [l1].[Id], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +LEFT JOIN [LocustHordes] AS [l1] ON [l0].[Name] = [l1].[CommanderName] +LEFT JOIN ( + SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l2] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [u].[Rank] + SELECT [l3].[Name], [l3].[LocustHordeId], [l3].[ThreatLevel], [l3].[ThreatLevelByte], [l3].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l3] +) AS [u] ON [l1].[Id] = [u].[LocustHordeId] +ORDER BY [l].[Id], [l0].[Name], [l1].[Id] """); } - public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(bool async) + public override async Task Project_collection_navigation_with_inheritance2(bool async) { - await base.Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(async); + await base.Project_collection_navigation_with_inheritance2(async); AssertSql( """ -SELECT [u].[FullName] -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] +SELECT [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [u].[FullName] +) AS [u] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(bool async) + public override async Task Project_collection_navigation_with_inheritance3(bool async) { - await base.Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(async); + await base.Project_collection_navigation_with_inheritance3(async); AssertSql( """ -SELECT [u].[FullName] -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] +SELECT [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [u].[FullName] +) AS [u] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Where_is_properly_lifted_from_subquery_created_by_include(bool async) + public override async Task Include_reference_on_derived_type_using_string(bool async) { - await base.Where_is_properly_lifted_from_subquery_created_by_include(async); + await base.Include_reference_on_derived_type_using_string(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] 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] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE [u].[FullName] <> N'Augustus Cole' AND [u].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [u].[FullName] +) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] """); } - public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMany(bool async) + public override async Task Include_reference_on_derived_type_using_string_nested1(bool async) { - await base.Subquery_is_lifted_from_main_from_clause_of_SelectMany(async); + await base.Include_reference_on_derived_type_using_string_nested1(async); AssertSql( """ -SELECT [u].[FullName] AS [Name1], [u0].[FullName] AS [Name2] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -CROSS JOIN ( - SELECT [g0].[FullName], [g0].[HasSoulPatch] - FROM [Gears] AS [g0] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] UNION ALL - SELECT [o0].[FullName], [o0].[HasSoulPatch] - FROM [Officers] AS [o0] -) AS [u0] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND [u0].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [u].[FullName] + 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +LEFT JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] """); } - public override async Task Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Include_reference_on_derived_type_using_string_nested2(bool async) { - await base.Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(async); + await base.Include_reference_on_derived_type_using_string_nested2(async); AssertSql( """ -SELECT [u].[FullName] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Name], [s].[Location], [s].[Nation] FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -CROSS JOIN [Tags] AS [t] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [u].[FullName] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +LEFT JOIN ( + SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator], [c].[Name], [c].[Location], [c].[Nation] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u1] + INNER JOIN [Cities] AS [c] ON [u1].[CityOfBirthName] = [c].[Name] +) AS [s] ON ([u0].[Nickname] = [s].[LeaderNickname] OR ([u0].[Nickname] IS NULL AND [s].[LeaderNickname] IS NULL)) AND [u0].[SquadId] = [s].[LeaderSquadId] +ORDER BY [u].[Name], [u0].[Nickname], [u0].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Subquery_containing_join_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Include_reference_on_derived_type_using_lambda(bool async) { - await base.Subquery_containing_join_projecting_main_from_clause_gets_lifted(async); + await base.Include_reference_on_derived_type_using_lambda(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [g].[Nickname] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname] + 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] -INNER JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] -ORDER BY [u].[Nickname] +) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] """); } - public override async Task Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Include_reference_on_derived_type_using_lambda_with_soft_cast(bool async) { - await base.Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(async); + await base.Include_reference_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [g].[Nickname] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname] + 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] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] -ORDER BY [u].[Nickname] +) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] """); } - public override async Task Subquery_containing_join_gets_lifted_clashing_names(bool async) + public override async Task Include_reference_on_derived_type_using_lambda_with_tracking(bool async) { - await base.Subquery_containing_join_gets_lifted_clashing_names(async); + await base.Include_reference_on_derived_type_using_lambda_with_tracking(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [g].[Nickname] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname] + 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] -INNER JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] -INNER JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] -WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL -ORDER BY [u].[Nickname], [t0].[Id] +) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] """); } - public override async Task Subquery_created_by_include_gets_lifted_nested(bool async) + public override async Task Include_collection_on_derived_type_using_string(bool async) { - await base.Subquery_created_by_include_gets_lifted_nested(async); + await base.Include_collection_on_derived_type_using_string(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [c].[Name], [c].[Location], [c].[Nation] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -4341,1005 +4332,1207 @@ 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] -INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -WHERE EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]) AND [u].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [u].[Nickname] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Subquery_is_lifted_from_additional_from_clause(bool async) + public override async Task Include_collection_on_derived_type_using_lambda(bool async) { - await base.Subquery_is_lifted_from_additional_from_clause(async); + await base.Include_collection_on_derived_type_using_lambda(async); AssertSql( """ -SELECT [u].[FullName] AS [Name1], [u0].[FullName] AS [Name2] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] + 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] -CROSS JOIN ( - SELECT [g0].[FullName], [g0].[HasSoulPatch] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[FullName], [o0].[HasSoulPatch] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o0] -) AS [u0] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND [u0].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [u].[FullName] +) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Subquery_with_result_operator_is_not_lifted(bool async) + public override async Task Include_collection_on_derived_type_using_lambda_with_soft_cast(bool async) { - await base.Subquery_with_result_operator_is_not_lifted(async); + await base.Include_collection_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( """ -@p='2' - -SELECT [u0].[FullName] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT TOP(@p) [u].[FullName], [u].[Rank] - FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(0 AS bit) - ORDER BY [u].[FullName] -) AS [u0] -ORDER BY [u0].[Rank] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down(bool async) + public override async Task Include_base_navigation_on_derived_entity(bool async) { - await base.Skip_with_orderby_followed_by_orderBy_is_pushed_down(async); + await base.Include_base_navigation_on_derived_entity(async); AssertSql( """ -@p='1' - -SELECT [u0].[FullName] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( - SELECT [u].[FullName], [u].[Rank] - FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(0 AS bit) - ORDER BY [u].[FullName] - OFFSET @p ROWS -) AS [u0] -ORDER BY [u0].[Rank] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [t].[Id] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) + public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); + await base.ThenInclude_collection_on_derived_after_base_reference(async); AssertSql( """ -@p='999' - -SELECT [u0].[FullName] -FROM ( - SELECT TOP(@p) [u].[FullName], [u].[Rank] - FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(0 AS bit) -) AS [u0] -ORDER BY [u0].[Rank] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) + public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); + await base.ThenInclude_collection_on_derived_after_derived_reference(async); AssertSql( """ -@p='999' +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] +"""); + } -SELECT [u0].[FullName] -FROM ( - SELECT TOP(@p) [u].[FullName], [u].[Rank] - FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] - FROM [Gears] AS [g] + public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) + { + await base.ThenInclude_collection_on_derived_after_derived_collection(async); + + AssertSql( + """ +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Nickname0], [s].[SquadId0], [s].[AssignedCityName0], [s].[CityOfBirthName0], [s].[FullName0], [s].[HasSoulPatch0], [s].[LeaderNickname0], [s].[LeaderSquadId0], [s].[Rank0], [s].[Discriminator0] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +LEFT JOIN ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u1].[Nickname] AS [Nickname0], [u1].[SquadId] AS [SquadId0], [u1].[AssignedCityName] AS [AssignedCityName0], [u1].[CityOfBirthName] AS [CityOfBirthName0], [u1].[FullName] AS [FullName0], [u1].[HasSoulPatch] AS [HasSoulPatch0], [u1].[LeaderNickname] AS [LeaderNickname0], [u1].[LeaderSquadId] AS [LeaderSquadId0], [u1].[Rank] AS [Rank0], [u1].[Discriminator] AS [Discriminator0] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(0 AS bit) -) AS [u0] -ORDER BY [u0].[Rank] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o1] + ) AS [u1] ON [u0].[Nickname] = [u1].[LeaderNickname] AND [u0].[SquadId] = [u1].[LeaderSquadId] +) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[SquadId], [s].[Nickname0] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) + public override async Task ThenInclude_reference_on_derived_after_derived_collection(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); + await base.ThenInclude_reference_on_derived_after_derived_collection(async); AssertSql( """ -@p='999' - -SELECT [u0].[FullName] -FROM ( - SELECT TOP(@p) [u].[FullName], [u].[Rank] +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator0] +FROM [LocustHordes] AS [l] +LEFT JOIN ( + SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] AS [Discriminator0] FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch], [g].[Rank] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l0] + UNION ALL + SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l1] + ) AS [u] + LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch], [o].[Rank] + 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 [u].[HasSoulPatch] = CAST(0 AS bit) -) AS [u0] -ORDER BY [u0].[FullName], [u0].[Rank] + ) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +) AS [s] ON [l].[Id] = [s].[LocustHordeId] +ORDER BY [l].[Id], [s].[Name], [s].[Nickname] """); } - public override async Task Select_length_of_string_property(bool async) + public override async Task Multiple_derived_included_on_one_method(bool async) { - await base.Select_length_of_string_property(async); + await base.Multiple_derived_included_on_one_method(async); AssertSql( """ -SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] -FROM [Weapons] AS [w] +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Client_method_on_collection_navigation_in_outer_join_key(bool async) - { - await base.Client_method_on_collection_navigation_in_outer_join_key(async); - - AssertSql(); - } - - public override async Task Member_access_on_derived_entity_using_cast(bool async) + public override async Task Include_on_derived_multi_level(bool async) { - await base.Member_access_on_derived_entity_using_cast(async); + await base.Include_on_derived_multi_level(async); AssertSql( """ -SELECT [l].[Name], [l].[Eradicated] -FROM [LocustHordes] AS [l] -ORDER BY [l].[Name] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Id], [s1].[Banner], [s1].[Banner5], [s1].[InternalNumber], [s1].[Name], [s1].[SquadId0], [s1].[MissionId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +LEFT JOIN ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[SquadId] AS [SquadId0], [s0].[MissionId] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] + LEFT JOIN [SquadMissions] AS [s0] ON [s].[Id] = [s0].[SquadId] +) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[SquadId0] """); } - public override async Task Member_access_on_derived_materialized_entity_using_cast(bool async) + public override async Task Projecting_nullable_bool_in_conditional_works(bool async) { - await base.Member_access_on_derived_materialized_entity_using_cast(async); + await base.Projecting_nullable_bool_in_conditional_works(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] -FROM [LocustHordes] AS [l] -ORDER BY [l].[Name] +SELECT CASE + WHEN [u].[Nickname] IS NOT NULL AND [u].[SquadId] IS NOT NULL THEN [u].[HasSoulPatch] + ELSE CAST(0 AS bit) +END AS [Prop] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Member_access_on_derived_entity_using_cast_and_let(bool async) + public override async Task ToString_enum_property_projection(bool async) { - await base.Member_access_on_derived_entity_using_cast_and_let(async); + await base.ToString_enum_property_projection(async); AssertSql( """ -SELECT [l].[Name], [l].[Eradicated] -FROM [LocustHordes] AS [l] -ORDER BY [l].[Name] +SELECT CASE [u].[Rank] + WHEN 0 THEN N'None' + WHEN 1 THEN N'Private' + WHEN 2 THEN N'Corporal' + WHEN 4 THEN N'Sergeant' + WHEN 8 THEN N'Lieutenant' + WHEN 16 THEN N'Captain' + WHEN 32 THEN N'Major' + WHEN 64 THEN N'Colonel' + WHEN 128 THEN N'General' + ELSE CAST([u].[Rank] AS nvarchar(max)) +END +FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Rank] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task Property_access_on_derived_entity_using_cast(bool async) + public override async Task ToString_nullable_enum_property_projection(bool async) { - await base.Property_access_on_derived_entity_using_cast(async); + await base.ToString_nullable_enum_property_projection(async); AssertSql( """ -SELECT [l].[Name], [l].[Eradicated] -FROM [LocustHordes] AS [l] -ORDER BY [l].[Name] +SELECT CASE [w].[AmmunitionType] + WHEN 1 THEN N'Cartridge' + WHEN 2 THEN N'Shell' + ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') +END +FROM [Weapons] AS [w] """); } - public override async Task Navigation_access_on_derived_entity_using_cast(bool async) + public override async Task ToString_enum_contains(bool async) { - await base.Navigation_access_on_derived_entity_using_cast(async); + await base.ToString_enum_contains(async); AssertSql( """ -SELECT [l].[Name], [l0].[ThreatLevel] AS [Threat] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -ORDER BY [l].[Name] +SELECT [m].[CodeName] +FROM [Missions] AS [m] +WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' """); } - public override async Task Navigation_access_on_derived_materialized_entity_using_cast(bool async) + public override async Task ToString_nullable_enum_contains(bool async) { - await base.Navigation_access_on_derived_materialized_entity_using_cast(async); + await base.ToString_nullable_enum_contains(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[ThreatLevel] AS [Threat] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -ORDER BY [l].[Name] +SELECT [w].[Name] +FROM [Weapons] AS [w] +WHERE CASE [w].[AmmunitionType] + WHEN 1 THEN N'Cartridge' + WHEN 2 THEN N'Shell' + ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') +END LIKE N'%Cart%' """); } - public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) { - await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); + await base.Correlated_collections_naked_navigation_with_ToList(async); AssertSql( """ -SELECT [l].[Name], [l0].[ThreatLevel] AS [Threat] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -ORDER BY [l].[Name] +SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Navigation_access_fk_on_derived_entity_using_cast(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool async) { - await base.Navigation_access_fk_on_derived_entity_using_cast(async); + await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(async); AssertSql( """ -SELECT [l].[Name], [l0].[Name] AS [CommanderName] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -ORDER BY [l].[Name] +SELECT ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]) +FROM ( + SELECT [g].[Nickname], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname] """); } - public override async Task Collection_navigation_access_on_derived_entity_using_cast(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToArray(bool async) { - await base.Collection_navigation_access_on_derived_entity_using_cast(async); + await base.Correlated_collections_naked_navigation_with_ToArray(async); AssertSql( """ -SELECT [l].[Name], ( - SELECT COUNT(*) - FROM ( - SELECT [l0].[LocustHordeId] - FROM [LocustLeaders] AS [l0] - UNION ALL - SELECT [l1].[LocustHordeId] - FROM [LocustCommanders] AS [l1] - ) AS [u] - WHERE [l].[Id] = [u].[LocustHordeId]) AS [LeadersCount] -FROM [LocustHordes] AS [l] -ORDER BY [l].[Name] -"""); - } - - public override async Task Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(bool async) - { - await base.Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(async); - - AssertSql( - """ -SELECT [l].[Name], [u].[Name] AS [LeaderName] -FROM [LocustHordes] AS [l] -INNER JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId] - FROM [LocustLeaders] AS [l0] +SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] UNION ALL - SELECT [l1].[Name], [l1].[LocustHordeId] - FROM [LocustCommanders] AS [l1] -) AS [u] ON [l].[Id] = [u].[LocustHordeId] -ORDER BY [u].[Name] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Include_on_derived_entity_using_OfType(bool async) + public override async Task Correlated_collections_basic_projection(bool async) { - await base.Include_on_derived_entity_using_OfType(async); + await base.Correlated_collections_basic_projection(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -LEFT JOIN ( - SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l1] +SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] UNION ALL - SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l2].[DefeatedByNickname], [l2].[DefeatedBySquadId], [l2].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l2] -) AS [u] ON [l].[Id] = [u].[LocustHordeId] -ORDER BY [l].[Name], [l].[Id], [l0].[Name] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) + public override async Task Correlated_collections_basic_projection_explicit_to_list(bool async) { - await base.Distinct_on_subquery_doesnt_get_lifted(async); + await base.Correlated_collections_basic_projection_explicit_to_list(async); AssertSql( """ -SELECT [u0].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT DISTINCT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -) AS [u0] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(bool async) + public override async Task Correlated_collections_basic_projection_explicit_to_array(bool async) { - await base.Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(async); + await base.Correlated_collections_basic_projection_explicit_to_array(async); AssertSql( """ -SELECT [l].[Eradicated] -FROM [LocustHordes] AS [l] +SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Comparing_two_collection_navigations_composite_key(bool async) + public override async Task Correlated_collections_basic_projection_ordered(bool async) { - await base.Comparing_two_collection_navigations_composite_key(async); + await base.Correlated_collections_basic_projection_ordered(async); AssertSql( """ -SELECT [u].[Nickname] AS [Nickname1], [u0].[Nickname] AS [Nickname2] +SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT [g].[Nickname], [g].[SquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] -) AS [u0] -WHERE [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] -ORDER BY [u].[Nickname] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId], [w0].[Name] DESC """); } - public override async Task Comparing_two_collection_navigations_inheritance(bool async) + public override async Task Correlated_collections_basic_projection_composite_key(bool async) { - await base.Comparing_two_collection_navigations_inheritance(async); + await base.Correlated_collections_basic_projection_composite_key(async); AssertSql( """ -SELECT [l].[Name], [u].[Nickname] -FROM [LocustHordes] AS [l] -CROSS JOIN ( - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [u1].[Nickname], [u1].[FullName], [u1].[SquadId] +FROM ( + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] -) AS [u0] ON [l0].[DefeatedByNickname] = [u0].[Nickname] AND [l0].[DefeatedBySquadId] = [u0].[SquadId] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) AND [u0].[Nickname] = [u].[Nickname] AND [u0].[SquadId] = [u].[SquadId] + SELECT [u0].[Nickname], [u0].[FullName], [u0].[SquadId], [u0].[LeaderNickname], [u0].[LeaderSquadId] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u0].[HasSoulPatch] = CAST(0 AS bit) +) AS [u1] ON [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] +WHERE [u].[Nickname] <> N'Foo' +ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] """); } - public override async Task Comparing_entities_using_Equals_inheritance(bool async) + public override async Task Correlated_collections_basic_projecting_single_property(bool async) { - await base.Comparing_entities_using_Equals_inheritance(async); + await base.Correlated_collections_basic_projecting_single_property(async); AssertSql( """ -SELECT [u].[Nickname] AS [Nickname1], [u0].[Nickname] AS [Nickname2] +SELECT [u].[Nickname], [u].[SquadId], [w0].[Name], [w0].[Id] FROM ( - SELECT [g].[Nickname], [g].[SquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -CROSS JOIN ( - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] -) AS [u0] -WHERE [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] -ORDER BY [u].[Nickname], [u0].[Nickname] +LEFT JOIN ( + SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Contains_on_nullable_array_produces_correct_sql(bool async) + public override async Task Correlated_collections_basic_projecting_constant(bool async) { - await base.Contains_on_nullable_array_produces_correct_sql(async); + await base.Correlated_collections_basic_projecting_constant(async); AssertSql( """ -@cities_without_nulls='["Ephyra"]' (Size = 4000) - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [w0].[c], [w0].[Id] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] -WHERE [u].[SquadId] < 2 AND ([c].[Name] IN ( - SELECT [c0].[value] - FROM OPENJSON(@cities_without_nulls) AS [c0] -) OR [c].[Name] IS NULL) +LEFT JOIN ( + SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Optional_navigation_with_collection_composite_key(bool async) + public override async Task Correlated_collections_basic_projecting_constant_bool(bool async) { - await base.Optional_navigation_with_collection_composite_key(async); + await base.Correlated_collections_basic_projecting_constant_bool(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], N'Gear' AS [Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [w0].[c], [w0].[Id] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Discriminator] = N'Officer' AND ( - SELECT COUNT(*) - FROM ( - SELECT [g0].[Nickname], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] IS NOT NULL AND [u].[SquadId] IS NOT NULL AND [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] AND [u0].[Nickname] = N'Dom') > 0 +) AS [u] +LEFT JOIN ( + SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Select_null_conditional_with_inheritance(bool async) + public override async Task Correlated_collections_projection_of_collection_thru_navigation(bool async) { - await base.Select_null_conditional_with_inheritance(async); + await base.Correlated_collections_projection_of_collection_thru_navigation(async); AssertSql( """ -SELECT CASE - WHEN [l].[CommanderName] IS NOT NULL THEN [l].[CommanderName] -END -FROM [LocustHordes] AS [l] +SELECT [u].[Nickname], [u].[SquadId], [s].[Id], [s1].[SquadId], [s1].[MissionId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] +LEFT JOIN ( + SELECT [s0].[SquadId], [s0].[MissionId] + FROM [SquadMissions] AS [s0] + WHERE [s0].[MissionId] <> 17 +) AS [s1] ON [s].[Id] = [s1].[SquadId] +WHERE [u].[Nickname] <> N'Marcus' +ORDER BY [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[Id], [s1].[SquadId] """); } - public override async Task Select_null_conditional_with_inheritance_negative(bool async) + public override async Task Correlated_collections_project_anonymous_collection_result(bool async) { - await base.Select_null_conditional_with_inheritance_negative(async); + await base.Correlated_collections_project_anonymous_collection_result(async); AssertSql( """ -SELECT CASE - WHEN [l].[CommanderName] IS NOT NULL THEN [l].[Eradicated] -END -FROM [LocustHordes] AS [l] +SELECT [s].[Name], [s].[Id], [u].[FullName], [u].[Rank], [u].[Nickname], [u].[SquadId] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[Rank] + FROM [Officers] AS [o] +) AS [u] ON [s].[Id] = [u].[SquadId] +WHERE [s].[Id] < 20 +ORDER BY [s].[Id], [u].[Nickname] """); } - public override async Task Project_collection_navigation_with_inheritance1(bool async) + public override async Task Correlated_collections_nested(bool async) { - await base.Project_collection_navigation_with_inheritance1(async); + await base.Correlated_collections_nested(async); AssertSql( """ -SELECT [l].[Id], [l0].[Name], [l1].[Id], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -LEFT JOIN [LocustHordes] AS [l1] ON [l0].[Name] = [l1].[CommanderName] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l2] - UNION ALL - SELECT [l3].[Name], [l3].[LocustHordeId], [l3].[ThreatLevel], [l3].[ThreatLevelByte], [l3].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l3] -) AS [u] ON [l1].[Id] = [u].[LocustHordeId] -ORDER BY [l].[Id], [l0].[Name], [l1].[Id] + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 7 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 42 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task Project_collection_navigation_with_inheritance2(bool async) + public override async Task Correlated_collections_nested_mixed_streaming_with_buffer1(bool async) { - await base.Project_collection_navigation_with_inheritance2(async); + await base.Correlated_collections_nested_mixed_streaming_with_buffer1(async); AssertSql( """ -SELECT [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 2 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 3 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task Project_collection_navigation_with_inheritance3(bool async) + public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) { - await base.Project_collection_navigation_with_inheritance3(async); + await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); AssertSql( """ -SELECT [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 7 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 42 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task Include_reference_on_derived_type_using_string(bool async) + public override async Task Correlated_collections_nested_with_custom_ordering(bool async) { - await base.Include_reference_on_derived_type_using_string(async); + await base.Correlated_collections_nested_with_custom_ordering(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] + FROM [Officers] AS [o] ) AS [u] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] + SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [u0].[Rank], [u0].[LeaderNickname], [u0].[LeaderSquadId] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank] + FROM [Officers] AS [o0] + ) AS [u0] + LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] + WHERE [u0].[FullName] <> N'Foo' +) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] +ORDER BY [u].[HasSoulPatch] DESC, [u].[Nickname], [u].[SquadId], [s].[Rank], [s].[Nickname], [s].[SquadId], [s].[IsAutomatic] """); } - public override async Task Include_reference_on_derived_type_using_string_nested1(bool async) + public override async Task Correlated_collections_same_collection_projected_multiple_times(bool async) { - await base.Include_reference_on_derived_type_using_string_nested1(async); + await base.Correlated_collections_same_collection_projected_multiple_times(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] -LEFT JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] +) AS [u] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w1] ON [u].[FullName] = [w1].[OwnerFullName] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(1 AS bit) +) AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [w1].[Id] """); } - public override async Task Include_reference_on_derived_type_using_string_nested2(bool async) + public override async Task Correlated_collections_similar_collection_projected_multiple_times(bool async) { - await base.Include_reference_on_derived_type_using_string_nested2(async); + await base.Correlated_collections_similar_collection_projected_multiple_times(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Name], [s].[Location], [s].[Nation] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[Rank] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[Rank] FROM [Officers] AS [o] -) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +) AS [u] LEFT JOIN ( - SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator], [c].[Name], [c].[Location], [c].[Nation] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u1] - INNER JOIN [Cities] AS [c] ON [u1].[CityOfBirthName] = [c].[Name] -) AS [s] ON ([u0].[Nickname] = [s].[LeaderNickname] OR ([u0].[Nickname] IS NULL AND [s].[LeaderNickname] IS NULL)) AND [u0].[SquadId] = [s].[LeaderSquadId] -ORDER BY [u].[Name], [u0].[Nickname], [u0].[SquadId], [s].[Nickname], [s].[SquadId] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w1] ON [u].[FullName] = [w1].[OwnerFullName] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(0 AS bit) +) AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] +ORDER BY [u].[Rank], [u].[Nickname], [u].[SquadId], [w1].[OwnerFullName], [w1].[Id], [w2].[IsAutomatic] """); } - public override async Task Include_reference_on_derived_type_using_lambda(bool async) + public override async Task Correlated_collections_different_collections_projected(bool async) { - await base.Include_reference_on_derived_type_using_lambda(async); + await base.Correlated_collections_different_collections_projected(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [w0].[Name], [w0].[IsAutomatic], [w0].[Id], [u0].[Nickname], [u0].[Rank], [u0].[SquadId] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] ) AS [u] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] -"""); - } - - public override async Task Include_reference_on_derived_type_using_lambda_with_soft_cast(bool async) - { - await base.Include_reference_on_derived_type_using_lambda_with_soft_cast(async); - - AssertSql( - """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] + SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [u].[FullName], [u].[Nickname], [u].[SquadId], [w0].[Id], [u0].[FullName], [u0].[Nickname] """); } - public override async Task Include_reference_on_derived_type_using_lambda_with_tracking(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(bool async) { - await base.Include_reference_on_derived_type_using_lambda_with_tracking(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[FullName] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) +ORDER BY [u].[HasSoulPatch] DESC, [t].[Note] """); } - public override async Task Include_collection_on_derived_type_using_string(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) { - await base.Include_collection_on_derived_type_using_string(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname] + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] + FROM [Officers] AS [o1] +) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u2].[Nickname], [u2].[SquadId] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName] + FROM [Officers] AS [o2] + ) AS [u2] ON [w].[OwnerFullName] = [u2].[FullName] +) AS [s] ON [u1].[FullName] = [s].[OwnerFullName] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) +ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] """); } - public override async Task Include_collection_on_derived_type_using_lambda(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( + bool async) { - await base.Include_collection_on_derived_type_using_lambda(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname] + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] + FROM [Officers] AS [o1] +) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u2].[Nickname], [u2].[SquadId] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName] + FROM [Officers] AS [o2] + ) AS [u2] ON [w].[OwnerFullName] = [u2].[FullName] +) AS [s] ON [u1].[FullName] = [s].[OwnerFullName] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) +ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] """); } - public override async Task Include_collection_on_derived_type_using_lambda_with_soft_cast(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( + bool async) { - await base.Include_collection_on_derived_type_using_lambda_with_soft_cast(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [u0].[Nickname] + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] + FROM [Officers] AS [o1] +) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u2].[Nickname], [u2].[SquadId], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [u2].[FullName] IS NOT NULL AND [u2].[FullName] = [w0].[OwnerFullName]) AS [c] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName] + FROM [Officers] AS [o2] + ) AS [u2] ON [w].[OwnerFullName] = [u2].[FullName] +) AS [s] ON [u1].[FullName] = [s].[OwnerFullName] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) +ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id] DESC, [s].[c], [s].[Nickname] """); } - public override async Task Include_base_navigation_on_derived_entity(bool async) + public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) { - await base.Include_base_navigation_on_derived_entity(async); + await base.Correlated_collections_multiple_nested_complex_collections(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Name], [s1].[IsAutomatic], [s1].[Id1], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00], [s2].[Id], [s2].[AmmunitionType], [s2].[IsAutomatic], [s2].[Name], [s2].[OwnerFullName], [s2].[SynergyWithId], [s2].[Nickname], [s2].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [t].[Id] -"""); - } - - public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) - { - await base.ThenInclude_collection_on_derived_after_base_reference(async); - - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId] -"""); - } - - public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) - { - await base.ThenInclude_collection_on_derived_after_derived_reference(async); - - AssertSql( - """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] FROM [Gears] AS [g0] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] + FROM [Officers] AS [o1] +) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] +LEFT JOIN ( + SELECT [u2].[FullName], [u2].[Nickname], [u2].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Name], [s0].[IsAutomatic], [s0].[Id1], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [u2].[Rank], [s0].[IsAutomatic0], [u2].[LeaderNickname], [u2].[LeaderSquadId] + FROM ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName], [o2].[LeaderNickname], [o2].[LeaderSquadId], [o2].[Rank] + FROM [Officers] AS [o2] + ) AS [u2] + LEFT JOIN ( + SELECT [w].[Id], [u3].[Nickname], [u3].[SquadId], [s].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [u4].[Nickname] AS [Nickname0], [u4].[HasSoulPatch], [u4].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] + FROM [Gears] AS [g2] + UNION ALL + SELECT [o3].[Nickname], [o3].[SquadId], [o3].[FullName] + FROM [Officers] AS [o3] + ) AS [u3] ON [w].[OwnerFullName] = [u3].[FullName] + LEFT JOIN [Squads] AS [s] ON [u3].[SquadId] = [s].[Id] + LEFT JOIN [Weapons] AS [w0] ON [u3].[FullName] = [w0].[OwnerFullName] + LEFT JOIN ( + SELECT [g3].[Nickname], [g3].[SquadId], [g3].[HasSoulPatch] + FROM [Gears] AS [g3] + UNION ALL + SELECT [o4].[Nickname], [o4].[SquadId], [o4].[HasSoulPatch] + FROM [Officers] AS [o4] + ) AS [u4] ON [s].[Id] = [u4].[SquadId] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [s0] ON [u2].[FullName] = [s0].[OwnerFullName] + WHERE [u2].[FullName] <> N'Foo' +) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] +LEFT JOIN ( + SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [u5].[Nickname], [u5].[SquadId] + FROM [Weapons] AS [w1] + LEFT JOIN ( + SELECT [g4].[Nickname], [g4].[SquadId], [g4].[FullName] + FROM [Gears] AS [g4] + UNION ALL + SELECT [o5].[Nickname], [o5].[SquadId], [o5].[FullName] + FROM [Officers] AS [o5] + ) AS [u5] ON [w1].[OwnerFullName] = [u5].[FullName] +) AS [s2] ON [u1].[FullName] = [s2].[OwnerFullName] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) +ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s1].[Rank], [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic0], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Id1], [s1].[Nickname00], [s1].[SquadId00], [s2].[IsAutomatic], [s2].[Nickname] DESC, [s2].[Id] """); } - public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) + public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) { - await base.ThenInclude_collection_on_derived_after_derived_collection(async); + await base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Nickname0], [s].[SquadId0], [s].[AssignedCityName0], [s].[CityOfBirthName0], [s].[FullName0], [s].[HasSoulPatch0], [s].[LeaderNickname0], [s].[LeaderSquadId0], [s].[Rank0], [s].[Discriminator0] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [u1].[ReportName], [u1].[OfficerName], [u1].[Nickname], [u1].[SquadId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u1].[Nickname] AS [Nickname0], [u1].[SquadId] AS [SquadId0], [u1].[AssignedCityName] AS [AssignedCityName0], [u1].[CityOfBirthName] AS [CityOfBirthName0], [u1].[FullName] AS [FullName0], [u1].[HasSoulPatch] AS [HasSoulPatch0], [u1].[LeaderNickname] AS [LeaderNickname0], [u1].[LeaderSquadId] AS [LeaderSquadId0], [u1].[Rank] AS [Rank0], [u1].[Discriminator] AS [Discriminator0] +OUTER APPLY ( + SELECT [u0].[FullName] AS [ReportName], [u].[FullName] AS [OfficerName], [u0].[Nickname], [u0].[SquadId] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] FROM [Officers] AS [o0] ) AS [u0] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g1] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +) AS [u1] +ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] +"""); + } + + public override async Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) + { + await base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async); + + AssertSql( + """ +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [u1].[ReportName], [u1].[Nickname], [u1].[SquadId] +FROM ( + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +OUTER APPLY ( + SELECT [u0].[FullName] AS [ReportName], [u0].[Nickname], [u0].[SquadId] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o1] - ) AS [u1] ON [u0].[Nickname] = [u1].[LeaderNickname] AND [u0].[SquadId] = [u1].[LeaderSquadId] -) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[SquadId], [s].[Nickname0] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] AND [u].[FullName] <> N'Foo' +) AS [u1] +ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] """); } - public override async Task ThenInclude_reference_on_derived_after_derived_collection(bool async) + public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) { - await base.ThenInclude_reference_on_derived_after_derived_collection(async); + await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator0] -FROM [LocustHordes] AS [l] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] +FROM ( + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] LEFT JOIN ( - SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] AS [Discriminator0] + SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id], [u0].[LeaderNickname], [u0].[LeaderSquadId] FROM ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l0] - UNION ALL - SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l1] - ) AS [u] - LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] FROM [Gears] AS [g] 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] -) AS [s] ON [l].[Id] = [s].[LocustHordeId] -ORDER BY [l].[Id], [s].[Name], [s].[Nickname] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + OUTER APPLY ( + SELECT [w].[Name], [u0].[Nickname], [w].[Id] + FROM [Weapons] AS [w] + WHERE [u0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) + ) AS [w0] + WHERE [u0].[FullName] <> N'Foo' +) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Multiple_derived_included_on_one_method(bool async) + public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) { - await base.Multiple_derived_included_on_one_method(async); + await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated], [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] +FROM ( + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] ON [l0].[DefeatedByNickname] = [u].[Nickname] AND [l0].[DefeatedBySquadId] = [u].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [l].[Id], [l0].[Name], [u].[Nickname], [u].[SquadId], [u0].[Nickname] +) AS [u] +OUTER APPLY ( + SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + LEFT JOIN ( + SELECT [w].[Name], [u].[Nickname], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] AND [u0].[FullName] <> N'Foo' +) AS [s] +ORDER BY [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Include_on_derived_multi_level(bool async) + public override async Task Correlated_collections_on_select_many(bool async) { - await base.Include_on_derived_multi_level(async); + await base.Correlated_collections_on_select_many(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Id], [s1].[Banner], [s1].[Banner5], [s1].[InternalNumber], [s1].[Name], [s1].[SquadId0], [s1].[MissionId] +SELECT [u].[Nickname], [s].[Name], [u].[SquadId], [s].[Id], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] +CROSS JOIN [Squads] AS [s] LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[SquadId] AS [SquadId0], [s0].[MissionId] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +LEFT JOIN ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g0] @@ -5347,198 +5540,257 @@ UNION ALL SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] FROM [Officers] AS [o0] ) AS [u0] - INNER JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] - LEFT JOIN [SquadMissions] AS [s0] ON [s].[Id] = [s0].[SquadId] -) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[SquadId0] + WHERE [u0].[HasSoulPatch] = CAST(0 AS bit) +) AS [u1] ON [s].[Id] = [u1].[SquadId] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [u].[Nickname], [s].[Id] DESC, [u].[SquadId], [w0].[Id], [u1].[Nickname] """); } - public override async Task Projecting_nullable_bool_in_conditional_works(bool async) + public override async Task Correlated_collections_with_Skip(bool async) { - await base.Projecting_nullable_bool_in_conditional_works(async); + await base.Correlated_collections_with_Skip(async); AssertSql( """ -SELECT CASE - WHEN [u].[Nickname] IS NOT NULL AND [u].[SquadId] IS NOT NULL THEN [u].[HasSoulPatch] - ELSE CAST(0 AS bit) -END AS [Prop] -FROM [Tags] AS [t] +SELECT [s].[Id], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname]) AS [row] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] + ) AS [u0] + WHERE 1 < [u0].[row] +) AS [u1] ON [s].[Id] = [u1].[SquadId] +ORDER BY [s].[Name], [s].[Id], [u1].[SquadId], [u1].[Nickname] """); } - public override async Task ToString_enum_property_projection(bool async) + public override async Task Correlated_collections_with_Take(bool async) { - await base.ToString_enum_property_projection(async); + await base.Correlated_collections_with_Take(async); AssertSql( """ -SELECT CASE [u].[Rank] - WHEN 0 THEN N'None' - WHEN 1 THEN N'Private' - WHEN 2 THEN N'Corporal' - WHEN 4 THEN N'Sergeant' - WHEN 8 THEN N'Lieutenant' - WHEN 16 THEN N'Captain' - WHEN 32 THEN N'Major' - WHEN 64 THEN N'Colonel' - WHEN 128 THEN N'General' - ELSE CAST([u].[Rank] AS nvarchar(max)) -END -FROM ( - SELECT [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Rank] - FROM [Officers] AS [o] -) AS [u] +SELECT [s].[Id], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname]) AS [row] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] + ) AS [u0] + WHERE [u0].[row] <= 2 +) AS [u1] ON [s].[Id] = [u1].[SquadId] +ORDER BY [s].[Name], [s].[Id], [u1].[SquadId], [u1].[Nickname] """); } - public override async Task ToString_nullable_enum_property_projection(bool async) + public override async Task Correlated_collections_with_Distinct(bool async) { - await base.ToString_nullable_enum_property_projection(async); + await base.Correlated_collections_with_Distinct(async); AssertSql( """ -SELECT CASE [w].[AmmunitionType] - WHEN 1 THEN N'Cartridge' - WHEN 2 THEN N'Shell' - ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') -END -FROM [Weapons] AS [w] +SELECT [s].[Id], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] +FROM [Squads] AS [s] +OUTER APPLY ( + SELECT DISTINCT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [s].[Id] = [u].[SquadId] + ORDER BY [u].[Nickname] + OFFSET 0 ROWS + ) AS [u0] +) AS [u1] +ORDER BY [s].[Name], [s].[Id], [u1].[Nickname] """); } - public override async Task ToString_enum_contains(bool async) + public override async Task Correlated_collections_with_FirstOrDefault(bool async) { - await base.ToString_enum_contains(async); + await base.Correlated_collections_with_FirstOrDefault(async); AssertSql( """ -SELECT [m].[CodeName] -FROM [Missions] AS [m] -WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' +SELECT ( + SELECT TOP(1) [u].[FullName] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] + ORDER BY [u].[Nickname]) +FROM [Squads] AS [s] +ORDER BY [s].[Name] """); } - public override async Task ToString_nullable_enum_contains(bool async) + public override async Task Correlated_collections_on_left_join_with_predicate(bool async) { - await base.ToString_nullable_enum_contains(async); + await base.Correlated_collections_on_left_join_with_predicate(async); AssertSql( """ -SELECT [w].[Name] -FROM [Weapons] AS [w] -WHERE CASE [w].[AmmunitionType] - WHEN 1 THEN N'Cartridge' - WHEN 2 THEN N'Shell' - ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') -END LIKE N'%Cart%' +SELECT [u].[Nickname], [t].[Id], [u].[SquadId], [w].[Name], [w].[Id] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +WHERE [u].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId] """); } - public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) + public override async Task Correlated_collections_on_left_join_with_null_value(bool async) { - await base.Correlated_collections_naked_navigation_with_ToList(async); + await base.Correlated_collections_on_left_join_with_null_value(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( +SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [w].[Name], [w].[Id] +FROM [Tags] AS [t] +LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] +ORDER BY [t].[Note], [t].[Id], [u].[Nickname], [u].[SquadId] """); } - public override async Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool async) + public override async Task Correlated_collections_left_join_with_self_reference(bool async) { - await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(async); + await base.Correlated_collections_left_join_with_self_reference(async); AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]) -FROM ( - SELECT [g].[Nickname], [g].[FullName] +SELECT [t].[Note], [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[FullName], [u0].[Nickname], [u0].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] +) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Correlated_collections_naked_navigation_with_ToArray(bool async) + public override async Task Correlated_collections_deeply_nested_left_join(bool async) { - await base.Correlated_collections_naked_navigation_with_ToArray(async); + await base.Correlated_collections_deeply_nested_left_join(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] +SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] +LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] +LEFT JOIN ( + SELECT [u0].[Nickname], [u0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName], [g0].[HasSoulPatch] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[HasSoulPatch] + FROM [Officers] AS [o0] + ) AS [u0] + LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) + ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] + WHERE [u0].[HasSoulPatch] = CAST(1 AS bit) +) AS [s0] ON [s].[Id] = [s0].[SquadId] +ORDER BY [t].[Note], [u].[Nickname] DESC, [t].[Id], [u].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId] """); } - public override async Task Correlated_collections_basic_projection(bool async) + public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) { - await base.Correlated_collections_basic_projection(async); + await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM ( +SELECT [w].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId], [s0].[Rank] +FROM [Weapons] AS [w] +LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [w].[OwnerFullName] = [u].[FullName] +LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] + SELECT [u0].[Nickname], [u0].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [u0].[Rank], [u0].[FullName] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName], [g0].[Rank] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[Rank] + FROM [Officers] AS [o0] + ) AS [u0] + LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(0 AS bit) + ) AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +ORDER BY [w].[Name], [w].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s0].[FullName] DESC, [s0].[Nickname], [s0].[SquadId], [s0].[Id] """); } - public override async Task Correlated_collections_basic_projection_explicit_to_list(bool async) + public override async Task Correlated_collections_complex_scenario1(bool async) { - await base.Correlated_collections_basic_projection_explicit_to_list(async); + await base.Correlated_collections_complex_scenario1(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] @@ -5547,46 +5799,79 @@ UNION ALL FROM [Officers] AS [o] ) AS [u] LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT [w].[Id], [u0].[Nickname], [u0].[SquadId], [s].[Id] AS [Id0], [u1].[Nickname] AS [Nickname0], [u1].[HasSoulPatch], [u1].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] ON [w].[OwnerFullName] = [u0].[FullName] + LEFT JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[HasSoulPatch] + FROM [Officers] AS [o1] + ) AS [u1] ON [s].[Id] = [u1].[SquadId] +) AS [s0] ON [u].[FullName] = [s0].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] """); } - public override async Task Correlated_collections_basic_projection_explicit_to_array(bool async) + public override async Task Correlated_collections_complex_scenario2(bool async) { - await base.Correlated_collections_basic_projection_explicit_to_array(async); + await base.Correlated_collections_complex_scenario2(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] + SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [u0].[LeaderNickname], [u0].[LeaderSquadId] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + LEFT JOIN ( + SELECT [w].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id] AS [Id0], [u2].[Nickname] AS [Nickname0], [u2].[HasSoulPatch], [u2].[SquadId] AS [SquadId0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] + FROM [Officers] AS [o1] + ) AS [u1] ON [w].[OwnerFullName] = [u1].[FullName] + LEFT JOIN [Squads] AS [s] ON [u1].[SquadId] = [s].[Id] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o2].[Nickname], [o2].[SquadId], [o2].[HasSoulPatch] + FROM [Officers] AS [o2] + ) AS [u2] ON [s].[Id] = [u2].[SquadId] + ) AS [s0] ON [u0].[FullName] = [s0].[OwnerFullName] +) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] +ORDER BY [u].[Nickname], [u].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] """); } - public override async Task Correlated_collections_basic_projection_ordered(bool async) + public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) { - await base.Correlated_collections_basic_projection_ordered(async); + await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] @@ -5595,28 +5880,41 @@ UNION ALL FROM [Officers] AS [o] ) AS [u] LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + SELECT [w].[Id], [u0].[Nickname], [u0].[SquadId], [s].[Id] AS [Id0], [u1].[Nickname] AS [Nickname0], [u1].[HasSoulPatch], [u1].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId], [w0].[Name] DESC + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] ON [w].[OwnerFullName] = [u0].[FullName] + LEFT JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[HasSoulPatch] + FROM [Officers] AS [o1] + ) AS [u1] ON [s].[Id] = [u1].[SquadId] +) AS [s0] ON [u].[FullName] = [s0].[OwnerFullName] +ORDER BY [u].[FullName], [u].[Nickname] DESC, [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] """); } - public override async Task Correlated_collections_basic_projection_composite_key(bool async) + public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) { - await base.Correlated_collections_basic_projection_composite_key(async); + await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u1].[Nickname], [u1].[FullName], [u1].[SquadId] +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] FROM ( - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname] FROM [Officers] AS [o] ) AS [u] LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[FullName], [u0].[SquadId], [u0].[LeaderNickname], [u0].[LeaderSquadId] + SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [u0].[HasSoulPatch] AS [HasSoulPatch0], [s0].[IsAutomatic], [s0].[Name], [u0].[LeaderNickname], [u0].[LeaderSquadId] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId] FROM [Gears] AS [g] @@ -5624,3407 +5922,1815 @@ UNION ALL SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId] FROM [Officers] AS [o0] ) AS [u0] - WHERE [u0].[HasSoulPatch] = CAST(0 AS bit) -) AS [u1] ON [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] -WHERE [u].[Nickname] <> N'Foo' -ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] + LEFT JOIN ( + SELECT [w].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id] AS [Id0], [u2].[Nickname] AS [Nickname0], [u2].[HasSoulPatch], [u2].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] + FROM [Officers] AS [o1] + ) AS [u1] ON [w].[OwnerFullName] = [u1].[FullName] + LEFT JOIN [Squads] AS [s] ON [u1].[SquadId] = [s].[Id] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] + FROM [Gears] AS [g1] + UNION ALL + SELECT [o2].[Nickname], [o2].[SquadId], [o2].[HasSoulPatch] + FROM [Officers] AS [o2] + ) AS [u2] ON [s].[Id] = [u2].[SquadId] + ) AS [s0] ON [u0].[FullName] = [s0].[OwnerFullName] +) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] +ORDER BY [u].[HasSoulPatch], [u].[LeaderNickname], [u].[FullName], [u].[Nickname], [u].[SquadId], [s1].[FullName], [s1].[HasSoulPatch0] DESC, [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic], [s1].[Name] DESC, [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] """); } - public override async Task Correlated_collections_basic_projecting_single_property(bool async) + public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) { - await base.Correlated_collections_basic_projecting_single_property(async); + await base.Correlated_collection_with_top_level_FirstOrDefault(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[Name], [w0].[Id] +SELECT [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] + SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] + ORDER BY [u].[Nickname] +) AS [u0] +LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] +ORDER BY [u0].[Nickname], [u0].[SquadId] """); } - public override async Task Correlated_collections_basic_projecting_constant(bool async) + public override async Task Correlated_collection_with_top_level_Count(bool async) { - await base.Correlated_collections_basic_projecting_constant(async); + await base.Correlated_collection_with_top_level_Count(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[c], [w0].[Id] +SELECT COUNT(*) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + SELECT 1 AS empty FROM [Officers] AS [o] ) AS [u] -LEFT JOIN ( - SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Correlated_collections_basic_projecting_constant_bool(bool async) + public override async Task Correlated_collection_with_top_level_Last_with_orderby_on_outer(bool async) { - await base.Correlated_collections_basic_projecting_constant_bool(async); + await base.Correlated_collection_with_top_level_Last_with_orderby_on_outer(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[c], [w0].[Id] +SELECT [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[Nickname], [u].[SquadId] + SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] + ORDER BY [u].[FullName] +) AS [u0] +LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] +ORDER BY [u0].[FullName], [u0].[Nickname], [u0].[SquadId] """); } - public override async Task Correlated_collections_projection_of_collection_thru_navigation(bool async) + public override async Task Correlated_collection_with_top_level_Last_with_order_by_on_inner(bool async) { - await base.Correlated_collections_projection_of_collection_thru_navigation(async); + await base.Correlated_collection_with_top_level_Last_with_order_by_on_inner(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [s].[Id], [s1].[SquadId], [s1].[MissionId] +SELECT [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId] - FROM [SquadMissions] AS [s0] - WHERE [s0].[MissionId] <> 17 -) AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE [u].[Nickname] <> N'Marcus' -ORDER BY [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[Id], [s1].[SquadId] + SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] + ORDER BY [u].[FullName] DESC +) AS [u0] +LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] +ORDER BY [u0].[FullName] DESC, [u0].[Nickname], [u0].[SquadId], [w].[Name] """); } - public override async Task Correlated_collections_project_anonymous_collection_result(bool async) + public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) { - await base.Correlated_collections_project_anonymous_collection_result(async); + await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); AssertSql( """ -SELECT [s].[Name], [s].[Id], [u].[FullName], [u].[Rank], [u].[Nickname], [u].[SquadId] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] +SELECT [l2].[Id], [l2].[CapitalName], [l2].[Name], [l2].[ServerAddress], [l2].[CommanderName], [l2].[Eradicated] +FROM ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[Rank] - FROM [Officers] AS [o] -) AS [u] ON [s].[Id] = [u].[SquadId] -WHERE [s].[Id] < 20 -ORDER BY [s].[Id], [u].[Nickname] + SELECT [l0].[Name] + FROM [LocustCommanders] AS [l0] +) AS [u] +INNER JOIN ( + SELECT [l1].[Id], [l1].[CapitalName], [l1].[Name], [l1].[ServerAddress], [l1].[CommanderName], [l1].[Eradicated] + FROM [LocustHordes] AS [l1] + WHERE [l1].[Name] = N'Swarm' +) AS [l2] ON [u].[Name] = [l2].[CommanderName] +WHERE [l2].[Eradicated] = CAST(0 AS bit) OR [l2].[Eradicated] IS NULL """); } - public override async Task Correlated_collections_nested(bool async) + public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) { - await base.Correlated_collections_nested(async); + await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); AssertSql( """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] +SELECT [l2].[Id], [l2].[CapitalName], [l2].[Name], [l2].[ServerAddress], [l2].[CommanderName], [l2].[Eradicated] +FROM ( + SELECT [l].[Name] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name] + FROM [LocustCommanders] AS [l0] +) AS [u] LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 7 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 42 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] + SELECT [l1].[Id], [l1].[CapitalName], [l1].[Name], [l1].[ServerAddress], [l1].[CommanderName], [l1].[Eradicated] + FROM [LocustHordes] AS [l1] + WHERE [l1].[Name] = N'Swarm' +) AS [l2] ON [u].[Name] = [l2].[CommanderName] +WHERE [l2].[Eradicated] = CAST(0 AS bit) OR [l2].[Eradicated] IS NULL """); } - public override async Task Correlated_collections_nested_mixed_streaming_with_buffer1(bool async) + public override async Task Include_on_derived_type_with_order_by_and_paging(bool async) { - await base.Correlated_collections_nested_mixed_streaming_with_buffer1(async); + await base.Include_on_derived_type_with_order_by_and_paging(async); AssertSql( """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 2 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 3 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] -"""); - } - - public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) - { - await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); +@p='10' - AssertSql( - """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] +SELECT [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator0] AS [Discriminator], [s].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(@p) [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] AS [Discriminator0], [t].[Id], [t].[Note] + FROM ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] + ) AS [u] LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 7 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 42 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] + LEFT JOIN [Tags] AS [t] ON ([u0].[Nickname] = [t].[GearNickName] OR ([u0].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([u0].[SquadId] = [t].[GearSquadId] OR ([u0].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) + ORDER BY [t].[Note] +) AS [s] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [s].[Note], [s].[Name], [s].[Nickname], [s].[SquadId], [s].[Id] """); } - public override async Task Correlated_collections_nested_with_custom_ordering(bool async) + public override async Task Select_required_navigation_on_derived_type(bool async) { - await base.Correlated_collections_nested_with_custom_ordering(async); + await base.Select_required_navigation_on_derived_type(async); AssertSql( """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] +SELECT [l1].[Name] FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] + SELECT NULL AS [HighCommandId] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[HighCommandId] + FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN ( - SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [u0].[Rank], [u0].[LeaderNickname], [u0].[LeaderSquadId] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] - WHERE [u0].[FullName] <> N'Foo' -) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] -ORDER BY [u].[HasSoulPatch] DESC, [u].[Nickname], [u].[SquadId], [s].[Rank], [s].[Nickname], [s].[SquadId], [s].[IsAutomatic] +LEFT JOIN [LocustHighCommands] AS [l1] ON [u].[HighCommandId] = [l1].[Id] """); } - public override async Task Correlated_collections_same_collection_projected_multiple_times(bool async) + public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) { - await base.Correlated_collections_same_collection_projected_multiple_times(async); + await base.Select_required_navigation_on_the_same_type_with_cast(async); AssertSql( """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] +SELECT [c].[Name] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + SELECT [g].[CityOfBirthName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + SELECT [o].[CityOfBirthName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w1] ON [u].[FullName] = [w1].[OwnerFullName] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(1 AS bit) -) AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [w1].[Id] +INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] """); } - public override async Task Correlated_collections_similar_collection_projected_multiple_times(bool async) + public override async Task Where_required_navigation_on_derived_type(bool async) { - await base.Correlated_collections_similar_collection_projected_multiple_times(async); + await base.Where_required_navigation_on_derived_type(async); AssertSql( """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[Rank] - FROM [Officers] AS [o] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w1] ON [u].[FullName] = [w1].[OwnerFullName] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(0 AS bit) -) AS [w2] ON [u].[FullName] = [w2].[OwnerFullName] -ORDER BY [u].[Rank], [u].[Nickname], [u].[SquadId], [w1].[OwnerFullName], [w1].[Id], [w2].[IsAutomatic] +LEFT JOIN [LocustHighCommands] AS [l1] ON [u].[HighCommandId] = [l1].[Id] +WHERE [l1].[IsOperational] = CAST(1 AS bit) """); } - public override async Task Correlated_collections_different_collections_projected(bool async) + public override async Task Outer_parameter_in_join_key(bool async) { - await base.Correlated_collections_different_collections_projected(async); + await base.Outer_parameter_in_join_key(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w0].[Name], [w0].[IsAutomatic], [w0].[Id], [u0].[Nickname], [u0].[Rank], [u0].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] FROM ( SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN ( - SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [u].[FullName], [u].[Nickname], [u].[SquadId], [w0].[Id], [u0].[FullName], [u0].[Nickname] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [u0].[Nickname], [u0].[SquadId] + FROM [Tags] AS [t] + INNER JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] ON [u].[FullName] = [u0].[FullName] +) AS [s] +ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(bool async) + public override async Task Outer_parameter_in_join_key_inner_and_outer(bool async) { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); + await base.Outer_parameter_in_join_key_inner_and_outer(async); AssertSql( """ -SELECT [u].[FullName] +SELECT [u].[Nickname], [u].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [g].[LeaderNickname], [g].[LeaderSquadId] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [u0].[Nickname], [u0].[SquadId] + FROM [Tags] AS [t] + INNER JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] + SELECT [o0].[Nickname], [o0].[SquadId] FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) -ORDER BY [u].[HasSoulPatch] DESC, [t].[Note] + ) AS [u0] ON [u].[FullName] = [u].[Nickname] +) AS [s] +ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) + public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); + await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); AssertSql( """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] - FROM [Officers] AS [o1] -) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u2].[Nickname], [u2].[SquadId] - FROM [Weapons] AS [w] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [u0].[Nickname], [u0].[SquadId] + FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName] - FROM [Officers] AS [o2] - ) AS [u2] ON [w].[OwnerFullName] = [u2].[FullName] -) AS [s] ON [u1].[FullName] = [s].[OwnerFullName] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [g].[LeaderNickname], [g].[LeaderSquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) -ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] + ) AS [u0] ON [u].[FullName] = [u0].[FullName] +) AS [s] +ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( - bool async) + public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] - FROM [Officers] AS [o1] -) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u2].[Nickname], [u2].[SquadId] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName] - FROM [Officers] AS [o2] - ) AS [u2] ON [w].[OwnerFullName] = [u2].[FullName] -) AS [s] ON [u1].[FullName] = [s].[OwnerFullName] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) -ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[IsAutomatic], [s].[Nickname] DESC, [s].[Id] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( - bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId], [s].[Nickname], [s].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] - FROM [Officers] AS [o1] -) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [u2].[Nickname], [u2].[SquadId], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [u2].[FullName] IS NOT NULL AND [u2].[FullName] = [w0].[OwnerFullName]) AS [c] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName] - FROM [Officers] AS [o2] - ) AS [u2] ON [w].[OwnerFullName] = [u2].[FullName] -) AS [s] ON [u1].[FullName] = [s].[OwnerFullName] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) -ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id] DESC, [s].[c], [s].[Nickname] -"""); - } - - public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) - { - await base.Correlated_collections_multiple_nested_complex_collections(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Name], [s1].[IsAutomatic], [s1].[Id1], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00], [s2].[Id], [s2].[AmmunitionType], [s2].[IsAutomatic], [s2].[Name], [s2].[OwnerFullName], [s2].[SynergyWithId], [s2].[Nickname], [s2].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] - FROM [Officers] AS [o1] -) AS [u1] ON [t].[GearNickName] = [u1].[Nickname] AND [t].[GearSquadId] = [u1].[SquadId] -LEFT JOIN ( - SELECT [u2].[FullName], [u2].[Nickname], [u2].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Name], [s0].[IsAutomatic], [s0].[Id1], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [u2].[Rank], [s0].[IsAutomatic0], [u2].[LeaderNickname], [u2].[LeaderSquadId] - FROM ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[FullName], [o2].[LeaderNickname], [o2].[LeaderSquadId], [o2].[Rank] - FROM [Officers] AS [o2] - ) AS [u2] - LEFT JOIN ( - SELECT [w].[Id], [u3].[Nickname], [u3].[SquadId], [s].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [u4].[Nickname] AS [Nickname0], [u4].[HasSoulPatch], [u4].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] - FROM [Gears] AS [g2] - UNION ALL - SELECT [o3].[Nickname], [o3].[SquadId], [o3].[FullName] - FROM [Officers] AS [o3] - ) AS [u3] ON [w].[OwnerFullName] = [u3].[FullName] - LEFT JOIN [Squads] AS [s] ON [u3].[SquadId] = [s].[Id] - LEFT JOIN [Weapons] AS [w0] ON [u3].[FullName] = [w0].[OwnerFullName] - LEFT JOIN ( - SELECT [g3].[Nickname], [g3].[SquadId], [g3].[HasSoulPatch] - FROM [Gears] AS [g3] - UNION ALL - SELECT [o4].[Nickname], [o4].[SquadId], [o4].[HasSoulPatch] - FROM [Officers] AS [o4] - ) AS [u4] ON [s].[Id] = [u4].[SquadId] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [s0] ON [u2].[FullName] = [s0].[OwnerFullName] - WHERE [u2].[FullName] <> N'Foo' -) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] -LEFT JOIN ( - SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [u5].[Nickname], [u5].[SquadId] - FROM [Weapons] AS [w1] - LEFT JOIN ( - SELECT [g4].[Nickname], [g4].[SquadId], [g4].[FullName] - FROM [Gears] AS [g4] - UNION ALL - SELECT [o5].[Nickname], [o5].[SquadId], [o5].[FullName] - FROM [Officers] AS [o5] - ) AS [u5] ON [w1].[OwnerFullName] = [u5].[FullName] -) AS [s2] ON [u1].[FullName] = [s2].[OwnerFullName] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId]) -ORDER BY [u].[HasSoulPatch] DESC, [t].[Note], [u].[Nickname], [u].[SquadId], [t].[Id], [u1].[Nickname], [u1].[SquadId], [s1].[Rank], [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic0], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Id1], [s1].[Nickname00], [s1].[SquadId00], [s2].[IsAutomatic], [s2].[Nickname] DESC, [s2].[Id] -"""); - } - - public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) - { - await base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [u1].[ReportName], [u1].[OfficerName], [u1].[Nickname], [u1].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -OUTER APPLY ( - SELECT [u0].[FullName] AS [ReportName], [u].[FullName] AS [OfficerName], [u0].[Nickname], [u0].[SquadId] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -) AS [u1] -ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] -"""); - } - - public override async Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) - { - await base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [u1].[ReportName], [u1].[Nickname], [u1].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -OUTER APPLY ( - SELECT [u0].[FullName] AS [ReportName], [u0].[Nickname], [u0].[SquadId] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] AND [u].[FullName] <> N'Foo' -) AS [u1] -ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] -"""); - } - - public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) - { - await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id], [u0].[LeaderNickname], [u0].[LeaderSquadId] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - OUTER APPLY ( - SELECT [w].[Name], [u0].[Nickname], [w].[Id] - FROM [Weapons] AS [w] - WHERE [u0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) - ) AS [w0] - WHERE [u0].[FullName] <> N'Foo' -) AS [s] ON [u].[Nickname] = [s].[LeaderNickname] AND [u].[SquadId] = [s].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) - { - await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -OUTER APPLY ( - SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - LEFT JOIN ( - SELECT [w].[Name], [u].[Nickname], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] AND [u0].[FullName] <> N'Foo' -) AS [s] -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_on_select_many(bool async) - { - await base.Correlated_collections_on_select_many(async); - - AssertSql( - """ -SELECT [u].[Nickname], [s].[Name], [u].[SquadId], [s].[Id], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -CROSS JOIN [Squads] AS [s] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u0].[HasSoulPatch] = CAST(0 AS bit) -) AS [u1] ON [s].[Id] = [u1].[SquadId] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [u].[Nickname], [s].[Id] DESC, [u].[SquadId], [w0].[Id], [u1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Skip(bool async) - { - await base.Correlated_collections_with_Skip(async); - - AssertSql( - """ -SELECT [s].[Id], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname]) AS [row] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] - ) AS [u0] - WHERE 1 < [u0].[row] -) AS [u1] ON [s].[Id] = [u1].[SquadId] -ORDER BY [s].[Name], [s].[Id], [u1].[SquadId], [u1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Take(bool async) - { - await base.Correlated_collections_with_Take(async); - - AssertSql( - """ -SELECT [s].[Id], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname]) AS [row] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] - ) AS [u0] - WHERE [u0].[row] <= 2 -) AS [u1] ON [s].[Id] = [u1].[SquadId] -ORDER BY [s].[Name], [s].[Id], [u1].[SquadId], [u1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Distinct(bool async) - { - await base.Correlated_collections_with_Distinct(async); - - AssertSql( - """ -SELECT [s].[Id], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] -FROM [Squads] AS [s] -OUTER APPLY ( - SELECT DISTINCT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [s].[Id] = [u].[SquadId] - ORDER BY [u].[Nickname] - OFFSET 0 ROWS - ) AS [u0] -) AS [u1] -ORDER BY [s].[Name], [s].[Id], [u1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_FirstOrDefault(bool async) - { - await base.Correlated_collections_with_FirstOrDefault(async); - - AssertSql( - """ -SELECT ( - SELECT TOP(1) [u].[FullName] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] - ORDER BY [u].[Nickname]) -FROM [Squads] AS [s] -ORDER BY [s].[Name] -"""); - } - - public override async Task Correlated_collections_on_left_join_with_predicate(bool async) - { - await base.Correlated_collections_on_left_join_with_predicate(async); - - AssertSql( - """ -SELECT [u].[Nickname], [t].[Id], [u].[SquadId], [w].[Name], [w].[Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -WHERE [u].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId] -"""); - } - - public override async Task Correlated_collections_on_left_join_with_null_value(bool async) - { - await base.Correlated_collections_on_left_join_with_null_value(async); - - AssertSql( - """ -SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [w].[Name], [w].[Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [u].[Nickname], [u].[SquadId] -"""); - } - - public override async Task Correlated_collections_left_join_with_self_reference(bool async) - { - await base.Correlated_collections_left_join_with_self_reference(async); - - AssertSql( - """ -SELECT [t].[Note], [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[FullName], [u0].[Nickname], [u0].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] -) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[Nickname] -"""); - } - - public override async Task Correlated_collections_deeply_nested_left_join(bool async) - { - await base.Correlated_collections_deeply_nested_left_join(async); - - AssertSql( - """ -SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] -LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName], [g0].[HasSoulPatch] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[HasSoulPatch] - FROM [Officers] AS [o0] - ) AS [u0] - LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) - ) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] - WHERE [u0].[HasSoulPatch] = CAST(1 AS bit) -) AS [s0] ON [s].[Id] = [s0].[SquadId] -ORDER BY [t].[Note], [u].[Nickname] DESC, [t].[Id], [u].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId] -"""); - } - - public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) - { - await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); - - AssertSql( - """ -SELECT [w].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId], [s0].[Rank] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] ON [w].[OwnerFullName] = [u].[FullName] -LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [u0].[Rank], [u0].[FullName] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName], [g0].[Rank] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[Rank] - FROM [Officers] AS [o0] - ) AS [u0] - LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(0 AS bit) - ) AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -ORDER BY [w].[Name], [w].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s0].[FullName] DESC, [s0].[Nickname], [s0].[SquadId], [s0].[Id] -"""); - } - - public override async Task Correlated_collections_complex_scenario1(bool async) - { - await base.Correlated_collections_complex_scenario1(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [w].[Id], [u0].[Nickname], [u0].[SquadId], [s].[Id] AS [Id0], [u1].[Nickname] AS [Nickname0], [u1].[HasSoulPatch], [u1].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] ON [w].[OwnerFullName] = [u0].[FullName] - LEFT JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[HasSoulPatch] - FROM [Officers] AS [o1] - ) AS [u1] ON [s].[Id] = [u1].[SquadId] -) AS [s0] ON [u].[FullName] = [s0].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] -"""); - } - - public override async Task Correlated_collections_complex_scenario2(bool async) - { - await base.Correlated_collections_complex_scenario2(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [u0].[LeaderNickname], [u0].[LeaderSquadId] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - LEFT JOIN ( - SELECT [w].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id] AS [Id0], [u2].[Nickname] AS [Nickname0], [u2].[HasSoulPatch], [u2].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] - FROM [Officers] AS [o1] - ) AS [u1] ON [w].[OwnerFullName] = [u1].[FullName] - LEFT JOIN [Squads] AS [s] ON [u1].[SquadId] = [s].[Id] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[HasSoulPatch] - FROM [Officers] AS [o2] - ) AS [u2] ON [s].[Id] = [u2].[SquadId] - ) AS [s0] ON [u0].[FullName] = [s0].[OwnerFullName] -) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] -ORDER BY [u].[Nickname], [u].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] -"""); - } - - public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) - { - await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0], [s0].[HasSoulPatch], [s0].[SquadId0] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [w].[Id], [u0].[Nickname], [u0].[SquadId], [s].[Id] AS [Id0], [u1].[Nickname] AS [Nickname0], [u1].[HasSoulPatch], [u1].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] ON [w].[OwnerFullName] = [u0].[FullName] - LEFT JOIN [Squads] AS [s] ON [u0].[SquadId] = [s].[Id] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[HasSoulPatch] - FROM [Officers] AS [o1] - ) AS [u1] ON [s].[Id] = [u1].[SquadId] -) AS [s0] ON [u].[FullName] = [s0].[OwnerFullName] -ORDER BY [u].[FullName], [u].[Nickname] DESC, [u].[SquadId], [s0].[Id], [s0].[Nickname], [s0].[SquadId], [s0].[Id0], [s0].[Nickname0] -"""); - } - - public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) - { - await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); - - AssertSql( - """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [s1].[FullName], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00], [s1].[HasSoulPatch], [s1].[SquadId00] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [u0].[FullName], [u0].[Nickname], [u0].[SquadId], [s0].[Id], [s0].[Nickname] AS [Nickname0], [s0].[SquadId] AS [SquadId0], [s0].[Id0], [s0].[Nickname0] AS [Nickname00], [s0].[HasSoulPatch], [s0].[SquadId0] AS [SquadId00], [u0].[HasSoulPatch] AS [HasSoulPatch0], [s0].[IsAutomatic], [s0].[Name], [u0].[LeaderNickname], [u0].[LeaderSquadId] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u0] - LEFT JOIN ( - SELECT [w].[Id], [u1].[Nickname], [u1].[SquadId], [s].[Id] AS [Id0], [u2].[Nickname] AS [Nickname0], [u2].[HasSoulPatch], [u2].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[FullName] - FROM [Officers] AS [o1] - ) AS [u1] ON [w].[OwnerFullName] = [u1].[FullName] - LEFT JOIN [Squads] AS [s] ON [u1].[SquadId] = [s].[Id] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[HasSoulPatch] - FROM [Gears] AS [g1] - UNION ALL - SELECT [o2].[Nickname], [o2].[SquadId], [o2].[HasSoulPatch] - FROM [Officers] AS [o2] - ) AS [u2] ON [s].[Id] = [u2].[SquadId] - ) AS [s0] ON [u0].[FullName] = [s0].[OwnerFullName] -) AS [s1] ON [u].[Nickname] = [s1].[LeaderNickname] AND [u].[SquadId] = [s1].[LeaderSquadId] -ORDER BY [u].[HasSoulPatch], [u].[LeaderNickname], [u].[FullName], [u].[Nickname], [u].[SquadId], [s1].[FullName], [s1].[HasSoulPatch0] DESC, [s1].[Nickname], [s1].[SquadId], [s1].[IsAutomatic], [s1].[Name] DESC, [s1].[Id], [s1].[Nickname0], [s1].[SquadId0], [s1].[Id0], [s1].[Nickname00] -"""); - } - - public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) - { - await base.Correlated_collection_with_top_level_FirstOrDefault(async); - - AssertSql( - """ -SELECT [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] - ORDER BY [u].[Nickname] -) AS [u0] -LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] -ORDER BY [u0].[Nickname], [u0].[SquadId] -"""); - } - - public override async Task Correlated_collection_with_top_level_Count(bool async) - { - await base.Correlated_collection_with_top_level_Count(async); - - AssertSql( - """ -SELECT COUNT(*) -FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Officers] AS [o] -) AS [u] -"""); - } - - public override async Task Correlated_collection_with_top_level_Last_with_orderby_on_outer(bool async) - { - await base.Correlated_collection_with_top_level_Last_with_orderby_on_outer(async); - - AssertSql( - """ -SELECT [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] - ORDER BY [u].[FullName] -) AS [u0] -LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] -ORDER BY [u0].[FullName], [u0].[Nickname], [u0].[SquadId] -"""); - } - - public override async Task Correlated_collection_with_top_level_Last_with_order_by_on_inner(bool async) - { - await base.Correlated_collection_with_top_level_Last_with_order_by_on_inner(async); - - AssertSql( - """ -SELECT [u0].[Nickname], [u0].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] - ORDER BY [u].[FullName] DESC -) AS [u0] -LEFT JOIN [Weapons] AS [w] ON [u0].[FullName] = [w].[OwnerFullName] -ORDER BY [u0].[FullName] DESC, [u0].[Nickname], [u0].[SquadId], [w].[Name] -"""); - } - - public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) - { - await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); - - AssertSql( - """ -SELECT [l2].[Id], [l2].[CapitalName], [l2].[Name], [l2].[ServerAddress], [l2].[CommanderName], [l2].[Eradicated] -FROM ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name] - FROM [LocustCommanders] AS [l0] -) AS [u] -INNER JOIN ( - SELECT [l1].[Id], [l1].[CapitalName], [l1].[Name], [l1].[ServerAddress], [l1].[CommanderName], [l1].[Eradicated] - FROM [LocustHordes] AS [l1] - WHERE [l1].[Name] = N'Swarm' -) AS [l2] ON [u].[Name] = [l2].[CommanderName] -WHERE [l2].[Eradicated] = CAST(0 AS bit) OR [l2].[Eradicated] IS NULL -"""); - } - - public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) - { - await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); - - AssertSql( - """ -SELECT [l2].[Id], [l2].[CapitalName], [l2].[Name], [l2].[ServerAddress], [l2].[CommanderName], [l2].[Eradicated] -FROM ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name] - FROM [LocustCommanders] AS [l0] -) AS [u] -LEFT JOIN ( - SELECT [l1].[Id], [l1].[CapitalName], [l1].[Name], [l1].[ServerAddress], [l1].[CommanderName], [l1].[Eradicated] - FROM [LocustHordes] AS [l1] - WHERE [l1].[Name] = N'Swarm' -) AS [l2] ON [u].[Name] = [l2].[CommanderName] -WHERE [l2].[Eradicated] = CAST(0 AS bit) OR [l2].[Eradicated] IS NULL -"""); - } - - public override async Task Include_on_derived_type_with_order_by_and_paging(bool async) - { - await base.Include_on_derived_type_with_order_by_and_paging(async); - - AssertSql( - """ -@p='10' - -SELECT [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator0] AS [Discriminator], [s].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(@p) [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] AS [Discriminator0], [t].[Id], [t].[Note] - FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] - ) AS [u] - LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] - LEFT JOIN [Tags] AS [t] ON ([u0].[Nickname] = [t].[GearNickName] OR ([u0].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([u0].[SquadId] = [t].[GearSquadId] OR ([u0].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) - ORDER BY [t].[Note] -) AS [s] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [s].[Note], [s].[Name], [s].[Nickname], [s].[SquadId], [s].[Id] -"""); - } - - public override async Task Select_required_navigation_on_derived_type(bool async) - { - await base.Select_required_navigation_on_derived_type(async); - - AssertSql( - """ -SELECT [l1].[Name] -FROM ( - SELECT NULL AS [HighCommandId] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[HighCommandId] - FROM [LocustCommanders] AS [l0] -) AS [u] -LEFT JOIN [LocustHighCommands] AS [l1] ON [u].[HighCommandId] = [l1].[Id] -"""); - } - - public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) - { - await base.Select_required_navigation_on_the_same_type_with_cast(async); - - AssertSql( - """ -SELECT [c].[Name] -FROM ( - SELECT [g].[CityOfBirthName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[CityOfBirthName] - FROM [Officers] AS [o] -) AS [u] -INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -"""); - } - - public override async Task Where_required_navigation_on_derived_type(bool async) - { - await base.Where_required_navigation_on_derived_type(async); - - AssertSql( - """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -LEFT JOIN [LocustHighCommands] AS [l1] ON [u].[HighCommandId] = [l1].[Id] -WHERE [l1].[IsOperational] = CAST(1 AS bit) -"""); - } - - public override async Task Outer_parameter_in_join_key(bool async) - { - await base.Outer_parameter_in_join_key(async); - - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [u0].[Nickname], [u0].[SquadId] - FROM [Tags] AS [t] - INNER JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] ON [u].[FullName] = [u0].[FullName] -) AS [s] -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] -"""); - } - - public override async Task Outer_parameter_in_join_key_inner_and_outer(bool async) - { - await base.Outer_parameter_in_join_key_inner_and_outer(async); - - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [u0].[Nickname], [u0].[SquadId] - FROM [Tags] AS [t] - INNER JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] - ) AS [u0] ON [u].[FullName] = [u].[Nickname] -) AS [s] -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] -"""); - } - - public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) - { - await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); - - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [s].[Note], [s].[Id], [s].[Nickname], [s].[SquadId] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [u0].[Nickname], [u0].[SquadId] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] ON [u].[FullName] = [u0].[FullName] -) AS [s] -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] -"""); - } - - public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) - { - await base.Negated_bool_ternary_inside_anonymous_type_in_projection(async); - - AssertSql( - """ -SELECT ~CASE - WHEN [u].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE COALESCE([u].[HasSoulPatch], CAST(1 AS bit)) -END AS [c] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -"""); - } - - public override async Task Order_by_entity_qsre(bool async) - { - await base.Order_by_entity_qsre(async); - - AssertSql( - """ -SELECT [u].[FullName] -FROM ( - SELECT [g].[Nickname], [g].[AssignedCityName], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[AssignedCityName], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] -ORDER BY [c].[Name], [u].[Nickname] DESC -"""); - } - - public override async Task Order_by_entity_qsre_with_inheritance(bool async) - { - await base.Order_by_entity_qsre_with_inheritance(async); - - AssertSql( - """ -SELECT [u].[Name] -FROM ( - SELECT [l].[Name], [l].[HighCommandId] - FROM [LocustCommanders] AS [l] -) AS [u] -INNER JOIN [LocustHighCommands] AS [l0] ON [u].[HighCommandId] = [l0].[Id] -ORDER BY [l0].[Id], [u].[Name] -"""); - } - - public override async Task Order_by_entity_qsre_composite_key(bool async) - { - await base.Order_by_entity_qsre_composite_key(async); - - AssertSql( - """ -SELECT [w].[Name] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] ON [w].[OwnerFullName] = [u].[FullName] -ORDER BY [u].[Nickname], [u].[SquadId], [w].[Id] -"""); - } - - public override async Task Order_by_entity_qsre_with_other_orderbys(bool async) - { - await base.Order_by_entity_qsre_with_other_orderbys(async); - - AssertSql( - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] ON [w].[OwnerFullName] = [u].[FullName] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w].[IsAutomatic], [u].[Nickname] DESC, [u].[SquadId] DESC, [w0].[Id], [w].[Name] -"""); - } - - public override async Task Join_on_entity_qsre_keys(bool async) - { - await base.Join_on_entity_qsre_keys(async); - - AssertSql( - """ -SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] -FROM [Weapons] AS [w] -INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id] -"""); - } - - public override async Task Join_on_entity_qsre_keys_composite_key(bool async) - { - await base.Join_on_entity_qsre_keys_composite_key(async); - - AssertSql( - """ -SELECT [u].[FullName] AS [GearName1], [u0].[FullName] AS [GearName2] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inheritance(bool async) - { - await base.Join_on_entity_qsre_keys_inheritance(async); - - AssertSql( - """ -SELECT [u].[FullName] AS [GearName], [u0].[FullName] AS [OfficerName] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -INNER JOIN ( - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] -"""); - } - - public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_outer_key_is_navigation(async); - - AssertSql( - """ -SELECT [w].[Name] AS [Name1], [w1].[Name] AS [Name2] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -INNER JOIN [Weapons] AS [w1] ON [w0].[Id] = [w1].[Id] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_inner_key_is_navigation(async); - - AssertSql( - """ -SELECT [c].[Name] AS [CityName], [s].[Nickname] AS [GearNickname] -FROM [Cities] AS [c] -INNER JOIN ( - SELECT [u].[Nickname], [c0].[Name] - FROM ( - SELECT [g].[Nickname], [g].[AssignedCityName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[AssignedCityName] - FROM [Officers] AS [o] - ) AS [u] - LEFT JOIN [Cities] AS [c0] ON [u].[AssignedCityName] = [c0].[Name] -) AS [s] ON [c].[Name] = [s].[Name] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) - { - await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); - - AssertSql( - """ -SELECT [u].[Nickname], [s].[Note] -FROM ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] -INNER JOIN ( - SELECT [t].[Note], [u0].[Nickname], [u0].[SquadId] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId] - FROM [Officers] AS [o0] - ) AS [u0] ON [t].[GearNickName] = [u0].[Nickname] AND [t].[GearSquadId] = [u0].[SquadId] - WHERE [t].[Note] IN (N'Cole''s Tag', N'Dom''s Tag') -) AS [s] ON [u].[Nickname] = [s].[Nickname] AND [u].[SquadId] = [s].[SquadId] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_inner_key_is_nested_navigation(async); - - AssertSql( - """ -SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] -FROM [Squads] AS [s] -INNER JOIN ( - SELECT [w].[Name], [s0].[Id] AS [Id0] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] ON [w].[OwnerFullName] = [u].[FullName] - LEFT JOIN [Squads] AS [s0] ON [u].[SquadId] = [s0].[Id] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [s1] ON [s].[Id] = [s1].[Id0] -"""); - } - - public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) - { - await base.GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(async); - - AssertSql( - """ -SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [w].[Name], [s0].[Id] AS [Id0] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] ON [w].[OwnerFullName] = [u].[FullName] - LEFT JOIN [Squads] AS [s0] ON [u].[SquadId] = [s0].[Id] -) AS [s1] ON [s].[Id] = [s1].[Id0] -"""); - } - - public override async Task Streaming_correlated_collection_issue_11403(bool async) - { - await base.Streaming_correlated_collection_issue_11403(async); - - AssertSql( - """ -SELECT [u0].[Nickname], [u0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM ( - SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] - ORDER BY [u].[Nickname] -) AS [u0] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(0 AS bit) -) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] -ORDER BY [u0].[Nickname], [u0].[SquadId], [w0].[Id] -"""); - } - - public override async Task Project_one_value_type_from_empty_collection(bool async) - { - await base.Project_one_value_type_from_empty_collection(async); - - AssertSql( - """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) [u].[SquadId] - FROM ( - SELECT [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' -"""); - } - - public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) - { - await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); - - AssertSql( - """ -SELECT [s].[Name], ( - SELECT TOP(1) [u].[SquadId] - FROM ( - SELECT [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' -"""); - } - - public override async Task Project_one_value_type_with_client_projection_from_empty_collection(bool async) - { - await base.Project_one_value_type_with_client_projection_from_empty_collection(async); - - AssertSql( - """ -SELECT [s].[Name], [u1].[SquadId], [u1].[LeaderSquadId], [u1].[c] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u0].[SquadId], [u0].[LeaderSquadId], [u0].[c] - FROM ( - SELECT [u].[SquadId], [u].[LeaderSquadId], 1 AS [c], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch], [g].[LeaderSquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch], [o].[LeaderSquadId] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(1 AS bit) - ) AS [u0] - WHERE [u0].[row] <= 1 -) AS [u1] ON [s].[Id] = [u1].[SquadId] -WHERE [s].[Name] = N'Kilo' -"""); - } - - public override async Task Filter_on_subquery_projecting_one_value_type_from_empty_collection(bool async) - { - await base.Filter_on_subquery_projecting_one_value_type_from_empty_collection(async); - - AssertSql( - """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' AND COALESCE(( - SELECT TOP(1) [u].[SquadId] - FROM ( - SELECT [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 -"""); - } - - public override async Task Select_subquery_projecting_single_constant_int(bool async) - { - await base.Select_subquery_projecting_single_constant_int(async); - - AssertSql( - """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) 42 - FROM ( - SELECT [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] -FROM [Squads] AS [s] -"""); - } - - public override async Task Select_subquery_projecting_single_constant_string(bool async) - { - await base.Select_subquery_projecting_single_constant_string(async); - - AssertSql( - """ -SELECT [s].[Name], ( - SELECT TOP(1) N'Foo' - FROM ( - SELECT [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] -FROM [Squads] AS [s] -"""); - } - - public override async Task Select_subquery_projecting_single_constant_bool(bool async) - { - await base.Select_subquery_projecting_single_constant_bool(async); - - AssertSql( - """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) CAST(1 AS bit) - FROM ( - SELECT [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] -FROM [Squads] AS [s] -"""); - } - - public override async Task Select_subquery_projecting_single_constant_inside_anonymous(bool async) - { - await base.Select_subquery_projecting_single_constant_inside_anonymous(async); - - AssertSql( - """ -SELECT [s].[Name], [u1].[One] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u0].[One], [u0].[SquadId] - FROM ( - SELECT 1 AS [One], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(1 AS bit) - ) AS [u0] - WHERE [u0].[row] <= 1 -) AS [u1] ON [s].[Id] = [u1].[SquadId] -"""); - } - - public override async Task Select_subquery_projecting_multiple_constants_inside_anonymous(bool async) - { - await base.Select_subquery_projecting_multiple_constants_inside_anonymous(async); - - AssertSql( - """ -SELECT [s].[Name], [u1].[True1], [u1].[False1], [u1].[c] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u0].[True1], [u0].[False1], [u0].[c], [u0].[SquadId] - FROM ( - SELECT CAST(1 AS bit) AS [True1], CAST(0 AS bit) AS [False1], 1 AS [c], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(1 AS bit) - ) AS [u0] - WHERE [u0].[row] <= 1 -) AS [u1] ON [s].[Id] = [u1].[SquadId] -"""); - } - - public override async Task Include_with_order_by_constant(bool async) - { - await base.Include_with_order_by_constant(async); + await base.Negated_bool_ternary_inside_anonymous_type_in_projection(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM [Squads] AS [s] +SELECT ~CASE + WHEN [u].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE COALESCE([u].[HasSoulPatch], CAST(1 AS bit)) +END AS [c] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] ON [s].[Id] = [u].[SquadId] -ORDER BY [s].[Id], [u].[Nickname] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Correlated_collection_order_by_constant(bool async) + public override async Task Order_by_entity_qsre(bool async) { - await base.Correlated_collection_order_by_constant(async); + await base.Order_by_entity_qsre(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w].[Name], [w].[Id] +SELECT [u].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + SELECT [g].[Nickname], [g].[AssignedCityName], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId] -"""); - } - - public override async Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool async) - { - await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(async); - - AssertSql( - """ -SELECT [s].[Name], [u1].[c] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u0].[c], [u0].[SquadId] - FROM ( - SELECT 1 AS [c], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(1 AS bit) - ) AS [u0] - WHERE [u0].[row] <= 1 -) AS [u1] ON [s].[Id] = [u1].[SquadId] -"""); - } - - public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool async) - { - await base.Select_subquery_projecting_single_constant_of_non_mapped_type(async); - - AssertSql( - """ -SELECT [s].[Name], [u1].[c] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u0].[c], [u0].[SquadId] - FROM ( - SELECT 1 AS [c], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [u].[HasSoulPatch] = CAST(1 AS bit) - ) AS [u0] - WHERE [u0].[row] <= 1 -) AS [u1] ON [s].[Id] = [u1].[SquadId] -"""); - } - - public override async Task Include_collection_OrderBy_aggregate(bool async) - { - await base.Include_collection_OrderBy_aggregate(async); - - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[AssignedCityName], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]), [u].[Nickname], [u].[SquadId], [u0].[Nickname] +LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] +ORDER BY [c].[Name], [u].[Nickname] DESC """); } - public override async Task Include_collection_with_complex_OrderBy2(bool async) + public override async Task Order_by_entity_qsre_with_inheritance(bool async) { - await base.Include_collection_with_complex_OrderBy2(async); + await base.Order_by_entity_qsre_with_inheritance(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[Name] FROM ( - 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] + SELECT [l].[Name], [l].[HighCommandId] + FROM [LocustCommanders] AS [l] ) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), [u].[Nickname], [u].[SquadId], [u0].[Nickname] +INNER JOIN [LocustHighCommands] AS [l0] ON [u].[HighCommandId] = [l0].[Id] +ORDER BY [l0].[Id], [u].[Name] """); } - public override async Task Include_collection_with_complex_OrderBy3(bool async) + public override async Task Order_by_entity_qsre_composite_key(bool async) { - await base.Include_collection_with_complex_OrderBy3(async); + await base.Order_by_entity_qsre_composite_key(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM ( - 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] +SELECT [w].[Name] +FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -ORDER BY COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)), [u].[Nickname], [u].[SquadId], [u0].[Nickname] -"""); - } - - public override async Task Correlated_collection_with_complex_OrderBy(bool async) - { - await base.Correlated_collection_with_complex_OrderBy(async); - - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] -FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u0].[HasSoulPatch] = CAST(0 AS bit) -) AS [u1] ON [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]), [u].[Nickname], [u].[SquadId], [u1].[Nickname] -"""); - } - - public override async Task Correlated_collection_with_very_complex_order_by(bool async) - { - await base.Correlated_collection_with_very_complex_order_by(async); - - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] -FROM ( SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o1] - ) AS [u1] - WHERE [u1].[HasSoulPatch] = CAST(0 AS bit) -) AS [u2] ON [u].[Nickname] = [u2].[LeaderNickname] AND [u].[SquadId] = [u2].[LeaderSquadId] -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( - SELECT TOP(1) [u0].[HasSoulPatch] - FROM ( - SELECT [g].[Nickname], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o0].[Nickname], [o0].[HasSoulPatch] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [u0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [u].[Nickname], [u].[SquadId], [u2].[Nickname] -"""); - } - - public override async Task Cast_to_derived_type_after_OfType_works(bool async) - { - await base.Cast_to_derived_type_after_OfType_works(async); - - AssertSql( - """ -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] ON [w].[OwnerFullName] = [u].[FullName] +ORDER BY [u].[Nickname], [u].[SquadId], [w].[Id] """); } - public override async Task Select_subquery_boolean(bool async) + public override async Task Order_by_entity_qsre_with_other_orderbys(bool async) { - await base.Select_subquery_boolean(async); + await base.Order_by_entity_qsre_with_other_orderbys(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)) -FROM ( - SELECT [g].[FullName] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] +) AS [u] ON [w].[OwnerFullName] = [u].[FullName] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w].[IsAutomatic], [u].[Nickname] DESC, [u].[SquadId] DESC, [w0].[Id], [w].[Name] """); } - public override async Task Select_subquery_boolean_with_pushdown(bool async) + public override async Task Join_on_entity_qsre_keys(bool async) { - await base.Select_subquery_boolean_with_pushdown(async); + await base.Join_on_entity_qsre_keys(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) -FROM ( - SELECT [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName] - FROM [Officers] AS [o] -) AS [u] +SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] +FROM [Weapons] AS [w] +INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id] """); } - public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) + public override async Task Join_on_entity_qsre_keys_composite_key(bool async) { - await base.Select_subquery_int_with_inside_cast_and_coalesce(async); + await base.Join_on_entity_qsre_keys_composite_key(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 42) +SELECT [u].[FullName] AS [GearName1], [u0].[FullName] AS [GearName2] FROM ( - SELECT [g].[FullName] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] +INNER JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] """); } - public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bool async) + public override async Task Join_on_entity_qsre_keys_inheritance(bool async) { - await base.Select_subquery_int_with_outside_cast_and_coalesce(async); + await base.Join_on_entity_qsre_keys_inheritance(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 0) +SELECT [u].[FullName] AS [GearName], [u0].[FullName] AS [OfficerName] FROM ( - SELECT [g].[FullName] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] +INNER JOIN ( + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] """); } - public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool async) + public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool async) { - await base.Select_subquery_int_with_pushdown_and_coalesce(async); + await base.Join_on_entity_qsre_keys_outer_key_is_navigation(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 42) -FROM ( - SELECT [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName] - FROM [Officers] AS [o] -) AS [u] +SELECT [w].[Name] AS [Name1], [w1].[Name] AS [Name2] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +INNER JOIN [Weapons] AS [w1] ON [w0].[Id] = [w1].[Id] """); } - public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool async) { - await base.Select_subquery_int_with_pushdown_and_coalesce2(async); + await base.Join_on_entity_qsre_keys_inner_key_is_navigation(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), ( - SELECT TOP(1) [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [u].[FullName] = [w0].[OwnerFullName] - ORDER BY [w0].[Id])) -FROM ( - SELECT [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName] - FROM [Officers] AS [o] -) AS [u] +SELECT [c].[Name] AS [CityName], [s].[Nickname] AS [GearNickname] +FROM [Cities] AS [c] +INNER JOIN ( + SELECT [u].[Nickname], [c0].[Name] + FROM ( + SELECT [g].[Nickname], [g].[AssignedCityName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[AssignedCityName] + FROM [Officers] AS [o] + ) AS [u] + LEFT JOIN [Cities] AS [c0] ON [u].[AssignedCityName] = [c0].[Name] +) AS [s] ON [c].[Name] = [s].[Name] """); } - public override async Task Select_subquery_boolean_empty(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) { - await base.Select_subquery_boolean_empty(async); + await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ORDER BY [w].[Id]), CAST(0 AS bit)) +SELECT [u].[Nickname], [s].[Note] FROM ( - SELECT [g].[FullName] + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] +INNER JOIN ( + SELECT [t].[Note], [u0].[Nickname], [u0].[SquadId] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId] + FROM [Officers] AS [o0] + ) AS [u0] ON [t].[GearNickName] = [u0].[Nickname] AND [t].[GearSquadId] = [u0].[SquadId] + WHERE [t].[Note] IN (N'Cole''s Tag', N'Dom''s Tag') +) AS [s] ON [u].[Nickname] = [s].[Nickname] AND [u].[SquadId] = [s].[SquadId] """); } - public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { - await base.Select_subquery_boolean_empty_with_pushdown(async); + await base.Join_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w].[IsAutomatic] +SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] +FROM [Squads] AS [s] +INNER JOIN ( + SELECT [w].[Name], [s0].[Id] AS [Id0] FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ORDER BY [w].[Id]) -FROM ( - SELECT [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName] - FROM [Officers] AS [o] -) AS [u] + LEFT JOIN ( + SELECT [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] ON [w].[OwnerFullName] = [u].[FullName] + LEFT JOIN [Squads] AS [s0] ON [u].[SquadId] = [s0].[Id] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [s1] ON [s].[Id] = [s1].[Id0] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) + public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean1(async); + await base.GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]), CAST(0 AS bit)) -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +SELECT [s].[Name] AS [SquadName], [s1].[Name] AS [WeaponName] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [w].[Name], [s0].[Id] AS [Id0] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] ON [w].[OwnerFullName] = [u].[FullName] + LEFT JOIN [Squads] AS [s0] ON [u].[SquadId] = [s0].[Id] +) AS [s1] ON [s].[Id] = [s1].[Id0] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean2(bool async) + public override async Task Streaming_correlated_collection_issue_11403(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean2(async); + await base.Streaming_correlated_collection_issue_11403(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) +SELECT [u0].[Nickname], [u0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + SELECT TOP(1) [u].[Nickname], [u].[SquadId], [u].[FullName] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] + ORDER BY [u].[Nickname] +) AS [u0] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(0 AS bit) +) AS [w0] ON [u0].[FullName] = [w0].[OwnerFullName] +ORDER BY [u0].[Nickname], [u0].[SquadId], [w0].[Id] +"""); + } + + public override async Task Project_one_value_type_from_empty_collection(bool async) + { + await base.Project_one_value_type_from_empty_collection(async); + + AssertSql( + """ +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) [u].[SquadId] + FROM ( + SELECT [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) + public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_with_pushdown(async); + await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[IsAutomatic] +SELECT [s].[Name], ( + SELECT TOP(1) [u].[SquadId] FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]) -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + SELECT [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty1(bool async) + public override async Task Project_one_value_type_with_client_projection_from_empty_collection(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty1(async); + await base.Project_one_value_type_with_client_projection_from_empty_collection(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] +SELECT [s].[Name], [u1].[SquadId], [u1].[LeaderSquadId], [u1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [u0].[SquadId], [u0].[LeaderSquadId], [u0].[c] FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ) AS [w0]), CAST(0 AS bit)) -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + SELECT [u].[SquadId], [u].[LeaderSquadId], 1 AS [c], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch], [o].[LeaderSquadId] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + ) AS [u0] + WHERE [u0].[row] <= 1 +) AS [u1] ON [s].[Id] = [u1].[SquadId] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty2(bool async) + public override async Task Filter_on_subquery_projecting_one_value_type_from_empty_collection(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty2(async); + await base.Filter_on_subquery_projecting_one_value_type_from_empty_collection(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG'), CAST(0 AS bit)) -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' AND COALESCE(( + SELECT TOP(1) [u].[SquadId] + FROM ( + SELECT [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) + public override async Task Select_subquery_projecting_single_constant_int(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); + await base.Select_subquery_projecting_single_constant_int(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[IsAutomatic] +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) 42 FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ) AS [w0]) -FROM ( - SELECT [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + SELECT [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool async) + public override async Task Select_subquery_projecting_single_constant_string(bool async) { - await base.Cast_subquery_to_base_type_using_typed_ToList(async); + await base.Select_subquery_projecting_single_constant_string(async); AssertSql( """ -SELECT [c].[Name], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Nickname], [u].[Rank], [u].[SquadId] -FROM [Cities] AS [c] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank] - FROM [Officers] AS [o] -) AS [u] ON [c].[Name] = [u].[AssignedCityName] -WHERE [c].[Name] = N'Ephyra' -ORDER BY [c].[Name], [u].[Nickname] +SELECT [s].[Name], ( + SELECT TOP(1) N'Foo' + FROM ( + SELECT [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArray(bool async) + public override async Task Select_subquery_projecting_single_constant_bool(bool async) { - await base.Cast_ordered_subquery_to_base_type_using_typed_ToArray(async); + await base.Select_subquery_projecting_single_constant_bool(async); AssertSql( """ -SELECT [c].[Name], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Nickname], [u].[Rank], [u].[SquadId] -FROM [Cities] AS [c] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank] - FROM [Officers] AS [o] -) AS [u] ON [c].[Name] = [u].[AssignedCityName] -WHERE [c].[Name] = N'Ephyra' -ORDER BY [c].[Name], [u].[Nickname] DESC +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) CAST(1 AS bit) + FROM ( + SELECT [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) + public override async Task Select_subquery_projecting_single_constant_inside_anonymous(bool async) { - await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); + await base.Select_subquery_projecting_single_constant_inside_anonymous(async); AssertSql( """ -@nicknames='[]' (Size = 4000) - -SELECT [u].[Nickname], [u].[SquadId], [w].[Name], [w].[Id] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY CASE - WHEN [u].[Nickname] IN ( - SELECT [n].[value] - FROM OPENJSON(@nicknames) WITH ([value] nvarchar(450) '$') AS [n] - ) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END DESC, [u].[Nickname], [u].[SquadId] +SELECT [s].[Name], [u1].[One] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [u0].[One], [u0].[SquadId] + FROM ( + SELECT 1 AS [One], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + ) AS [u0] + WHERE [u0].[row] <= 1 +) AS [u1] ON [s].[Id] = [u1].[SquadId] """); } - public override async Task Double_order_by_on_nullable_bool_coming_from_optional_navigation(bool async) + public override async Task Select_subquery_projecting_multiple_constants_inside_anonymous(bool async) { - await base.Double_order_by_on_nullable_bool_coming_from_optional_navigation(async); + await base.Select_subquery_projecting_multiple_constants_inside_anonymous(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w0].[IsAutomatic], [w0].[Id] +SELECT [s].[Name], [u1].[True1], [u1].[False1], [u1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [u0].[True1], [u0].[False1], [u0].[c], [u0].[SquadId] + FROM ( + SELECT CAST(1 AS bit) AS [True1], CAST(0 AS bit) AS [False1], 1 AS [c], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + ) AS [u0] + WHERE [u0].[row] <= 1 +) AS [u1] ON [s].[Id] = [u1].[SquadId] """); } - public override async Task Double_order_by_on_Like(bool async) + public override async Task Include_with_order_by_constant(bool async) { - await base.Double_order_by_on_Like(async); + await base.Include_with_order_by_constant(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] LIKE N'%Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] ON [s].[Id] = [u].[SquadId] +ORDER BY [s].[Id], [u].[Nickname] """); } - public override async Task Double_order_by_on_is_null(bool async) + public override async Task Correlated_collection_order_by_constant(bool async) { - await base.Double_order_by_on_is_null(async); + await base.Correlated_collection_order_by_constant(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [u].[Nickname], [u].[SquadId], [w].[Name], [w].[Id] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Double_order_by_on_string_compare(bool async) + public override async Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool async) { - await base.Double_order_by_on_string_compare(async); + await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -ORDER BY CASE - WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w].[Id] +SELECT [s].[Name], [u1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [u0].[c], [u0].[SquadId] + FROM ( + SELECT 1 AS [c], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + ) AS [u0] + WHERE [u0].[row] <= 1 +) AS [u1] ON [s].[Id] = [u1].[SquadId] """); } - public override async Task Double_order_by_binary_expression(bool async) + public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool async) { - await base.Double_order_by_binary_expression(async); + await base.Select_subquery_projecting_single_constant_of_non_mapped_type(async); AssertSql( """ -SELECT [w].[Id] + 2 AS [Binary] -FROM [Weapons] AS [w] -ORDER BY [w].[Id] + 2 +SELECT [s].[Name], [u1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [u0].[c], [u0].[SquadId] + FROM ( + SELECT 1 AS [c], [u].[SquadId], ROW_NUMBER() OVER(PARTITION BY [u].[SquadId] ORDER BY [u].[Nickname], [u].[SquadId]) AS [row] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [u].[HasSoulPatch] = CAST(1 AS bit) + ) AS [u0] + WHERE [u0].[row] <= 1 +) AS [u1] ON [s].[Id] = [u1].[SquadId] """); } - public override async Task String_compare_with_null_conditional_argument(bool async) + public override async Task Include_collection_OrderBy_aggregate(bool async) { - await base.String_compare_with_null_conditional_argument(async); + await base.Include_collection_OrderBy_aggregate(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM ( + 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] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]), [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task String_compare_with_null_conditional_argument2(bool async) + public override async Task Include_collection_with_complex_OrderBy2(bool async) { - await base.String_compare_with_null_conditional_argument2(async); + await base.Include_collection_with_complex_OrderBy2(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM ( + 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] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task String_concat_with_null_conditional_argument(bool async) + public override async Task Include_collection_with_complex_OrderBy3(bool async) { - await base.String_concat_with_null_conditional_argument(async); + await base.Include_collection_with_complex_OrderBy3(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY COALESCE([w0].[Name], N'') + CAST(5 AS nvarchar(max)) +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM ( + 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] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +ORDER BY COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)), [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task String_concat_with_null_conditional_argument2(bool async) + public override async Task Correlated_collection_with_complex_OrderBy(bool async) { - await base.String_concat_with_null_conditional_argument2(async); + await base.Correlated_collection_with_complex_OrderBy(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY COALESCE([w0].[Name], N'') + N'Marcus'' Lancer' +SELECT [u].[Nickname], [u].[SquadId], [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] +FROM ( + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u0].[HasSoulPatch] = CAST(0 AS bit) +) AS [u1] ON [u].[Nickname] = [u1].[LeaderNickname] AND [u].[SquadId] = [u1].[LeaderSquadId] +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]), [u].[Nickname], [u].[SquadId], [u1].[Nickname] """); } - public override async Task String_concat_on_various_types(bool async) + public override async Task Correlated_collection_with_very_complex_order_by(bool async) { - await base.String_concat_on_various_types(async); + await base.Correlated_collection_with_very_complex_order_by(async); AssertSql( """ -SELECT N'HasSoulPatch ' + CAST([u].[HasSoulPatch] AS nvarchar(max)) + N' HasSoulPatch' AS [HasSoulPatch], N'Rank ' + CAST([u].[Rank] AS nvarchar(max)) + N' Rank' AS [Rank], N'SquadId ' + CAST([u].[SquadId] AS nvarchar(max)) + N' SquadId' AS [SquadId], N'Rating ' + COALESCE(CAST([m].[Rating] AS nvarchar(max)), N'') + N' Rating' AS [Rating], N'Timeline ' + CAST([m].[Timeline] AS nvarchar(max)) + N' Timeline' AS [Timeline] +SELECT [u].[Nickname], [u].[SquadId], [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch], [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch], [o].[Rank] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -CROSS JOIN [Missions] AS [m] -ORDER BY [u].[Nickname], [m].[Id] +LEFT JOIN ( + SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o1].[Nickname], [o1].[SquadId], [o1].[AssignedCityName], [o1].[CityOfBirthName], [o1].[FullName], [o1].[HasSoulPatch], [o1].[LeaderNickname], [o1].[LeaderSquadId], [o1].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o1] + ) AS [u1] + WHERE [u1].[HasSoulPatch] = CAST(0 AS bit) +) AS [u2] ON [u].[Nickname] = [u2].[LeaderNickname] AND [u].[SquadId] = [u2].[LeaderSquadId] +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( + SELECT TOP(1) [u0].[HasSoulPatch] + FROM ( + SELECT [g].[Nickname], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[HasSoulPatch] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [u].[Nickname], [u].[SquadId], [u2].[Nickname] """); } - public override async Task Time_of_day_datetimeoffset(bool async) + public override async Task Cast_to_derived_type_after_OfType_works(bool async) { - await base.Time_of_day_datetimeoffset(async); + await base.Cast_to_derived_type_after_OfType_works(async); AssertSql( """ -SELECT CONVERT(time, [m].[Timeline]) -FROM [Missions] AS [m] +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] """); } - public override async Task GroupBy_Property_Include_Select_Average(bool async) + public override async Task Select_subquery_boolean(bool async) { - await base.GroupBy_Property_Include_Select_Average(async); + await base.Select_subquery_boolean(async); AssertSql( """ -SELECT AVG(CAST([u].[SquadId] AS float)) +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)) FROM ( - SELECT [g].[SquadId], [g].[Rank] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[SquadId], [o].[Rank] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -GROUP BY [u].[Rank] """); } - public override async Task GroupBy_Property_Include_Select_Sum(bool async) + public override async Task Select_subquery_boolean_with_pushdown(bool async) { - await base.GroupBy_Property_Include_Select_Sum(async); + await base.Select_subquery_boolean_with_pushdown(async); AssertSql( """ -SELECT COALESCE(SUM([u].[SquadId]), 0) +SELECT ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) FROM ( - SELECT [g].[SquadId], [g].[Rank] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[SquadId], [o].[Rank] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -GROUP BY [u].[Rank] """); } - public override async Task GroupBy_Property_Include_Select_Count(bool async) + public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) { - await base.GroupBy_Property_Include_Select_Count(async); + await base.Select_subquery_int_with_inside_cast_and_coalesce(async); AssertSql( """ -SELECT COUNT(*) +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 42) FROM ( - SELECT [g].[Rank] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Rank] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -GROUP BY [u].[Rank] """); } - public override async Task GroupBy_Property_Include_Select_LongCount(bool async) + public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bool async) { - await base.GroupBy_Property_Include_Select_LongCount(async); + await base.Select_subquery_int_with_outside_cast_and_coalesce(async); AssertSql( """ -SELECT COUNT_BIG(*) +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 0) FROM ( - SELECT [g].[Rank] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Rank] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -GROUP BY [u].[Rank] """); } - public override async Task GroupBy_Property_Include_Select_Min(bool async) + public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool async) { - await base.GroupBy_Property_Include_Select_Min(async); + await base.Select_subquery_int_with_pushdown_and_coalesce(async); AssertSql( """ -SELECT MIN([u].[SquadId]) +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 42) FROM ( - SELECT [g].[SquadId], [g].[Rank] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[SquadId], [o].[Rank] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -GROUP BY [u].[Rank] """); } - public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(bool async) + public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool async) { - await base.GroupBy_Property_Include_Aggregate_with_anonymous_selector(async); + await base.Select_subquery_int_with_pushdown_and_coalesce2(async); AssertSql( """ -SELECT [u].[Nickname] AS [Key], COUNT(*) AS [c] +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), ( + SELECT TOP(1) [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [u].[FullName] = [w0].[OwnerFullName] + ORDER BY [w0].[Id])) FROM ( - SELECT [g].[Nickname] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -GROUP BY [u].[Nickname] -ORDER BY [u].[Nickname] """); } - public override async Task Group_by_with_include_with_entity_in_result_selector(bool async) + public override async Task Select_subquery_boolean_empty(bool async) { - await base.Group_by_with_include_with_entity_in_result_selector(async); + await base.Select_subquery_boolean_empty(async); AssertSql( """ -SELECT [u1].[Rank], [u1].[c], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ORDER BY [w].[Id]), CAST(0 AS bit)) FROM ( - SELECT [u].[Rank], COUNT(*) AS [c] - FROM ( - SELECT [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Rank] - FROM [Officers] AS [o] - ) AS [u] - GROUP BY [u].[Rank] -) AS [u1] -LEFT JOIN ( - SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Name], [s].[Location], [s].[Nation] - FROM ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [u0].[Rank] ORDER BY [u0].[Nickname]) AS [row] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - INNER JOIN [Cities] AS [c] ON [u0].[CityOfBirthName] = [c].[Name] - ) AS [s] - WHERE [s].[row] <= 1 -) AS [s0] ON [u1].[Rank] = [s0].[Rank] -ORDER BY [u1].[Rank] + SELECT [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task GroupBy_Property_Include_Select_Max(bool async) + public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) { - await base.GroupBy_Property_Include_Select_Max(async); + await base.Select_subquery_boolean_empty_with_pushdown(async); AssertSql( """ -SELECT MAX([u].[SquadId]) +SELECT ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ORDER BY [w].[Id]) FROM ( - SELECT [g].[SquadId], [g].[Rank] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[SquadId], [o].[Rank] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] -GROUP BY [u].[Rank] """); } - public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) { - await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); + await base.Select_subquery_distinct_singleordefault_boolean1(async); AssertSql( """ -SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] -FROM ( - SELECT [u].[Rank] - FROM ( - SELECT [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Rank] - FROM [Officers] AS [o] - ) AS [u] - GROUP BY [u].[Rank] -) AS [u1] -LEFT JOIN ( - SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Name], [s].[Location], [s].[Nation] +SELECT COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] FROM ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [u0].[Rank] ORDER BY [u0].[Nickname], [u0].[SquadId], [c].[Name]) AS [row] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - INNER JOIN [Cities] AS [c] ON [u0].[CityOfBirthName] = [c].[Name] - WHERE [u0].[HasSoulPatch] = CAST(1 AS bit) - ) AS [s] - WHERE [s].[row] <= 1 -) AS [s0] ON [u1].[Rank] = [s0].[Rank] + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]), CAST(0 AS bit)) +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Include_collection_with_Cast_to_base(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean2(bool async) { - await base.Include_collection_with_Cast_to_base(async); + await base.Select_subquery_distinct_singleordefault_boolean2(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [g].[FullName], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Include_with_client_method_and_member_access_still_applies_includes(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { - await base.Include_with_client_method_and_member_access_still_applies_includes(async); + await base.Select_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Include_with_projection_of_unmapped_property_still_gets_applied(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty1(bool async) { - await base.Include_with_projection_of_unmapped_property_still_gets_applied(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty1(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ) AS [w0]), CAST(0 AS bit)) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection() + public override async Task Select_subquery_distinct_singleordefault_boolean_empty2(bool async) { - await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); + await base.Select_subquery_distinct_singleordefault_boolean_empty2(async); AssertSql( """ -SELECT [s].[Name], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] - LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -WHERE [s].[Name] = N'Delta' -ORDER BY [s].[Id], [s0].[Nickname], [s0].[SquadId] +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG'), CAST(0 AS bit)) +FROM ( + SELECT [g].[FullName], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) { - await base.OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); AssertSql( """ -SELECT CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) -END +SELECT ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ) AS [w0]) FROM ( - SELECT [g].[Nickname], [g].[LeaderNickname] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[LeaderNickname] + SELECT [o].[FullName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -ORDER BY CASE - WHEN CASE - WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) - END IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +WHERE [u].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task GetValueOrDefault_in_projection(bool async) + public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool async) { - await base.GetValueOrDefault_in_projection(async); + await base.Cast_subquery_to_base_type_using_typed_ToList(async); AssertSql( """ -SELECT COALESCE([w].[SynergyWithId], 0) -FROM [Weapons] AS [w] +SELECT [c].[Name], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Nickname], [u].[Rank], [u].[SquadId] +FROM [Cities] AS [c] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank] + FROM [Officers] AS [o] +) AS [u] ON [c].[Name] = [u].[AssignedCityName] +WHERE [c].[Name] = N'Ephyra' +ORDER BY [c].[Name], [u].[Nickname] """); } - public override async Task GetValueOrDefault_in_filter(bool async) + public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArray(bool async) { - await base.GetValueOrDefault_in_filter(async); + await base.Cast_ordered_subquery_to_base_type_using_typed_ToArray(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], 0) = 0 +SELECT [c].[Name], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Nickname], [u].[Rank], [u].[SquadId] +FROM [Cities] AS [c] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank] + FROM [Officers] AS [o] +) AS [u] ON [c].[Name] = [u].[AssignedCityName] +WHERE [c].[Name] = N'Ephyra' +ORDER BY [c].[Name], [u].[Nickname] DESC """); } - public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool async) + public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) { - await base.GetValueOrDefault_in_filter_non_nullable_column(async); + await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[Id] = 0 +@nicknames='[]' (Size = 4000) + +SELECT [u].[Nickname], [u].[SquadId], [w].[Name], [w].[Id] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +ORDER BY CASE + WHEN [u].[Nickname] IN ( + SELECT [n].[value] + FROM OPENJSON(@nicknames) WITH ([value] nvarchar(450) '$') AS [n] + ) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END DESC, [u].[Nickname], [u].[SquadId] """); } - public override async Task GetValueOrDefault_in_order_by(bool async) + public override async Task Double_order_by_on_nullable_bool_coming_from_optional_navigation(bool async) { - await base.GetValueOrDefault_in_order_by(async); + await base.Double_order_by_on_nullable_bool_coming_from_optional_navigation(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] -ORDER BY COALESCE([w].[SynergyWithId], 0), [w].[Id] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w0].[IsAutomatic], [w0].[Id] """); } - public override async Task GetValueOrDefault_with_argument(bool async) + public override async Task Double_order_by_on_Like(bool async) { - await base.GetValueOrDefault_with_argument(async); + await base.Double_order_by_on_Like(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], [w].[Id]) = 1 +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] LIKE N'%Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task GetValueOrDefault_with_argument_complex(bool async) + public override async Task Double_order_by_on_is_null(bool async) { - await base.GetValueOrDefault_with_argument_complex(async); + await base.Double_order_by_on_is_null(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], CAST(LEN([w].[Name]) AS int) + 42) > 10 +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Filter_with_complex_predicate_containing_subquery(bool async) + public override async Task Double_order_by_on_string_compare(bool async) { - await base.Filter_with_complex_predicate_containing_subquery(async); + await base.Double_order_by_on_string_compare(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[FullName] <> N'Dom' AND EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit)) +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +ORDER BY CASE + WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w].[Id] """); } - public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( - bool async) + public override async Task Double_order_by_binary_expression(bool async) { - await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(async); + await base.Double_order_by_binary_expression(async); AssertSql( """ -SELECT [u].[Nickname], ( - SELECT TOP(1) [w].[Name] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit) - ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] -FROM ( - SELECT [g].[Nickname], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -WHERE [u].[Nickname] <> N'Dom' +SELECT [w].[Id] + 2 AS [Binary] +FROM [Weapons] AS [w] +ORDER BY [w].[Id] + 2 """); } - public override async Task - Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) + public override async Task String_compare_with_null_conditional_argument(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); + await base.String_compare_with_null_conditional_argument(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE SUBSTRING([t].[Note], 0 + 1, [u].[SquadId]) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [u].[SquadId] IS NULL) AND [t].[GearNickName] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task - Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) + public override async Task String_compare_with_null_conditional_argument2(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( - async); + await base.String_compare_with_null_conditional_argument2(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -WHERE SUBSTRING([t].[Note], 0 + 1, CAST(LEN([s].[Name]) AS int)) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s].[Name] IS NULL) AND [t].[GearNickName] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Filter_with_new_Guid(bool async) + public override async Task String_concat_with_null_conditional_argument(bool async) { - await base.Filter_with_new_Guid(async); + await base.String_concat_with_null_conditional_argument(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] = 'df36f493-463f-4123-83f9-6b135deeb7ba' +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY COALESCE([w0].[Name], N'') + CAST(5 AS nvarchar(max)) """); } - public override async Task Filter_with_new_Guid_closure(bool async) - { - await base.Filter_with_new_Guid_closure(async); - - AssertSql(); - } - - public override async Task OfTypeNav1(bool async) + public override async Task String_concat_with_null_conditional_argument2(bool async) { - await base.OfTypeNav1(async); + await base.String_concat_with_null_conditional_argument2(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - 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] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY COALESCE([w0].[Name], N'') + N'Marcus'' Lancer' """); } - public override async Task OfTypeNav2(bool async) + public override async Task String_concat_on_various_types(bool async) { - await base.OfTypeNav2(async); + await base.String_concat_on_various_types(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT N'HasSoulPatch ' + CAST([u].[HasSoulPatch] AS nvarchar(max)) + N' HasSoulPatch' AS [HasSoulPatch], N'Rank ' + CAST([u].[Rank] AS nvarchar(max)) + N' Rank' AS [Rank], N'SquadId ' + CAST([u].[SquadId] AS nvarchar(max)) + N' SquadId' AS [SquadId], N'Rating ' + COALESCE(CAST([m].[Rating] AS nvarchar(max)), N'') + N' Rating' AS [Rating], N'Timeline ' + CAST([m].[Timeline] AS nvarchar(max)) + N' Timeline' AS [Timeline] FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch], [o].[Rank] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) +CROSS JOIN [Missions] AS [m] +ORDER BY [u].[Nickname], [m].[Id] """); } - public override async Task OfTypeNav3(bool async) + public override async Task GroupBy_Property_Include_Select_Average(bool async) { - await base.OfTypeNav3(async); + await base.GroupBy_Property_Include_Select_Average(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT AVG(CAST([u].[SquadId] AS float)) FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[AssignedCityName], [o].[CityOfBirthName], [o].[FullName], [o].[HasSoulPatch], [o].[LeaderNickname], [o].[LeaderSquadId], [o].[Rank], N'Officer' AS [Discriminator] + SELECT [g].[SquadId], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[Rank] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -INNER JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +GROUP BY [u].[Rank] """); } - public override async Task Nav_rewrite_Distinct_with_convert() - { - await base.Nav_rewrite_Distinct_with_convert(); - - AssertSql(); - } - - public override async Task Nav_rewrite_Distinct_with_convert_anonymous() - { - await base.Nav_rewrite_Distinct_with_convert_anonymous(); - - AssertSql(); - } - - public override async Task Nav_rewrite_with_convert1(bool async) + public override async Task GroupBy_Property_Include_Select_Sum(bool async) { - await base.Nav_rewrite_with_convert1(async); + await base.GroupBy_Property_Include_Select_Sum(async); AssertSql( """ -SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] -FROM [LocustHordes] AS [l] -LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL +SELECT COALESCE(SUM([u].[SquadId]), 0) +FROM ( + SELECT [g].[SquadId], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[Rank] + FROM [Officers] AS [o] +) AS [u] +GROUP BY [u].[Rank] """); } - public override async Task Nav_rewrite_with_convert2(bool async) + public override async Task GroupBy_Property_Include_Select_Count(bool async) { - await base.Nav_rewrite_with_convert2(async); + await base.GroupBy_Property_Include_Select_Count(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] -FROM [LocustHordes] AS [l] -LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +SELECT COUNT(*) +FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Rank] + FROM [Officers] AS [o] +) AS [u] +GROUP BY [u].[Rank] """); } - public override async Task Nav_rewrite_with_convert3(bool async) + public override async Task GroupBy_Property_Include_Select_LongCount(bool async) { - await base.Nav_rewrite_with_convert3(async); + await base.GroupBy_Property_Include_Select_LongCount(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] -FROM [LocustHordes] AS [l] -LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) +SELECT COUNT_BIG(*) +FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Rank] + FROM [Officers] AS [o] +) AS [u] +GROUP BY [u].[Rank] """); } - public override async Task Where_contains_on_navigation_with_composite_keys(bool async) + public override async Task GroupBy_Property_Include_Select_Min(bool async) { - await base.Where_contains_on_navigation_with_composite_keys(async); + await base.GroupBy_Property_Include_Select_Min(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT MIN([u].[SquadId]) FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[SquadId], [g].[Rank] FROM [Gears] AS [g] 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] + SELECT [o].[SquadId], [o].[Rank] FROM [Officers] AS [o] ) AS [u] -WHERE EXISTS ( - SELECT 1 - FROM [Cities] AS [c] - WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[CityOfBirthName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[CityOfBirthName] - FROM [Officers] AS [o0] - ) AS [u0] - WHERE [c].[Name] = [u0].[CityOfBirthName] AND [u0].[Nickname] = [u].[Nickname] AND [u0].[SquadId] = [u].[SquadId])) +GROUP BY [u].[Rank] """); } - public override async Task Include_with_complex_order_by(bool async) + public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(bool async) { - await base.Include_with_complex_order_by(async); + await base.GroupBy_Property_Include_Aggregate_with_anonymous_selector(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[Nickname] AS [Key], COUNT(*) AS [c] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] -ORDER BY ( - SELECT TOP(1) [w].[Name] - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Gnasher%'), [u].[Nickname], [u].[SquadId] +GROUP BY [u].[Nickname] +ORDER BY [u].[Nickname] """); } - public override async Task Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(bool async) + public override async Task Group_by_with_include_with_entity_in_result_selector(bool async) { - await base.Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(async); + await base.Group_by_with_include_with_entity_in_result_selector(async); AssertSql( """ -@p='25' - -SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId] +SELECT [u1].[Rank], [u1].[c], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] FROM ( - SELECT TOP(@p) [u].[FullName] + SELECT [u].[Rank], COUNT(*) AS [c] FROM ( - SELECT [g].[FullName] + SELECT [g].[Rank] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + SELECT [o].[Rank] FROM [Officers] AS [o] ) AS [u] -) AS [u0] + GROUP BY [u].[Rank] +) AS [u1] LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Name], [s].[Location], [s].[Nation] FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] - FROM [Weapons] AS [w] - ) AS [w0] - WHERE [w0].[row] <= 1 -) AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [u0].[Rank] ORDER BY [u0].[Nickname]) AS [row] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Cities] AS [c] ON [u0].[CityOfBirthName] = [c].[Name] + ) AS [s] + WHERE [s].[row] <= 1 +) AS [s0] ON [u1].[Rank] = [s0].[Rank] +ORDER BY [u1].[Rank] """); } - public override async Task Bool_projection_from_subquery_treated_appropriately_in_where(bool async) + public override async Task GroupBy_Property_Include_Select_Max(bool async) { - await base.Bool_projection_from_subquery_treated_appropriately_in_where(async); + await base.GroupBy_Property_Include_Select_Max(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE ( - SELECT TOP(1) [u].[HasSoulPatch] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - ORDER BY [u].[Nickname], [u].[SquadId]) = CAST(1 AS bit) +SELECT MAX([u].[SquadId]) +FROM ( + SELECT [g].[SquadId], [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[Rank] + FROM [Officers] AS [o] +) AS [u] +GROUP BY [u].[Rank] """); } - public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) + public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) { - await base.DateTimeOffset_Contains_Less_than_Greater_than(async); + await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); AssertSql( """ -@start='1902-01-01T10:00:00.1234567+01:30' -@end='1902-01-03T10:00:00.1234567+01:30' -@dates='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) - -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE @start <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @end AND [m].[Timeline] IN ( - SELECT [d].[value] - FROM OPENJSON(@dates) WITH ([value] datetimeoffset '$') AS [d] -) +SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] +FROM ( + SELECT [u].[Rank] + FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Rank] + FROM [Officers] AS [o] + ) AS [u] + GROUP BY [u].[Rank] +) AS [u1] +LEFT JOIN ( + SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s].[Name], [s].[Location], [s].[Nation] + FROM ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [u0].[Rank] ORDER BY [u0].[Nickname], [u0].[SquadId], [c].[Name]) AS [row] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Cities] AS [c] ON [u0].[CityOfBirthName] = [c].[Name] + WHERE [u0].[HasSoulPatch] = CAST(1 AS bit) + ) AS [s] + WHERE [s].[row] <= 1 +) AS [s0] ON [u1].[Rank] = [s0].[Rank] """); } - public override Task DateTimeOffsetNow_minus_timespan(bool async) - => AssertTranslationFailed(() => base.DateTimeOffsetNow_minus_timespan(async)); - - public override async Task Navigation_inside_interpolated_string_expanded(bool async) + public override async Task Include_collection_with_Cast_to_base(bool async) { - await base.Navigation_inside_interpolated_string_expanded(async); + await base.Include_collection_with_Cast_to_base(async); AssertSql( """ -SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w0].[OwnerFullName] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + 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] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Left_join_projection_using_coalesce_tracking(bool async) + public override async Task Include_with_client_method_and_member_access_still_applies_includes(bool async) { - await base.Left_join_projection_using_coalesce_tracking(async); + await base.Include_with_client_method_and_member_access_still_applies_includes(async); AssertSql( """ -SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -9032,26 +7738,17 @@ 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] """); } - public override async Task Left_join_projection_using_conditional_tracking(bool async) + public override async Task Include_with_projection_of_unmapped_property_still_gets_applied(bool async) { - await base.Left_join_projection_using_conditional_tracking(async); + await base.Include_with_projection_of_unmapped_property_still_gets_applied(async); AssertSql( """ -SELECT CASE - WHEN [u0].[Nickname] IS NULL OR [u0].[SquadId] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -9059,150 +7756,134 @@ 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Project_collection_navigation_nested_with_take_composite_key(bool async) + public override async Task Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection() { - await base.Project_collection_navigation_nested_with_take_composite_key(async); + await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); AssertSql( """ -SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], N'Officer' AS [Discriminator] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +SELECT [s].[Name], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] + SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], ROW_NUMBER() OVER(PARTITION BY [u0].[LeaderNickname], [u0].[LeaderSquadId] ORDER BY [u0].[Nickname], [u0].[SquadId]) AS [row] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - ) AS [u1] - WHERE [u1].[row] <= 50 -) AS [u2] ON ([u].[Nickname] = [u2].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u2].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u2].[LeaderSquadId] -WHERE [u].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId], [u2].[Nickname] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] + LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +WHERE [s].[Name] = N'Delta' +ORDER BY [s].[Id], [s0].[Nickname], [s0].[SquadId] """); } - public override async Task Project_collection_navigation_nested_composite_key(bool async) + public override async Task OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(bool async) { - await base.Project_collection_navigation_nested_composite_key(async); + await base.OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(async); AssertSql( """ -SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], N'Gear' AS [Discriminator] +SELECT CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) +END +FROM ( + SELECT [g].[Nickname], [g].[LeaderNickname] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], N'Officer' AS [Discriminator] + SELECT [o].[Nickname], [o].[LeaderNickname] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] -WHERE [u].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[Nickname] +) AS [u] +ORDER BY CASE + WHEN CASE + WHEN [u].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([u].[Nickname]) AS int) ^ 5 AS bit) + END IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) + public override async Task GetValueOrDefault_in_projection(bool async) { - await base.Null_checks_in_correlated_predicate_are_correctly_translated(async); + await base.GetValueOrDefault_in_projection(async); AssertSql( """ -SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] AND [t].[Note] IS NOT NULL -ORDER BY [t].[Id], [u].[Nickname] +SELECT COALESCE([w].[SynergyWithId], 0) +FROM [Weapons] AS [w] """); } - public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(bool async) + public override async Task GetValueOrDefault_in_filter(bool async) { - await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(async); + await base.GetValueOrDefault_in_filter(async); AssertSql( """ -@isAutomatic='True' +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], 0) = 0 +"""); + } -SELECT [u].[Nickname], [u].[FullName], CASE - WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Collection] -FROM ( - SELECT [g].[Nickname], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = @isAutomatic -) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] + public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool async) + { + await base.GetValueOrDefault_in_filter_non_nullable_column(async); + + AssertSql( + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[Id] = 0 """); } - public override async Task Join_with_inner_being_a_subquery_projecting_single_property(bool async) + public override async Task GetValueOrDefault_in_order_by(bool async) { - await base.Join_with_inner_being_a_subquery_projecting_single_property(async); + await base.GetValueOrDefault_in_order_by(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -INNER JOIN ( - SELECT [g0].[Nickname] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[Nickname] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +ORDER BY COALESCE([w].[SynergyWithId], 0), [w].[Id] """); } - public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) + public override async Task GetValueOrDefault_with_argument(bool async) { - await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); + await base.GetValueOrDefault_with_argument(async); + + AssertSql( + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], [w].[Id]) = 1 +"""); + } + + public override async Task GetValueOrDefault_with_argument_complex(bool async) + { + await base.GetValueOrDefault_with_argument_complex(async); + + AssertSql( + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], CAST(LEN([w].[Name]) AS int) + 42) > 10 +"""); + } + + public override async Task Filter_with_complex_predicate_containing_subquery(bool async) + { + await base.Filter_with_complex_predicate_containing_subquery(async); AssertSql( """ @@ -9214,1624 +7895,1535 @@ 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] -INNER JOIN ( - SELECT [g0].[Nickname] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname] - FROM [Officers] AS [o0] -) AS [u0] ON [u].[Nickname] = [u0].[Nickname] -"""); - } - - public override async Task Navigation_based_on_complex_expression1(bool async) - { - await base.Navigation_based_on_complex_expression1(async); - - AssertSql( - """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL +WHERE [u].[FullName] <> N'Dom' AND EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit)) """); } - public override async Task Navigation_based_on_complex_expression2(bool async) + public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( + bool async) { - await base.Navigation_based_on_complex_expression2(async); + await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(async); AssertSql( """ -SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL +SELECT [u].[Nickname], ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit) + ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] +FROM ( + SELECT [g].[Nickname], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +WHERE [u].[Nickname] <> N'Dom' """); } - public override async Task Navigation_based_on_complex_expression3(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) { - await base.Navigation_based_on_complex_expression3(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); AssertSql( """ -SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] -FROM [LocustHordes] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE SUBSTRING([t].[Note], 0 + 1, [u].[SquadId]) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [u].[SquadId] IS NULL) AND [t].[GearNickName] IS NULL) """); } - public override async Task Navigation_based_on_complex_expression4(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) { - await base.Navigation_based_on_complex_expression4(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + async); AssertSql( """ -SELECT CAST(1 AS bit), [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM [LocustHordes] AS [l] -CROSS JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -LEFT JOIN [LocustCommanders] AS [l1] ON [l].[CommanderName] = [l1].[Name] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] +WHERE SUBSTRING([t].[Note], 0 + 1, CAST(LEN([s].[Name]) AS int)) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s].[Name] IS NULL) AND [t].[GearNickName] IS NULL) """); } - public override async Task Navigation_based_on_complex_expression5(bool async) + public override async Task OfTypeNav1(bool async) { - await base.Navigation_based_on_complex_expression5(async); + await base.OfTypeNav1(async); AssertSql( """ -SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM [LocustHordes] AS [l] -CROSS JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + 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] -LEFT JOIN [LocustCommanders] AS [l1] ON [l].[CommanderName] = [l1].[Name] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) """); } - public override async Task Navigation_based_on_complex_expression6(bool async) + public override async Task OfTypeNav2(bool async) { - await base.Navigation_based_on_complex_expression6(async); + await base.OfTypeNav2(async); AssertSql( """ -SELECT CASE - WHEN [l1].[Name] = N'Queen Myrrah' AND [l1].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM [LocustHordes] AS [l] -CROSS JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + 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] -LEFT JOIN [LocustCommanders] AS [l1] ON [l].[CommanderName] = [l1].[Name] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) """); } - public override async Task Select_as_operator(bool async) + public override async Task OfTypeNav3(bool async) { - await base.Select_as_operator(async); + await base.OfTypeNav3(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] -FROM [LocustLeaders] AS [l] -UNION ALL -SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] -FROM [LocustCommanders] AS [l0] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + 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] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +INNER JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Tags] AS [t0] ON [u].[Nickname] = [t0].[GearNickName] AND [u].[SquadId] = [t0].[GearSquadId] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) """); } - public override async Task Select_datetimeoffset_comparison_in_projection(bool async) + public override async Task Nav_rewrite_Distinct_with_convert() { - await base.Select_datetimeoffset_comparison_in_projection(async); + await base.Nav_rewrite_Distinct_with_convert(); - AssertSql( - """ -SELECT CASE - WHEN [m].[Timeline] > SYSDATETIMEOFFSET() THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Missions] AS [m] -"""); + AssertSql(); } - public override async Task OfType_in_subquery_works(bool async) + public override async Task Nav_rewrite_Distinct_with_convert_anonymous() { - await base.OfType_in_subquery_works(async); + await base.Nav_rewrite_Distinct_with_convert_anonymous(); - AssertSql( - """ -SELECT [s].[Name], [s].[Location], [s].[Nation] -FROM [Officers] AS [o] -INNER JOIN ( - SELECT [c].[Name], [c].[Location], [c].[Nation], [u].[LeaderNickname], [u].[LeaderSquadId] - FROM ( - SELECT [o0].[AssignedCityName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] - ) AS [u] - LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] -) AS [s] ON [o].[Nickname] = [s].[LeaderNickname] AND [o].[SquadId] = [s].[LeaderSquadId] -"""); + AssertSql(); } - public override async Task Nullable_bool_comparison_is_translated_to_server(bool async) + public override async Task Nav_rewrite_with_convert1(bool async) { - await base.Nullable_bool_comparison_is_translated_to_server(async); + await base.Nav_rewrite_with_convert1(async); AssertSql( """ -SELECT CASE - WHEN [l].[Eradicated] = CAST(1 AS bit) AND [l].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [IsEradicated] +SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] FROM [LocustHordes] AS [l] +LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL """); } - public override async Task Accessing_reference_navigation_collection_composition_generates_single_query(bool async) + public override async Task Nav_rewrite_with_convert2(bool async) { - await base.Accessing_reference_navigation_collection_composition_generates_single_query(async); + await base.Nav_rewrite_with_convert2(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [s].[Id], [s].[IsAutomatic], [s].[Name], [s].[Id0] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] -) AS [u] -LEFT JOIN ( - SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [u].[FullName] = [s].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id] +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] +FROM [LocustHordes] AS [l] +LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) """); } - public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) + public override async Task Nav_rewrite_with_convert3(bool async) { - await base.Reference_include_chain_loads_correctly_when_middle_is_null(async); + await base.Nav_rewrite_with_convert3(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -ORDER BY [t].[Note] +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] +FROM [LocustHordes] AS [l] +LEFT JOIN [Cities] AS [c] ON [l].[CapitalName] = [c].[Name] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([l0].[Name] <> N'Bar' OR [l0].[Name] IS NULL) """); } - public override async Task Accessing_property_of_optional_navigation_in_child_projection_works(bool async) + public override async Task Where_contains_on_navigation_with_composite_keys(bool async) { - await base.Accessing_property_of_optional_navigation_in_child_projection_works(async); + await base.Where_contains_on_navigation_with_composite_keys(async); AssertSql( """ -SELECT CASE - WHEN [u].[Nickname] IS NOT NULL AND [u].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [t].[Id], [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[Id], [s].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN ( - SELECT [u0].[Nickname], [w].[Id], [u0].[SquadId], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] ON [w].[OwnerFullName] = [u0].[FullName] -) AS [s] ON [u].[FullName] = [s].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] -"""); - } - - public override async Task Collection_navigation_ofType_filter_works(bool async) - { - await base.Collection_navigation_ofType_filter_works(async); - - AssertSql( - """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] +) AS [u] WHERE EXISTS ( SELECT 1 - FROM ( - SELECT [o].[Nickname], [o].[CityOfBirthName] - FROM [Officers] AS [o] - ) AS [u] - WHERE [c].[Name] = [u].[CityOfBirthName] AND [u].[Nickname] = N'Marcus') + FROM [Cities] AS [c] + WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[CityOfBirthName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[CityOfBirthName] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [c].[Name] = [u0].[CityOfBirthName] AND [u0].[Nickname] = [u].[Nickname] AND [u0].[SquadId] = [u].[SquadId])) """); } - public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) + public override async Task Include_with_complex_order_by(bool async) { - await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); + await base.Include_with_complex_order_by(async); AssertSql( """ -@prm_Inner_Nickname='Marcus' (Size = 450) - -SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT DISTINCT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Nickname] <> @prm_Inner_Nickname -) AS [u0] -ORDER BY [u0].[FullName] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +LEFT JOIN [Weapons] AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] +ORDER BY ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Gnasher%'), [u].[Nickname], [u].[SquadId] """); } - public override async Task Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(bool async) + public override async Task Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(bool async) { - await base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async); + await base.Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(async); AssertSql( """ -@squadId='1' +@p='25' -SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] +SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId] FROM ( - SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] + SELECT TOP(@p) [u].[FullName] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] - INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] - WHERE [s].[Id] IN ( - SELECT [s0].[Id] - FROM [Squads] AS [s0] - WHERE [s0].[Id] = @squadId - ) - UNION ALL - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +) AS [u0] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] - ) AS [u0] - INNER JOIN [Squads] AS [s1] ON [u0].[SquadId] = [s1].[Id] - WHERE [s1].[Id] IN ( - SELECT [s2].[Id] - FROM [Squads] AS [s2] - WHERE [s2].[Id] = @squadId - ) -) AS [u1] -ORDER BY [u1].[FullName] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] + FROM [Weapons] AS [w] + ) AS [w0] + WHERE [w0].[row] <= 1 +) AS [w1] ON [u0].[FullName] = [w1].[OwnerFullName] """); } - public override async Task Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(bool async) + public override async Task Bool_projection_from_subquery_treated_appropriately_in_where(bool async) { - await base.Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(async); + await base.Bool_projection_from_subquery_treated_appropriately_in_where(async); AssertSql( """ -@gearId='1' - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE EXISTS ( - SELECT 1 +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE ( + SELECT TOP(1) [u].[HasSoulPatch] FROM ( - SELECT [g].[SquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] UNION ALL - SELECT [o].[SquadId] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[SquadId] = @gearId AND [u].[SquadId] = @gearId) + ORDER BY [u].[Nickname], [u].[SquadId]) = CAST(1 AS bit) """); } - public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(bool async) + public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) { - await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(async); + await base.DateTimeOffset_Contains_Less_than_Greater_than(async); AssertSql( """ -@entity_equality_prm_Inner_Squad_Id='1' (Nullable = true) +@start='1902-01-01T10:00:00.1234567+01:30' +@end='1902-01-03T10:00:00.1234567+01:30' +@dates='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) -SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM ( - SELECT DISTINCT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] - INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] - WHERE [s].[Id] = @entity_equality_prm_Inner_Squad_Id -) AS [s1] -INNER JOIN [Squads] AS [s0] ON [s1].[SquadId] = [s0].[Id] -WHERE [s0].[Id] = @entity_equality_prm_Inner_Squad_Id -ORDER BY [s1].[FullName] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE @start <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @end AND [m].[Timeline] IN ( + SELECT [d].[value] + FROM OPENJSON(@dates) WITH ([value] datetimeoffset '$') AS [d] +) """); } - public override async Task Complex_GroupBy_after_set_operator(bool async) + public override Task DateTimeOffsetNow_minus_timespan(bool async) + => AssertTranslationFailed(() => base.DateTimeOffsetNow_minus_timespan(async)); + + public override async Task Navigation_inside_interpolated_string_expanded(bool async) { - await base.Complex_GroupBy_after_set_operator(async); + await base.Navigation_inside_interpolated_string_expanded(async); AssertSql( """ -SELECT [u1].[Name], [u1].[Count], COALESCE(SUM([u1].[Count]), 0) AS [Sum] -FROM ( - SELECT [c].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]) AS [Count] - FROM ( - SELECT [g].[AssignedCityName], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[AssignedCityName], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] - LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] - UNION ALL - SELECT [c0].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [u0].[FullName] = [w0].[OwnerFullName]) AS [Count] - FROM ( - SELECT [g0].[CityOfBirthName], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[CityOfBirthName], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] - INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] -) AS [u1] -GROUP BY [u1].[Name], [u1].[Count] +SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w0].[OwnerFullName] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] """); } - public override async Task Complex_GroupBy_after_set_operator_using_result_selector(bool async) + public override async Task Left_join_projection_using_coalesce_tracking(bool async) { - await base.Complex_GroupBy_after_set_operator_using_result_selector(async); + await base.Left_join_projection_using_coalesce_tracking(async); AssertSql( """ -SELECT [u1].[Name], [u1].[Count], COALESCE(SUM([u1].[Count]), 0) AS [Sum] +SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [c].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [u].[FullName] = [w].[OwnerFullName]) AS [Count] - FROM ( - SELECT [g].[AssignedCityName], [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[AssignedCityName], [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] - LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] UNION ALL - SELECT [c0].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [u0].[FullName] = [w0].[OwnerFullName]) AS [Count] - FROM ( - SELECT [g0].[CityOfBirthName], [g0].[FullName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[CityOfBirthName], [o0].[FullName] - FROM [Officers] AS [o0] - ) AS [u0] - INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] -) AS [u1] -GROUP BY [u1].[Name], [u1].[Count] + 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] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] """); } - public override async Task Left_join_with_GroupBy_with_composite_group_key(bool async) + public override async Task Left_join_projection_using_conditional_tracking(bool async) { - await base.Left_join_with_GroupBy_with_composite_group_key(async); + await base.Left_join_projection_using_conditional_tracking(async); AssertSql( """ -SELECT [u].[CityOfBirthName], [u].[HasSoulPatch] +SELECT CASE + WHEN [u0].[Nickname] IS NULL OR [u0].[SquadId] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName], [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName], [o].[HasSoulPatch] + 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] -INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] -GROUP BY [u].[CityOfBirthName], [u].[HasSoulPatch] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[LeaderNickname] = [u0].[Nickname] """); } - public override async Task GroupBy_with_boolean_grouping_key(bool async) + public override async Task Project_collection_navigation_nested_with_take_composite_key(bool async) { - await base.GroupBy_with_boolean_grouping_key(async); + await base.Project_collection_navigation_nested_with_take_composite_key(async); AssertSql( """ -SELECT [u0].[CityOfBirthName], [u0].[HasSoulPatch], [u0].[IsMarcus], COUNT(*) AS [Count] -FROM ( - SELECT [u].[CityOfBirthName], [u].[HasSoulPatch], CASE - WHEN [u].[Nickname] = N'Marcus' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [IsMarcus] +SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], N'Officer' AS [Discriminator] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[CityOfBirthName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[CityOfBirthName], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] -) AS [u0] -GROUP BY [u0].[CityOfBirthName], [u0].[HasSoulPatch], [u0].[IsMarcus] + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator], ROW_NUMBER() OVER(PARTITION BY [u0].[LeaderNickname], [u0].[LeaderSquadId] ORDER BY [u0].[Nickname], [u0].[SquadId]) AS [row] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + ) AS [u1] + WHERE [u1].[row] <= 50 +) AS [u2] ON ([u].[Nickname] = [u2].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u2].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u2].[LeaderSquadId] +WHERE [u].[Discriminator] = N'Officer' +ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId], [u2].[Nickname] """); } - public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) + public override async Task Project_collection_navigation_nested_composite_key(bool async) { - await base.GroupBy_with_boolean_groupin_key_thru_navigation_access(async); + await base.Project_collection_navigation_nested_composite_key(async); AssertSql( """ -SELECT [u].[HasSoulPatch], LOWER([s].[Name]) AS [Name] +SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + SELECT [g].[Nickname], [g].[SquadId], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId], N'Officer' AS [Discriminator] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -GROUP BY [u].[HasSoulPatch], [s].[Name] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] ON ([u].[Nickname] = [u0].[LeaderNickname] OR ([u].[Nickname] IS NULL AND [u0].[LeaderNickname] IS NULL)) AND [u].[SquadId] = [u0].[LeaderSquadId] +WHERE [u].[Discriminator] = N'Officer' +ORDER BY [t].[Id], [u].[Nickname], [u].[SquadId], [u0].[Nickname] """); } - public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) + public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) { - await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); + await base.Null_checks_in_correlated_predicate_are_correctly_translated(async); AssertSql( """ -SELECT [c].[Name] -FROM ( - SELECT [g].[CityOfBirthName] +SELECT [t].[Id], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[CityOfBirthName] + 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] -INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -GROUP BY [c].[Name] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] AND [t].[Note] IS NOT NULL +ORDER BY [t].[Id], [u].[Nickname] """); } - public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(bool async) { - await base.Group_by_on_StartsWith_with_null_parameter_as_argument(async); + await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(async); AssertSql( """ -SELECT [u0].[Key] +@isAutomatic='True' + +SELECT [u].[Nickname], [u].[FullName], CASE + WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Collection] FROM ( - SELECT CAST(0 AS bit) AS [Key] - FROM ( - SELECT [g].[FullName] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[FullName] - FROM [Officers] AS [o] - ) AS [u] -) AS [u0] -GROUP BY [u0].[Key] + SELECT [g].[Nickname], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN ( + SELECT [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = @isAutomatic +) AS [w0] ON [u].[FullName] = [w0].[OwnerFullName] """); } - public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Join_with_inner_being_a_subquery_projecting_single_property(bool async) { - await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); + await base.Join_with_inner_being_a_subquery_projecting_single_property(async); AssertSql( """ -SELECT [u].[FullName] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[FullName] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + 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] -GROUP BY [u].[FullName] -HAVING 0 = 1 +INNER JOIN ( + SELECT [g0].[Nickname] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[Nickname] """); } - public override async Task Select_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) { - await base.Select_StartsWith_with_null_parameter_as_argument(async); + await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); AssertSql( """ -SELECT CAST(0 AS bit) +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[FullName] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[FullName] + 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] +INNER JOIN ( + SELECT [g0].[Nickname] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname] + FROM [Officers] AS [o0] +) AS [u0] ON [u].[Nickname] = [u0].[Nickname] """); } - public override async Task Select_null_parameter_is_not_null(bool async) + public override async Task Navigation_based_on_complex_expression1(bool async) { - await base.Select_null_parameter_is_not_null(async); + await base.Navigation_based_on_complex_expression1(async); AssertSql( """ -@p='False' - -SELECT @p -FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Officers] AS [o] -) AS [u] +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +WHERE [l0].[Name] IS NOT NULL """); } - public override async Task Where_null_parameter_is_not_null(bool async) + public override async Task Navigation_based_on_complex_expression2(bool async) { - await base.Where_null_parameter_is_not_null(async); + await base.Navigation_based_on_complex_expression2(async); AssertSql( """ -@p='False' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 @p = CAST(1 AS bit) +SELECT [l].[Id], [l].[CapitalName], [l].[Name], [l].[ServerAddress], [l].[CommanderName], [l].[Eradicated] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] +WHERE [l0].[Name] IS NOT NULL """); } - public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Navigation_based_on_complex_expression3(bool async) { - await base.OrderBy_StartsWith_with_null_parameter_as_argument(async); + await base.Navigation_based_on_complex_expression3(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -ORDER BY [u].[Nickname] +SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] +FROM [LocustHordes] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[CommanderName] = [l0].[Name] """); } - public override async Task OrderBy_Contains_empty_list(bool async) + public override async Task Navigation_based_on_complex_expression4(bool async) { - await base.OrderBy_Contains_empty_list(async); + await base.Navigation_based_on_complex_expression4(async); AssertSql( """ -@ids='[]' (Size = 4000) - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] +SELECT CAST(1 AS bit), [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM [LocustHordes] AS [l] +CROSS JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -ORDER BY CASE - WHEN [u].[SquadId] IN ( - SELECT [i].[value] - FROM OPENJSON(@ids) WITH ([value] int '$') AS [i] - ) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +LEFT JOIN [LocustCommanders] AS [l1] ON [l].[CommanderName] = [l1].[Name] """); } - public override async Task Where_with_enum_flags_parameter(bool async) + public override async Task Navigation_based_on_complex_expression5(bool async) { - await base.Where_with_enum_flags_parameter(async); + await base.Navigation_based_on_complex_expression5(async); AssertSql( """ -@rank='1' (Nullable = true) - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] +SELECT [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM [LocustHordes] AS [l] +CROSS JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -WHERE [u].[Rank] & @rank = @rank -""", - // +LEFT JOIN [LocustCommanders] AS [l1] ON [l].[CommanderName] = [l1].[Name] +"""); + } + + public override async Task Navigation_based_on_complex_expression6(bool async) + { + await base.Navigation_based_on_complex_expression6(async); + + AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] +SELECT CASE + WHEN [l1].[Name] = N'Queen Myrrah' AND [l1].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [l1].[Name], [l1].[LocustHordeId], [l1].[ThreatLevel], [l1].[ThreatLevelByte], [l1].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM [LocustHordes] AS [l] +CROSS JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -""", - // - """ -@rank='2' (Nullable = true) +LEFT JOIN [LocustCommanders] AS [l1] ON [l].[CommanderName] = [l1].[Name] +"""); + } -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Rank] | @rank <> @rank -""", - // + public override async Task Select_as_operator(bool async) + { + await base.Select_as_operator(async); + + AssertSql( + """ +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] +FROM [LocustLeaders] AS [l] +UNION ALL +SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] +FROM [LocustCommanders] AS [l0] +"""); + } + + public override async Task Select_datetimeoffset_comparison_in_projection(bool async) + { + await base.Select_datetimeoffset_comparison_in_projection(async); + + AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 0 = 1 +SELECT CASE + WHEN [m].[Timeline] > SYSDATETIMEOFFSET() THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Missions] AS [m] """); } - public override async Task FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(bool async) + public override async Task OfType_in_subquery_works(bool async) { - await base.FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(async); + await base.OfType_in_subquery_works(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] -WHERE [c].[Name] = ( - SELECT TOP(1) [c0].[Name] - FROM ( - SELECT [g0].[Nickname], [g0].[CityOfBirthName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[CityOfBirthName] - FROM [Officers] AS [o0] - ) AS [u0] - INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] - ORDER BY [u0].[Nickname]) OR ([c].[Name] IS NULL AND ( - SELECT TOP(1) [c0].[Name] +SELECT [s].[Name], [s].[Location], [s].[Nation] +FROM [Officers] AS [o] +INNER JOIN ( + SELECT [c].[Name], [c].[Location], [c].[Nation], [u].[LeaderNickname], [u].[LeaderSquadId] FROM ( - SELECT [g0].[Nickname], [g0].[CityOfBirthName] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[CityOfBirthName] + SELECT [o0].[AssignedCityName], [o0].[LeaderNickname], [o0].[LeaderSquadId] FROM [Officers] AS [o0] - ) AS [u0] - INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] - ORDER BY [u0].[Nickname]) IS NULL) + ) AS [u] + LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] +) AS [s] ON [o].[Nickname] = [s].[LeaderNickname] AND [o].[SquadId] = [s].[LeaderSquadId] """); } - public override async Task Bitwise_operation_with_non_null_parameter_optimizes_null_checks(bool async) + public override async Task Nullable_bool_comparison_is_translated_to_server(bool async) { - await base.Bitwise_operation_with_non_null_parameter_optimizes_null_checks(async); + await base.Nullable_bool_comparison_is_translated_to_server(async); AssertSql( """ -@ranks='134' +SELECT CASE + WHEN [l].[Eradicated] = CAST(1 AS bit) AND [l].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [IsEradicated] +FROM [LocustHordes] AS [l] +"""); + } -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[Rank] & @ranks <> 0 -""", - // - """ -@ranks='134' + public override async Task Accessing_reference_navigation_collection_composition_generates_single_query(bool async) + { + await base.Accessing_reference_navigation_collection_composition_generates_single_query(async); -SELECT ~CAST(([u].[Rank] | @ranks) ^ @ranks AS bit) -FROM ( - SELECT [g].[Rank] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Rank] - FROM [Officers] AS [o] -) AS [u] -""", - // + AssertSql( """ -@ranks='134' - -SELECT ~CAST(([u].[Rank] | [u].[Rank] | @ranks | [u].[Rank] | @ranks) ^ @ranks AS bit) +SELECT [u].[Nickname], [u].[SquadId], [s].[Id], [s].[IsAutomatic], [s].[Name], [s].[Id0] FROM ( - SELECT [g].[Rank] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Rank] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] +LEFT JOIN ( + SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +) AS [s] ON [u].[FullName] = [s].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id] """); } - public override async Task Bitwise_operation_with_null_arguments(bool async) + public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) { - await base.Bitwise_operation_with_null_arguments(async); + await base.Reference_include_chain_loads_correctly_when_middle_is_null(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -""", - // - """ -@prm='2' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @prm <> 0 OR [w].[AmmunitionType] IS NULL -""", - // - """ -@prm='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @prm = @prm +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] +ORDER BY [t].[Note] """); } - public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) + public override async Task Accessing_property_of_optional_navigation_in_child_projection_works(bool async) { - await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); + await base.Accessing_property_of_optional_navigation_in_child_projection_works(async); AssertSql( """ -@prm='True' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u].[HasSoulPatch] <> @prm -""", - // - """ -@prm='False' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] +SELECT CASE + WHEN [u].[Nickname] IS NOT NULL AND [u].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [t].[Id], [u].[Nickname], [u].[SquadId], [s].[Nickname], [s].[Id], [s].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] -WHERE [u].[HasSoulPatch] <> @prm +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN ( + SELECT [u0].[Nickname], [w].[Id], [u0].[SquadId], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] ON [w].[OwnerFullName] = [u0].[FullName] +) AS [s] ON [u].[FullName] = [s].[OwnerFullName] +ORDER BY [t].[Note], [t].[Id], [u].[Nickname], [u].[SquadId], [s].[Id], [s].[Nickname] """); } - public override async Task Cast_OfType_works_correctly(bool async) + public override async Task Collection_navigation_ofType_filter_works(bool async) { - await base.Cast_OfType_works_correctly(async); + await base.Collection_navigation_ofType_filter_works(async); AssertSql( """ -SELECT [o].[FullName] -FROM [Officers] AS [o] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [o].[Nickname], [o].[CityOfBirthName] + FROM [Officers] AS [o] + ) AS [u] + WHERE [c].[Name] = [u].[CityOfBirthName] AND [u].[Nickname] = N'Marcus') """); } - public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) + public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) { - await base.Join_inner_source_custom_projection_followed_by_filter(async); + await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); AssertSql( """ -SELECT CASE - WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) -END AS [IsEradicated], [l1].[CommanderName], [l1].[Name] +@prm_Inner_Nickname='Marcus' (Size = 450) + +SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [l].[Name] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name] - FROM [LocustCommanders] AS [l0] -) AS [u] -INNER JOIN [LocustHordes] AS [l1] ON [u].[Name] = [l1].[CommanderName] -WHERE CASE - WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) -END = CAST(0 AS bit) OR CASE - WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) -END IS NULL + SELECT DISTINCT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u].[Nickname] <> @prm_Inner_Nickname +) AS [u0] +ORDER BY [u0].[FullName] """); } - public override async Task Byte_array_contains_literal(bool async) + public override async Task Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(bool async) { - await base.Byte_array_contains_literal(async); + await base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CHARINDEX(0x01, [s].[Banner]) > 0 -"""); - } - - public override async Task Byte_array_filter_by_length_literal(bool async) - { - await base.Byte_array_filter_by_length_literal(async); +@squadId='1' - AssertSql( - """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = 2 +SELECT [u1].[Nickname], [u1].[SquadId], [u1].[AssignedCityName], [u1].[CityOfBirthName], [u1].[FullName], [u1].[HasSoulPatch], [u1].[LeaderNickname], [u1].[LeaderSquadId], [u1].[Rank], [u1].[Discriminator] +FROM ( + SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] + INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] + WHERE [s].[Id] IN ( + SELECT [s0].[Id] + FROM [Squads] AS [s0] + WHERE [s0].[Id] = @squadId + ) + UNION ALL + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Squads] AS [s1] ON [u0].[SquadId] = [s1].[Id] + WHERE [s1].[Id] IN ( + SELECT [s2].[Id] + FROM [Squads] AS [s2] + WHERE [s2].[Id] = @squadId + ) +) AS [u1] +ORDER BY [u1].[FullName] """); } - public override async Task Byte_array_filter_by_length_parameter(bool async) + public override async Task Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(bool async) { - await base.Byte_array_filter_by_length_parameter(async); + await base.Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(async); AssertSql( """ -@p='2' +@gearId='1' SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = @p +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[SquadId] = @gearId AND [u].[SquadId] = @gearId) """); } - public override void Byte_array_filter_by_length_parameter_compiled() + public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(bool async) { - base.Byte_array_filter_by_length_parameter_compiled(); + await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(async); AssertSql( """ -@byteArrayParam='0x2A80' (Size = 8000) +@entity_equality_prm_Inner_Squad_Id='1' (Nullable = true) -SELECT COUNT(*) -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@byteArrayParam) AS int) +SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] +FROM ( + SELECT DISTINCT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] + INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] + WHERE [s].[Id] = @entity_equality_prm_Inner_Squad_Id +) AS [s1] +INNER JOIN [Squads] AS [s0] ON [s1].[SquadId] = [s0].[Id] +WHERE [s0].[Id] = @entity_equality_prm_Inner_Squad_Id +ORDER BY [s1].[FullName] """); } - public override async Task Byte_array_contains_parameter(bool async) + public override async Task Complex_GroupBy_after_set_operator(bool async) { - await base.Byte_array_contains_parameter(async); + await base.Complex_GroupBy_after_set_operator(async); AssertSql( """ -@someByte='1' (Size = 1) - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CHARINDEX(CAST(@someByte AS varbinary(max)), [s].[Banner]) > 0 +SELECT [u1].[Name], [u1].[Count], COALESCE(SUM([u1].[Count]), 0) AS [Sum] +FROM ( + SELECT [c].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]) AS [Count] + FROM ( + SELECT [g].[AssignedCityName], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[AssignedCityName], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] + LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] + UNION ALL + SELECT [c0].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [u0].[FullName] = [w0].[OwnerFullName]) AS [Count] + FROM ( + SELECT [g0].[CityOfBirthName], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[CityOfBirthName], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] +) AS [u1] +GROUP BY [u1].[Name], [u1].[Count] """); } - public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) + public override async Task Complex_GroupBy_after_set_operator_using_result_selector(bool async) { - await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); + await base.Complex_GroupBy_after_set_operator_using_result_selector(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE DATALENGTH([s].[Banner5]) = 5 +SELECT [u1].[Name], [u1].[Count], COALESCE(SUM([u1].[Count]), 0) AS [Sum] +FROM ( + SELECT [c].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [u].[FullName] = [w].[OwnerFullName]) AS [Count] + FROM ( + SELECT [g].[AssignedCityName], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[AssignedCityName], [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] + LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] + UNION ALL + SELECT [c0].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [u0].[FullName] = [w0].[OwnerFullName]) AS [Count] + FROM ( + SELECT [g0].[CityOfBirthName], [g0].[FullName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[CityOfBirthName], [o0].[FullName] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] +) AS [u1] +GROUP BY [u1].[Name], [u1].[Count] """); } - public override async Task Conditional_expression_with_test_being_simplified_to_constant_simple(bool isAsync) + public override async Task Left_join_with_GroupBy_with_composite_group_key(bool async) { - await base.Conditional_expression_with_test_being_simplified_to_constant_simple(isAsync); + await base.Left_join_with_GroupBy_with_composite_group_key(async); AssertSql( """ -@prm='True' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u].[CityOfBirthName], [u].[HasSoulPatch] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName], [o].[HasSoulPatch] FROM [Officers] AS [o] ) AS [u] -WHERE CASE - WHEN [u].[HasSoulPatch] = @prm THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] +GROUP BY [u].[CityOfBirthName], [u].[HasSoulPatch] """); } - public override async Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) + public override async Task GroupBy_with_boolean_grouping_key(bool async) { - await base.Conditional_expression_with_test_being_simplified_to_constant_complex(isAsync); + await base.GroupBy_with_boolean_grouping_key(async); AssertSql( """ -@prm='True' -@prm2='Marcus' Lancer' (Size = 4000) - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +SELECT [u0].[CityOfBirthName], [u0].[HasSoulPatch], [u0].[IsMarcus], COUNT(*) AS [Count] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + SELECT [u].[CityOfBirthName], [u].[HasSoulPatch], CASE + WHEN [u].[Nickname] = N'Marcus' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [IsMarcus] + FROM ( + SELECT [g].[Nickname], [g].[CityOfBirthName], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[CityOfBirthName], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] +) AS [u0] +GROUP BY [u0].[CityOfBirthName], [u0].[HasSoulPatch], [u0].[IsMarcus] +"""); + } + + public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) + { + await base.GroupBy_with_boolean_groupin_key_thru_navigation_access(async); + + AssertSql( + """ +SELECT [u].[HasSoulPatch], LOWER([s].[Name]) AS [Name] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] 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] + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] FROM [Officers] AS [o] -) AS [u] -WHERE CASE - WHEN [u].[HasSoulPatch] = @prm AND ( - SELECT TOP(1) [w].[Name] - FROM [Weapons] AS [w] - WHERE [w].[Id] = [u].[SquadId]) = @prm2 THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +LEFT JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] +GROUP BY [u].[HasSoulPatch], [s].[Name] """); } - public override async Task OrderBy_bool_coming_from_optional_navigation(bool async) + public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) { - await base.OrderBy_bool_coming_from_optional_navigation(async); + await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w0].[IsAutomatic] +SELECT [c].[Name] +FROM ( + SELECT [g].[CityOfBirthName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[CityOfBirthName] + FROM [Officers] AS [o] +) AS [u] +INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] +GROUP BY [c].[Name] """); } - public override async Task DateTimeOffset_Date_returns_datetime(bool async) + public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async) { - await base.DateTimeOffset_Date_returns_datetime(async); + await base.Group_by_on_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -@dateTimeOffset_Date='0002-03-01T00:00:00.0000000' - -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONVERT(date, [m].[Timeline]) >= @dateTimeOffset_Date +SELECT [u0].[Key] +FROM ( + SELECT CAST(0 AS bit) AS [Key] + FROM ( + SELECT [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[FullName] + FROM [Officers] AS [o] + ) AS [u] +) AS [u0] +GROUP BY [u0].[Key] """); } - public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async) + public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async); + await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ SELECT [u].[FullName] FROM ( - SELECT [g].[Nickname], [g].[CityOfBirthName], [g].[FullName] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[CityOfBirthName], [o].[FullName] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] +GROUP BY [u].[FullName] +HAVING 0 = 1 """); } - public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async) + public override async Task Select_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async); + await base.Select_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT [u].[CityOfBirthName] +SELECT CAST(0 AS bit) FROM ( - SELECT [g].[Nickname], [g].[CityOfBirthName], [g].[FullName] + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[CityOfBirthName], [o].[FullName] + SELECT [o].[FullName] FROM [Officers] AS [o] ) AS [u] """); } - public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async) + public override async Task Select_null_parameter_is_not_null(bool async) { - await base.Projecting_required_string_column_compared_to_null_parameter(async); + await base.Select_null_parameter_is_not_null(async); AssertSql( """ -SELECT CAST(0 AS bit) +@p='False' + +SELECT @p FROM ( - SELECT [g].[Nickname] + SELECT 1 AS empty FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname] + SELECT 1 AS empty FROM [Officers] AS [o] ) AS [u] """); } - public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) + public override async Task Where_null_parameter_is_not_null(bool async) { - await base.Byte_array_filter_by_SequenceEqual(isAsync); + await base.Where_null_parameter_is_not_null(async); AssertSql( """ -@byteArrayParam='0x0405060708' (Size = 5) +@p='False' -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE [s].[Banner5] = @byteArrayParam +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 @p = CAST(1 AS bit) """); } - public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) + public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); + await base.OrderBy_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT [w0].[Key] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [Key] - FROM [Weapons] AS [w] -) AS [w0] -GROUP BY [w0].[Key] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +ORDER BY [u].[Nickname] """); } - public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) + public override async Task OrderBy_Contains_empty_list(bool async) { - await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); + await base.OrderBy_Contains_empty_list(async); AssertSql( """ -SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) +@ids='[]' (Size = 4000) + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +ORDER BY CASE + WHEN [u].[SquadId] IN ( + SELECT [i].[value] + FROM OPENJSON(@ids) WITH ([value] int '$') AS [i] + ) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END -FROM [Weapons] AS [w] -GROUP BY [w].[SynergyWithId] """); } - public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) + public override async Task Where_with_enum_flags_parameter(bool async) { - await base.Checked_context_with_cast_does_not_fail(isAsync); + await base.Where_with_enum_flags_parameter(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +@rank='1' (Nullable = true) + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] + 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 CAST([u].[ThreatLevel] AS tinyint) >= CAST(5 AS tinyint) -"""); - } - - public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) - { - await base.Checked_context_with_addition_does_not_fail(isAsync); +WHERE [u].[Rank] & @rank = @rank +""", + // + """ +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +""", + // + """ +@rank='2' (Nullable = true) - AssertSql( +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u].[Rank] | @rank <> @rank +""", + // """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] + 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 CAST([u].[ThreatLevel] AS bigint) <= CAST(5 AS bigint) + CAST([u].[ThreatLevel] AS bigint) +WHERE 0 = 1 """); } - public override async Task TimeSpan_Hours(bool async) + public override async Task FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(bool async) { - await base.TimeSpan_Hours(async); + await base.FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(async); AssertSql( """ -SELECT DATEPART(hour, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +LEFT JOIN [Cities] AS [c] ON [u].[AssignedCityName] = [c].[Name] +WHERE [c].[Name] = ( + SELECT TOP(1) [c0].[Name] + FROM ( + SELECT [g0].[Nickname], [g0].[CityOfBirthName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[CityOfBirthName] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] + ORDER BY [u0].[Nickname]) OR ([c].[Name] IS NULL AND ( + SELECT TOP(1) [c0].[Name] + FROM ( + SELECT [g0].[Nickname], [g0].[CityOfBirthName] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[CityOfBirthName] + FROM [Officers] AS [o0] + ) AS [u0] + INNER JOIN [Cities] AS [c0] ON [u0].[CityOfBirthName] = [c0].[Name] + ORDER BY [u0].[Nickname]) IS NULL) """); } - public override async Task TimeSpan_Minutes(bool async) + public override async Task Bitwise_operation_with_non_null_parameter_optimizes_null_checks(bool async) { - await base.TimeSpan_Minutes(async); + await base.Bitwise_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( """ -SELECT DATEPART(minute, [m].[Duration]) -FROM [Missions] AS [m] -"""); - } +@ranks='134' - public override async Task TimeSpan_Seconds(bool async) - { - await base.TimeSpan_Seconds(async); +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u].[Rank] & @ranks <> 0 +""", + // + """ +@ranks='134' - AssertSql( +SELECT ~CAST(([u].[Rank] | @ranks) ^ @ranks AS bit) +FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Rank] + FROM [Officers] AS [o] +) AS [u] +""", + // """ -SELECT DATEPART(second, [m].[Duration]) -FROM [Missions] AS [m] +@ranks='134' + +SELECT ~CAST(([u].[Rank] | [u].[Rank] | @ranks | [u].[Rank] | @ranks) ^ @ranks AS bit) +FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Rank] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task TimeSpan_Milliseconds(bool async) + public override async Task Bitwise_operation_with_null_arguments(bool async) { - await base.TimeSpan_Milliseconds(async); + await base.Bitwise_operation_with_null_arguments(async); AssertSql( """ -SELECT DATEPART(millisecond, [m].[Duration]) -FROM [Missions] AS [m] -"""); - } - - public override async Task Where_TimeSpan_Hours(bool async) - { - await base.Where_TimeSpan_Hours(async); - - AssertSql( +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Duration]) = 1 -"""); - } - - public override async Task Where_TimeSpan_Minutes(bool async) - { - await base.Where_TimeSpan_Minutes(async); - - AssertSql( +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Duration]) = 2 -"""); - } - - public override async Task Where_TimeSpan_Seconds(bool async) - { - await base.Where_TimeSpan_Seconds(async); - - AssertSql( +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Duration]) = 3 -"""); - } - - public override async Task Where_TimeSpan_Milliseconds(bool async) - { - await base.Where_TimeSpan_Milliseconds(async); +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +""", + // + """ +@prm='2' (Nullable = true) - AssertSql( +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] & @prm <> 0 OR [w].[AmmunitionType] IS NULL +""", + // """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Duration]) = 456 +@prm='1' (Nullable = true) + +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] & @prm = @prm """); } - public override async Task Contains_on_collection_of_byte_subquery(bool async) + public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) { - await base.Contains_on_collection_of_byte_subquery(async); + await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +@prm='True' + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] + 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 [u].[ThreatLevelByte] IN ( - SELECT [l1].[ThreatLevelByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelByte] - FROM [LocustCommanders] AS [l2] -) -"""); - } - - public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) - { - await base.Contains_on_collection_of_nullable_byte_subquery(async); - - AssertSql( +WHERE [u].[HasSoulPatch] <> @prm +""", + // """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +@prm='False' + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] + 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 EXISTS ( - SELECT 1 - FROM ( - SELECT [l1].[ThreatLevelNullableByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelNullableByte] - FROM [LocustCommanders] AS [l2] - ) AS [u0] - WHERE [u0].[ThreatLevelNullableByte] = [u].[ThreatLevelNullableByte] OR ([u0].[ThreatLevelNullableByte] IS NULL AND [u].[ThreatLevelNullableByte] IS NULL)) +WHERE [u].[HasSoulPatch] <> @prm """); } - public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) + public override async Task Cast_OfType_works_correctly(bool async) { - await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); + await base.Cast_OfType_works_correctly(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [l1].[ThreatLevelNullableByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelNullableByte] - FROM [LocustCommanders] AS [l2] - ) AS [u0] - WHERE [u0].[ThreatLevelNullableByte] IS NULL) +SELECT [o].[FullName] +FROM [Officers] AS [o] """); } - public override async Task Contains_on_collection_of_nullable_byte_subquery_null_parameter(bool async) + public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) { - await base.Contains_on_collection_of_nullable_byte_subquery_null_parameter(async); + await base.Join_inner_source_custom_projection_followed_by_filter(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +SELECT CASE + WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) +END AS [IsEradicated], [l1].[CommanderName], [l1].[Name] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + SELECT [l].[Name] FROM [LocustLeaders] AS [l] UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + SELECT [l0].[Name] FROM [LocustCommanders] AS [l0] ) AS [u] -WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [l1].[ThreatLevelNullableByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelNullableByte] - FROM [LocustCommanders] AS [l2] - ) AS [u0] - WHERE [u0].[ThreatLevelNullableByte] IS NULL) +INNER JOIN [LocustHordes] AS [l1] ON [u].[Name] = [l1].[CommanderName] +WHERE CASE + WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) +END = CAST(0 AS bit) OR CASE + WHEN [l1].[Name] = N'Locust' THEN CAST(1 AS bit) +END IS NULL """); } - public override async Task Contains_on_byte_array_property_using_byte_column(bool async) + public override async Task Byte_array_contains_literal(bool async) { - await base.Contains_on_byte_array_property_using_byte_column(async); + await base.Byte_array_contains_literal(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -CROSS JOIN ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -WHERE CHARINDEX(CAST([u].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0 -"""); - } - - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( - bool async) - { - await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); - - AssertSql( - """ -SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] -FROM ( - SELECT [l].[ThreatLevelByte] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[ThreatLevelByte] - FROM [LocustCommanders] AS [l0] -) AS [u] -CROSS APPLY ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] - WHERE [u].[ThreatLevelByte] IN ( - SELECT [l1].[ThreatLevelByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelByte] - FROM [LocustCommanders] AS [l2] - ) -) AS [u2] +WHERE CHARINDEX(0x01, [s].[Banner]) > 0 """); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( - bool async) + public override async Task Byte_array_filter_by_length_literal(bool async) { - await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); + await base.Byte_array_filter_by_length_literal(async); AssertSql( """ -SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] -FROM ( - SELECT [l].[ThreatLevelByte] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[ThreatLevelByte] - FROM [LocustCommanders] AS [l0] -) AS [u] -CROSS APPLY ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] - WHERE [u].[ThreatLevelByte] NOT IN ( - SELECT [l1].[ThreatLevelByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelByte] - FROM [LocustCommanders] AS [l2] - ) -) AS [u2] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = 2 """); } - public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) + public override async Task Byte_array_filter_by_length_parameter(bool async) { - await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async); + await base.Byte_array_filter_by_length_parameter(async); AssertSql( """ -SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] -FROM ( - SELECT [l].[ThreatLevelNullableByte] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[ThreatLevelNullableByte] - FROM [LocustCommanders] AS [l0] -) AS [u] -CROSS APPLY ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] - WHERE EXISTS ( - SELECT 1 - FROM ( - SELECT [l1].[ThreatLevelNullableByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelNullableByte] - FROM [LocustCommanders] AS [l2] - ) AS [u1] - WHERE [u1].[ThreatLevelNullableByte] = [u].[ThreatLevelNullableByte] OR ([u1].[ThreatLevelNullableByte] IS NULL AND [u].[ThreatLevelNullableByte] IS NULL)) -) AS [u2] +@p='2' + +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = @p """); } - public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) + public override void Byte_array_filter_by_length_parameter_compiled() { - await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async); + base.Byte_array_filter_by_length_parameter_compiled(); AssertSql( """ -SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] -FROM ( - SELECT [l].[ThreatLevelNullableByte] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[ThreatLevelNullableByte] - FROM [LocustCommanders] AS [l0] -) AS [u] -CROSS APPLY ( - SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] - WHERE NOT EXISTS ( - SELECT 1 - FROM ( - SELECT [l1].[ThreatLevelNullableByte] - FROM [LocustLeaders] AS [l1] - UNION ALL - SELECT [l2].[ThreatLevelNullableByte] - FROM [LocustCommanders] AS [l2] - ) AS [u1] - WHERE [u1].[ThreatLevelNullableByte] = [u].[ThreatLevelNullableByte] OR ([u1].[ThreatLevelNullableByte] IS NULL AND [u].[ThreatLevelNullableByte] IS NULL)) -) AS [u2] +@byteArrayParam='0x2A80' (Size = 8000) + +SELECT COUNT(*) +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@byteArrayParam) AS int) """); } - public override async Task Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) + public override async Task Byte_array_contains_parameter(bool async) { - await base.Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(async); + await base.Byte_array_contains_parameter(async); AssertSql( """ -@prm='1' (Nullable = true) +@someByte='1' (Size = 1) -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE @prm = [w].[AmmunitionType] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CHARINDEX(CAST(@someByte AS varbinary(max)), [s].[Banner]) > 0 """); } - public override async Task Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) + public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) { - await base.Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(async); + await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); AssertSql( """ -@prm='133' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 @prm & [u].[Rank] = [u].[Rank] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE DATALENGTH([s].[Banner5]) = 5 """); } - public override async Task Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(bool async) + public override async Task Conditional_expression_with_test_being_simplified_to_constant_simple(bool isAsync) { - await base.Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(async); + await base.Conditional_expression_with_test_being_simplified_to_constant_simple(isAsync); AssertSql( """ -@prm='5' +@prm='True' SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( @@ -10841,444 +9433,492 @@ 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 @prm & CAST([u].[Rank] AS int) = CAST([u].[Rank] AS int) +WHERE CASE + WHEN [u].[HasSoulPatch] = @prm THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) + public override async Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) { - await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); + await base.Conditional_expression_with_test_being_simplified_to_constant_complex(isAsync); AssertSql( """ -@p='1' +@prm='True' +@prm2='Marcus' Lancer' (Size = 4000) -SELECT TOP(@p) [u].[Rank] & 1 +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[Rank] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[Rank] + 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] -ORDER BY [u].[Nickname] +WHERE CASE + WHEN [u].[HasSoulPatch] = @prm AND ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [w].[Id] = [u].[SquadId]) = @prm2 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Enum_array_contains(bool async) + public override async Task OrderBy_bool_coming_from_optional_navigation(bool async) { - await base.Enum_array_contains(async); + await base.OrderBy_bool_coming_from_optional_navigation(async); AssertSql( """ -@types_without_nulls='[1]' (Size = 4000) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -WHERE [w0].[Id] IS NOT NULL AND ([w0].[AmmunitionType] IN ( - SELECT [t].[value] - FROM OPENJSON(@types_without_nulls) AS [t] -) OR [w0].[AmmunitionType] IS NULL) +ORDER BY [w0].[IsAutomatic] """); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public async Task DataLength_function_for_string_parameter(bool async) + public override async Task DateTimeOffset_Date_returns_datetime(bool async) { - await AssertQueryScalar( - async, - ss => ss.Set().Select(m => EF.Functions.DataLength(m.CodeName)), - ss => ss.Set().Select(m => (int?)(m.CodeName.Length * 2))); + await base.DateTimeOffset_Date_returns_datetime(async); AssertSql( """ -SELECT CAST(DATALENGTH([m].[CodeName]) AS int) +@dateTimeOffset_Date='0002-03-01T00:00:00.0000000' + +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] FROM [Missions] AS [m] +WHERE CONVERT(date, [m].[Timeline]) >= @dateTimeOffset_Date """); } - public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) + public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async) { - await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); + await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' +SELECT [u].[FullName] +FROM ( + SELECT [g].[Nickname], [g].[CityOfBirthName], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[CityOfBirthName], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task Coalesce_used_with_non_unicode_string_column_and_constant(bool async) + public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async) { - await base.Coalesce_used_with_non_unicode_string_column_and_constant(async); + await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async); AssertSql( """ -SELECT COALESCE([c].[Location], 'Unknown') -FROM [Cities] AS [c] +SELECT [u].[CityOfBirthName] +FROM ( + SELECT [g].[Nickname], [g].[CityOfBirthName], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[CityOfBirthName], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] """); } - public override async Task Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(bool async) + public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async) { - await base.Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(async); + await base.Projecting_required_string_column_compared_to_null_parameter(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], COUNT(*) AS [Count] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[CityOfBirthName], [g].[FullName] +SELECT CAST(0 AS bit) +FROM ( + SELECT [g].[Nickname] FROM [Gears] AS [g] UNION ALL - SELECT [o].[CityOfBirthName], [o].[FullName] + SELECT [o].[Nickname] FROM [Officers] AS [o] -) AS [u] ON [w].[OwnerFullName] = [u].[FullName] -LEFT JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -GROUP BY [c].[Name], [c].[Location] -ORDER BY [c].[Location] +) AS [u] """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(bool async) + public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) { - await base.SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(async); + await base.Byte_array_filter_by_SequenceEqual(isAsync); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -INNER JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL -ORDER BY [u].[Nickname], [w].[Id] +@byteArrayParam='0x0405060708' (Size = 5) + +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Banner5] = @byteArrayParam """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) + public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) { - await base.SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); + await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w0].[Key] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL -ORDER BY [u].[Nickname], [w].[Id] + SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [Key] + FROM [Weapons] AS [w] +) AS [w0] +GROUP BY [w0].[Key] +"""); + } + + public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) + { + await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); + + AssertSql( + """ +SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Weapons] AS [w] +GROUP BY [w].[SynergyWithId] """); } - public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( - bool async) + public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) { - await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); + await base.Checked_context_with_cast_does_not_fail(isAsync); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] 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] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w] - LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [u].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL -ORDER BY [u].[Nickname], [s].[Id] +WHERE CAST([u].[ThreatLevel] AS tinyint) >= CAST(5 AS tinyint) """); } - public override async Task SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(bool async) + public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) { - await base.SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(async); + await base.Checked_context_with_addition_does_not_fail(isAsync); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM ( - SELECT [g].[FullName] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[FullName] - FROM [Officers] AS [o] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +WHERE CAST([u].[ThreatLevel] AS bigint) <= CAST(5 AS bigint) + CAST([u].[ThreatLevel] AS bigint) """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(bool async) + public override async Task Contains_on_collection_of_byte_subquery(bool async) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(async); + await base.Contains_on_collection_of_byte_subquery(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] AND [u].[SquadId] < [w].[Id] -ORDER BY [u].[Nickname], [u].[SquadId] +WHERE [u].[ThreatLevelByte] IN ( + SELECT [l1].[ThreatLevelByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelByte] + FROM [LocustCommanders] AS [l2] +) """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(async); + await base.Contains_on_collection_of_nullable_byte_subquery(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] AND [u].[SquadId] <= [w].[Id] -ORDER BY [u].[Nickname], [u].[SquadId] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [l1].[ThreatLevelNullableByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelNullableByte] + FROM [LocustCommanders] AS [l2] + ) AS [u0] + WHERE [u0].[ThreatLevelNullableByte] = [u].[ThreatLevelNullableByte] OR ([u0].[ThreatLevelNullableByte] IS NULL AND [u].[ThreatLevelNullableByte] IS NULL)) """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(async); + await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] AND [u].[SquadId] >= [w].[Id] -ORDER BY [u].[Nickname], [u].[SquadId] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [l1].[ThreatLevelNullableByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelNullableByte] + FROM [LocustCommanders] AS [l2] + ) AS [u0] + WHERE [u0].[ThreatLevelNullableByte] IS NULL) """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery_null_parameter(bool async) { - await base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async); + await base.Contains_on_collection_of_nullable_byte_subquery_null_parameter(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] 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] + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] ) AS [u] -CROSS APPLY ( - SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[OwnerFullName] <> [u].[FullName] OR [w].[OwnerFullName] IS NULL - ORDER BY [w].[Id] -) AS [w0] -ORDER BY [u].[Nickname], [w0].[Id] +WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [l1].[ThreatLevelNullableByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelNullableByte] + FROM [LocustCommanders] AS [l2] + ) AS [u0] + WHERE [u0].[ThreatLevelNullableByte] IS NULL) """); } - public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) + public override async Task Contains_on_byte_array_property_using_byte_column(bool async) { - await base.FirstOrDefault_over_int_compared_to_zero(async); + await base.Contains_on_byte_array_property_using_byte_column(async); AssertSql( """ -SELECT [s].[Name] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] FROM [Squads] AS [s] -WHERE [s].[Name] = N'Delta' AND COALESCE(( - SELECT TOP(1) [u].[SquadId] - FROM ( - SELECT [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] - FROM [Officers] AS [o] - ) AS [u] - WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit) - ORDER BY [u].[FullName]), 0) <> 0 +CROSS JOIN ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +WHERE CHARINDEX(CAST([u].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0 """); } - public override async Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( + bool async) { - await base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async); + await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); AssertSql( """ -SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [u1].[ReportName], [u1].[OfficerName], [u1].[Nickname], [u1].[SquadId] +SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] FROM ( - SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] - FROM [Officers] AS [o] + SELECT [l].[ThreatLevelByte] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[ThreatLevelByte] + FROM [LocustCommanders] AS [l0] ) AS [u] -OUTER APPLY ( - SELECT [u0].[FullName] AS [ReportName], [u].[FullName] AS [OfficerName], [u0].[Nickname], [u0].[SquadId] +CROSS APPLY ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] - FROM [Officers] AS [o0] + 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 [u0] - WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] -) AS [u1] -ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] + WHERE [u].[ThreatLevelByte] IN ( + SELECT [l1].[ThreatLevelByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelByte] + FROM [LocustCommanders] AS [l2] + ) +) AS [u2] """); } - public override async Task Accessing_derived_property_using_hard_and_soft_cast(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) { - await base.Accessing_derived_property_using_hard_and_soft_cast(async); + await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] - FROM [LocustLeaders] AS [l] - UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l0] -) AS [u] -WHERE [u].[Discriminator] = N'LocustCommander' AND ([u].[HighCommandId] <> 0 OR [u].[HighCommandId] IS NULL) -""", - // - """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + SELECT [l].[ThreatLevelByte] FROM [LocustLeaders] AS [l] UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + SELECT [l0].[ThreatLevelByte] FROM [LocustCommanders] AS [l0] ) AS [u] -WHERE [u].[Discriminator] = N'LocustCommander' AND ([u].[HighCommandId] <> 0 OR [u].[HighCommandId] IS NULL) +CROSS APPLY ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u0] + WHERE [u].[ThreatLevelByte] NOT IN ( + SELECT [l1].[ThreatLevelByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelByte] + FROM [LocustCommanders] AS [l2] + ) +) AS [u2] """); } - public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) + public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) { - await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); + await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async); AssertSql( """ -SELECT TOP(1) [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + SELECT [l].[ThreatLevelNullableByte] FROM [LocustLeaders] AS [l] UNION ALL - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + SELECT [l0].[ThreatLevelNullableByte] FROM [LocustCommanders] AS [l0] ) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] -WHERE [u].[Name] LIKE N'%Queen%' +CROSS APPLY ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u0] + WHERE EXISTS ( + SELECT 1 + FROM ( + SELECT [l1].[ThreatLevelNullableByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelNullableByte] + FROM [LocustCommanders] AS [l2] + ) AS [u1] + WHERE [u1].[ThreatLevelNullableByte] = [u].[ThreatLevelNullableByte] OR ([u1].[ThreatLevelNullableByte] IS NULL AND [u].[ThreatLevelNullableByte] IS NULL)) +) AS [u2] """); } - public override async Task Correlated_collection_take(bool async) + public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) { - await base.Correlated_collection_take(async); + await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [c].[Name], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [c].[Location], [c].[Nation] +SELECT [u2].[Nickname], [u2].[SquadId], [u2].[AssignedCityName], [u2].[CityOfBirthName], [u2].[FullName], [u2].[HasSoulPatch], [u2].[LeaderNickname], [u2].[LeaderSquadId], [u2].[Rank], [u2].[Discriminator] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName], [g].[FullName] - FROM [Gears] AS [g] + SELECT [l].[ThreatLevelNullableByte] + FROM [LocustLeaders] AS [l] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName], [o].[FullName] - FROM [Officers] AS [o] + SELECT [l0].[ThreatLevelNullableByte] + FROM [LocustCommanders] AS [l0] ) AS [u] -INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +CROSS APPLY ( + SELECT [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] - FROM [Weapons] AS [w] - ) AS [w0] - WHERE [w0].[row] <= 10 -) AS [w1] ON [u].[FullName] = [w1].[OwnerFullName] -ORDER BY [u].[Nickname], [u].[SquadId], [c].[Name] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u0] + WHERE NOT EXISTS ( + SELECT 1 + FROM ( + SELECT [l1].[ThreatLevelNullableByte] + FROM [LocustLeaders] AS [l1] + UNION ALL + SELECT [l2].[ThreatLevelNullableByte] + FROM [LocustCommanders] AS [l2] + ) AS [u1] + WHERE [u1].[ThreatLevelNullableByte] = [u].[ThreatLevelNullableByte] OR ([u1].[ThreatLevelNullableByte] IS NULL AND [u].[ThreatLevelNullableByte] IS NULL)) +) AS [u2] """); } - public override async Task First_on_byte_array(bool async) + public override async Task Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) { - await base.First_on_byte_array(async); + await base.Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(SUBSTRING([s].[Banner], 1, 1) AS tinyint) = CAST(2 AS tinyint) -"""); - } - - public override async Task Array_access_on_byte_array(bool async) - { - await base.Array_access_on_byte_array(async); +@prm='1' (Nullable = true) - AssertSql( - """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(SUBSTRING([s].[Banner5], 2 + 1, 1) AS tinyint) = CAST(6 AS tinyint) +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE @prm = [w].[AmmunitionType] """); } - public override async Task Project_shadow_properties(bool async) + public override async Task Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) { - await base.Project_shadow_properties(async); + await base.Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [g].[Nickname], [g].[AssignedCityName] -FROM [Gears] AS [g] -UNION ALL -SELECT [o].[Nickname], [o].[AssignedCityName] -FROM [Officers] AS [o] -"""); - } - - public override async Task Composite_key_entity_equal(bool async) - { - await base.Composite_key_entity_equal(async); +@prm='133' - AssertSql( - """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -11286,24 +9926,19 @@ 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] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] -WHERE [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] +WHERE @prm & [u].[Rank] = [u].[Rank] """); } - public override async Task Composite_key_entity_not_equal(bool async) + public override async Task Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(bool async) { - await base.Composite_key_entity_not_equal(async); + await base.Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +@prm='5' + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] @@ -11311,566 +9946,630 @@ 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] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g0] - UNION ALL - SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] - FROM [Officers] AS [o0] -) AS [u0] -WHERE [u].[Nickname] <> [u0].[Nickname] OR [u].[SquadId] <> [u0].[SquadId] +WHERE @prm & CAST([u].[Rank] AS int) = CAST([u].[Rank] AS int) """); } - public override async Task Composite_key_entity_equal_null(bool async) + public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) { - await base.Composite_key_entity_equal_null(async); + await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); AssertSql( """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] -FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l] -) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] -WHERE [u0].[Nickname] IS NULL OR [u0].[SquadId] IS NULL -"""); - } - - public override async Task Composite_key_entity_not_equal_null(bool async) - { - await base.Composite_key_entity_not_equal_null(async); +@p='1' - AssertSql( - """ -SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +SELECT TOP(@p) [u].[Rank] & 1 FROM ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], N'LocustCommander' AS [Discriminator] - FROM [LocustCommanders] AS [l] -) AS [u] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] + SELECT [g].[Nickname], [g].[Rank] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[Nickname], [o].[Rank] FROM [Officers] AS [o] -) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] -WHERE [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL +) AS [u] +ORDER BY [u].[Nickname] """); } - public override async Task Projecting_property_converted_to_nullable_with_comparison(bool async) + public override async Task Enum_array_contains(bool async) { - await base.Projecting_property_converted_to_nullable_with_comparison(async); + await base.Enum_array_contains(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u].[Nickname], [u].[SquadId], [u].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END = 1 -"""); - } - - public override async Task Projecting_property_converted_to_nullable_with_addition(bool async) - { - await base.Projecting_property_converted_to_nullable_with_addition(async); +@types_without_nulls='[1]' (Size = 4000) - AssertSql( - """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u].[Nickname], [u].[SquadId], [u].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END + 1 = 2 +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +WHERE [w0].[Id] IS NOT NULL AND ([w0].[AmmunitionType] IN ( + SELECT [t].[value] + FROM OPENJSON(@types_without_nulls) AS [t] +) OR [w0].[AmmunitionType] IS NULL) """); } - public override async Task Projecting_property_converted_to_nullable_with_addition_and_final_projection(bool async) + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DataLength_function_for_string_parameter(bool async) { - await base.Projecting_property_converted_to_nullable_with_addition_and_final_projection(async); + await AssertQueryScalar( + async, + ss => ss.Set().Select(m => EF.Functions.DataLength(m.CodeName)), + ss => ss.Set().Select(m => (int?)(m.CodeName.Length * 2))); AssertSql( - """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END + 1 AS [Value] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END IS NOT NULL + """ +SELECT CAST(DATALENGTH([m].[CodeName]) AS int) +FROM [Missions] AS [m] """); } - public override async Task Projecting_property_converted_to_nullable_with_conditional(bool async) + public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) { - await base.Projecting_property_converted_to_nullable_with_conditional(async); + await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); AssertSql( """ -SELECT CASE - WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] - END - ELSE -1 -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - UNION ALL - SELECT [o].[Nickname], [o].[SquadId] - FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' """); } - public override async Task Projecting_property_converted_to_nullable_with_function_call(bool async) + public override async Task Coalesce_used_with_non_unicode_string_column_and_constant(bool async) { - await base.Projecting_property_converted_to_nullable_with_function_call(async); + await base.Coalesce_used_with_non_unicode_string_column_and_constant(async); AssertSql( """ -SELECT SUBSTRING(CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END, 0 + 1, 3) -FROM [Tags] AS [t] +SELECT COALESCE([c].[Location], 'Unknown') +FROM [Cities] AS [c] +"""); + } + + public override async Task Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(bool async) + { + await base.Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(async); + + AssertSql( + """ +SELECT [c].[Name], [c].[Location], COUNT(*) AS [Count] +FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] + SELECT [g].[CityOfBirthName], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[CityOfBirthName], [o].[FullName] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +) AS [u] ON [w].[OwnerFullName] = [u].[FullName] +LEFT JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] +GROUP BY [c].[Name], [c].[Location] +ORDER BY [c].[Location] """); } - public override async Task Projecting_property_converted_to_nullable_with_function_call2(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(bool async) { - await base.Projecting_property_converted_to_nullable_with_function_call2(async); + await base.SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(async); AssertSql( """ -SELECT [t].[Note], SUBSTRING([t].[Note], 0 + 1, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END) AS [Function] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END IS NOT NULL +) AS [u] +INNER JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +ORDER BY [u].[Nickname], [w].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_into_element_init(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) { - await base.Projecting_property_converted_to_nullable_into_element_init(async); + await base.SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([u].[Nickname]) AS int) -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END + 1 -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +ORDER BY [u].[Nickname], [w].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_into_member_assignment(bool async) + public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( + bool async) { - await base.Projecting_property_converted_to_nullable_into_member_assignment(async); + await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END AS [Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + 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] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +) AS [u] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w] + LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +) AS [s] ON [u].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL +ORDER BY [u].[Nickname], [s].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_into_new_array(bool async) + public override async Task SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(bool async) { - await base.Projecting_property_converted_to_nullable_into_new_array(async); + await base.SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([u].[Nickname]) AS int) -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END + 1 -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId] + SELECT [o].[FullName] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL """); } - public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(bool async) { - await base.Projecting_property_converted_to_nullable_into_unary(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(async); AssertSql( """ -SELECT [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END IS NOT NULL AND CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[HasSoulPatch] -END = CAST(0 AS bit) -ORDER BY [t].[Note] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] AND [u].[SquadId] < [w].[Id] +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(bool async) { - await base.Projecting_property_converted_to_nullable_into_member_access(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(async); AssertSql( """ -SELECT [u].[Nickname] +SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] ) AS [u] -LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] -WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL -ORDER BY [u].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] AND [u].[SquadId] <= [w].[Id] +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(bool async) { - await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [u].[Nickname], [u].[SquadId], [u].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] +SELECT [u].[Nickname], [u].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] UNION ALL - SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] FROM [Officers] AS [o] -) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] -END IS NOT NULL -ORDER BY CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] -END, [t].[Note] +) AS [u] +LEFT JOIN [Weapons] AS [w] ON [u].[FullName] = [w].[OwnerFullName] AND [u].[SquadId] >= [w].[Id] +ORDER BY [u].[Nickname], [u].[SquadId] """); } - public override async Task Where_DateOnly_Year(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) { - await base.Where_DateOnly_Year(async); + await base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(year, [m].[Date]) = 1990 +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +CROSS APPLY ( + SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[OwnerFullName] <> [u].[FullName] OR [w].[OwnerFullName] IS NULL + ORDER BY [w].[Id] +) AS [w0] +ORDER BY [u].[Nickname], [w0].[Id] """); } - public override async Task Where_DateOnly_Month(bool async) + public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) { - await base.Where_DateOnly_Month(async); + await base.FirstOrDefault_over_int_compared_to_zero(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(month, [m].[Date]) = 11 +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Delta' AND COALESCE(( + SELECT TOP(1) [u].[SquadId] + FROM ( + SELECT [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[SquadId], [o].[FullName], [o].[HasSoulPatch] + FROM [Officers] AS [o] + ) AS [u] + WHERE [s].[Id] = [u].[SquadId] AND [u].[HasSoulPatch] = CAST(1 AS bit) + ORDER BY [u].[FullName]), 0) <> 0 """); } - public override async Task Where_DateOnly_Day(bool async) + public override async Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async) { - await base.Where_DateOnly_Day(async); + await base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(day, [m].[Date]) = 10 +SELECT [u].[FullName], [u].[Nickname], [u].[SquadId], [u1].[ReportName], [u1].[OfficerName], [u1].[Nickname], [u1].[SquadId] +FROM ( + SELECT [o].[Nickname], [o].[SquadId], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +OUTER APPLY ( + SELECT [u0].[FullName] AS [ReportName], [u].[FullName] AS [OfficerName], [u0].[Nickname], [u0].[SquadId] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[LeaderNickname], [g].[LeaderSquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[FullName], [o0].[LeaderNickname], [o0].[LeaderSquadId] + FROM [Officers] AS [o0] + ) AS [u0] + WHERE [u].[Nickname] = [u0].[LeaderNickname] AND [u].[SquadId] = [u0].[LeaderSquadId] +) AS [u1] +ORDER BY [u].[Nickname], [u].[SquadId], [u1].[Nickname] """); } - public override async Task Where_DateOnly_DayOfYear(bool async) + public override async Task Accessing_derived_property_using_hard_and_soft_cast(bool async) { - await base.Where_DateOnly_DayOfYear(async); + await base.Accessing_derived_property_using_hard_and_soft_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(dayofyear, [m].[Date]) = 314 +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +WHERE [u].[Discriminator] = N'LocustCommander' AND ([u].[HighCommandId] <> 0 OR [u].[HighCommandId] IS NULL) +""", + // + """ +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +WHERE [u].[Discriminator] = N'LocustCommander' AND ([u].[HighCommandId] <> 0 OR [u].[HighCommandId] IS NULL) """); } - public override async Task Where_DateOnly_DayOfWeek(bool async) - { - await AssertTranslationFailed(() => base.Where_DateOnly_DayOfWeek(async)); - - AssertSql(); - } - - public override async Task Where_DateOnly_AddYears(bool async) + public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) { - await base.Where_DateOnly_AddYears(async); + await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' +SELECT TOP(1) [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], NULL AS [DefeatedByNickname], NULL AS [DefeatedBySquadId], NULL AS [HighCommandId], N'LocustLeader' AS [Discriminator] + FROM [LocustLeaders] AS [l] + UNION ALL + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l0] +) AS [u] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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 [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +WHERE [u].[Name] LIKE N'%Queen%' """); } - public override async Task Where_DateOnly_AddMonths(bool async) + public override async Task Correlated_collection_take(bool async) { - await base.Where_DateOnly_AddMonths(async); + await base.Correlated_collection_take(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' +SELECT [u].[Nickname], [u].[SquadId], [c].[Name], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [c].[Location], [c].[Nation] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName], [g].[FullName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName], [o].[FullName] + FROM [Officers] AS [o] +) AS [u] +INNER JOIN [Cities] AS [c] ON [u].[CityOfBirthName] = [c].[Name] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] + FROM [Weapons] AS [w] + ) AS [w0] + WHERE [w0].[row] <= 10 +) AS [w1] ON [u].[FullName] = [w1].[OwnerFullName] +ORDER BY [u].[Nickname], [u].[SquadId], [c].[Name] """); } - public override async Task Where_DateOnly_AddDays(bool async) + public override async Task Project_shadow_properties(bool async) { - await base.Where_DateOnly_AddDays(async); + await base.Project_shadow_properties(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' +SELECT [g].[Nickname], [g].[AssignedCityName] +FROM [Gears] AS [g] +UNION ALL +SELECT [o].[Nickname], [o].[AssignedCityName] +FROM [Officers] AS [o] """); } - public override async Task Where_TimeOnly_Hour(bool async) + public override async Task Composite_key_entity_equal(bool async) { - await base.Where_TimeOnly_Hour(async); + await base.Composite_key_entity_equal(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Time]) = 10 +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] +WHERE [u].[Nickname] = [u0].[Nickname] AND [u].[SquadId] = [u0].[SquadId] """); } - public override async Task Where_TimeOnly_Minute(bool async) + public override async Task Composite_key_entity_not_equal(bool async) { - await base.Where_TimeOnly_Minute(async); + await base.Composite_key_entity_not_equal(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Time]) = 15 +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [u0].[Nickname], [u0].[SquadId], [u0].[AssignedCityName], [u0].[CityOfBirthName], [u0].[FullName], [u0].[HasSoulPatch], [u0].[LeaderNickname], [u0].[LeaderSquadId], [u0].[Rank], [u0].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g] + 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] +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], N'Gear' AS [Discriminator] + FROM [Gears] AS [g0] + UNION ALL + SELECT [o0].[Nickname], [o0].[SquadId], [o0].[AssignedCityName], [o0].[CityOfBirthName], [o0].[FullName], [o0].[HasSoulPatch], [o0].[LeaderNickname], [o0].[LeaderSquadId], [o0].[Rank], N'Officer' AS [Discriminator] + FROM [Officers] AS [o0] +) AS [u0] +WHERE [u].[Nickname] <> [u0].[Nickname] OR [u].[SquadId] <> [u0].[SquadId] """); } - public override async Task Where_TimeOnly_Second(bool async) + public override async Task Composite_key_entity_equal_null(bool async) { - await base.Where_TimeOnly_Second(async); + await base.Composite_key_entity_equal_null(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Time]) = 50 +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l] +) AS [u] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +WHERE [u0].[Nickname] IS NULL OR [u0].[SquadId] IS NULL """); } - public override async Task Where_TimeOnly_Millisecond(bool async) + public override async Task Composite_key_entity_not_equal_null(bool async) { - await base.Where_TimeOnly_Millisecond(async); + await base.Composite_key_entity_not_equal_null(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Time]) = 500 +SELECT [u].[Name], [u].[LocustHordeId], [u].[ThreatLevel], [u].[ThreatLevelByte], [u].[ThreatLevelNullableByte], [u].[DefeatedByNickname], [u].[DefeatedBySquadId], [u].[HighCommandId], [u].[Discriminator] +FROM ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], N'LocustCommander' AS [Discriminator] + FROM [LocustCommanders] AS [l] +) AS [u] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u0] ON [u].[DefeatedByNickname] = [u0].[Nickname] AND [u].[DefeatedBySquadId] = [u0].[SquadId] +WHERE [u0].[Nickname] IS NOT NULL AND [u0].[SquadId] IS NOT NULL """); } - public override async Task Where_TimeOnly_AddHours(bool async) + public override async Task Projecting_property_converted_to_nullable_with_comparison(bool async) { - await base.Where_TimeOnly_AddHours(async); + await base.Projecting_property_converted_to_nullable_with_comparison(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u].[Nickname], [u].[SquadId], [u].[HasSoulPatch] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END = 1 """); } - public override async Task Where_TimeOnly_AddMinutes(bool async) + public override async Task Projecting_property_converted_to_nullable_with_addition(bool async) { - await base.Where_TimeOnly_AddMinutes(async); + await base.Projecting_property_converted_to_nullable_with_addition(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u].[Nickname], [u].[SquadId], [u].[HasSoulPatch] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END + 1 = 2 """); } - public override async Task Where_TimeOnly_Add_TimeSpan(bool async) - { - await AssertTranslationFailed(() => base.Where_TimeOnly_Add_TimeSpan(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_IsBetween(bool async) + public override async Task Projecting_property_converted_to_nullable_with_addition_and_final_projection(bool async) { - await base.Where_TimeOnly_IsBetween(async); + await base.Projecting_property_converted_to_nullable_with_addition_and_final_projection(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END + 1 AS [Value] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] WHERE CASE - WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END & CASE - WHEN [m].[Time] < '11:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END IS NOT NULL """); } - public override async Task Where_TimeOnly_subtract_TimeOnly(bool async) + public override async Task Projecting_property_converted_to_nullable_with_conditional(bool async) { - await AssertTranslationFailed(() => base.Where_TimeOnly_subtract_TimeOnly(async)); + await base.Projecting_property_converted_to_nullable_with_conditional(async); - AssertSql(); + AssertSql( + """ +SELECT CASE + WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] + END + ELSE -1 +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +"""); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) + public override async Task Projecting_property_converted_to_nullable_with_function_call(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_property(async); + await base.Projecting_property_converted_to_nullable_with_function_call(async); AssertSql( """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] +SELECT SUBSTRING(CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END, 0 + 1, 3) FROM [Tags] AS [t] -CROSS JOIN [Missions] AS [m] -WHERE CAST([t].[IssueDate] AS time) = [m].[Time] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] """); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) + public override async Task Projecting_property_converted_to_nullable_with_function_call2(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); + await base.Projecting_property_converted_to_nullable_with_function_call2(async); AssertSql( """ -@time='02:00' (DbType = Time) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT [t].[Note], SUBSTRING([t].[Note], 0 + 1, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END) AS [Function] FROM [Tags] AS [t] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] @@ -11879,84 +10578,160 @@ UNION ALL SELECT [o].[Nickname], [o].[SquadId] FROM [Officers] AS [o] ) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] -WHERE [u].[Nickname] IS NOT NULL AND [u].[SquadId] IS NOT NULL AND CAST(DATEADD(hour, CAST(CAST([u].[SquadId] AS float) AS int), [t].[IssueDate]) AS time) = @time +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END IS NOT NULL """); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) + public override async Task Projecting_property_converted_to_nullable_into_element_init(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); + await base.Projecting_property_converted_to_nullable_into_element_init(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([u].[Nickname]) AS int) +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END + 1 FROM [Tags] AS [t] -WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) + public override async Task Projecting_property_converted_to_nullable_into_member_assignment(bool async) { - await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); + await base.Projecting_property_converted_to_nullable_into_member_assignment(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CAST([m].[Duration] AS time) < [m].[Time] +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END AS [Id] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + public override async Task Projecting_property_converted_to_nullable_into_new_array(bool async) { - await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); + await base.Projecting_property_converted_to_nullable_into_new_array(async); AssertSql( """ -@time='01:02' (DbType = Time) - -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CAST([m].[Duration] AS time) = @time +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([u].[Nickname]) AS int) +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END + 1 +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) + public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) { - await base.Order_by_TimeOnly_FromTimeSpan(async); + await base.Projecting_property_converted_to_nullable_into_unary(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -ORDER BY CAST([m].[Duration] AS time) +SELECT [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END IS NOT NULL AND CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[HasSoulPatch] +END = CAST(0 AS bit) +ORDER BY [t].[Note] """); } - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) + public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); + await base.Projecting_property_converted_to_nullable_into_member_access(async); AssertSql( """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] -FROM [Tags] AS [t] -CROSS JOIN [Missions] AS [m] -WHERE CAST([t].[IssueDate] AS date) > [m].[Date] +SELECT [u].[Nickname] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[CityOfBirthName] + FROM [Officers] AS [o] +) AS [u] +LEFT JOIN [Tags] AS [t] ON [u].[Nickname] = [t].[GearNickName] AND [u].[SquadId] = [t].[GearSquadId] +WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL +ORDER BY [u].[Nickname] """); } - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); + await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); AssertSql( """ -@prm='10/11/0002' (DbType = Date) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [u].[Nickname], [u].[SquadId], [u].[HasSoulPatch] FROM [Tags] AS [t] -WHERE CAST([t].[IssueDate] AS date) IN (@prm, '0015-03-07') +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + UNION ALL + SELECT [o].[Nickname], [o].[SquadId], [o].[HasSoulPatch] + FROM [Officers] AS [o] +) AS [u] ON [t].[GearNickName] = [u].[Nickname] AND [t].[GearSquadId] = [u].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[Nickname] +END IS NOT NULL +ORDER BY CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [u].[SquadId] +END, [t].[Note] """); } @@ -12199,17 +10974,6 @@ FROM [Weapons] AS [w0] """); } - public override async Task DateTimeOffset_DateAdd_AddYears(bool async) - { - await base.DateTimeOffset_DateAdd_AddYears(async); - - AssertSql( - """ -SELECT DATEADD(year, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] AS [m] -"""); - } - public override async Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async) { await base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async); @@ -12422,17 +11186,6 @@ FROM [Missions] AS [m] """); } - public override async Task ToString_guid_property_projection(bool async) - { - await base.ToString_guid_property_projection(async); - - AssertSql( - """ -SELECT [t].[GearNickName] AS [A], CONVERT(varchar(36), [t].[Id]) AS [B] -FROM [Tags] AS [t] -"""); - } - public override async Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async) { await base.Correlated_collection_with_distinct_not_projecting_identifier_column(async); @@ -13392,60 +12145,6 @@ FROM [Squads] AS [s] """); } - public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - await base.DateTimeOffset_to_unix_time_milliseconds(async); - - AssertSql( - """ -@unixEpochMilliseconds='0' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochMilliseconds = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - - public override async Task DateTimeOffset_to_unix_time_seconds(bool async) - { - await base.DateTimeOffset_to_unix_time_seconds(async); - - AssertSql( - """ -@unixEpochSeconds='0' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], N'Gear' AS [Discriminator] - FROM [Gears] AS [g] - 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] -INNER JOIN [Squads] AS [s] ON [u].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochSeconds = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [u].[Nickname], [u].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - public override async Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) { await base.Set_operator_with_navigation_in_projection_groupby_aggregate(async); @@ -13878,78 +12577,6 @@ FROM OPENJSON(@keys) WITH ([value] uniqueidentifier '$') AS [k] """); } - public override async Task Where_datetimeoffset_microsecond_component(bool async) - { - await base.Where_datetimeoffset_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Timeline]) % 1000 = 200 -"""); - } - - public override async Task Where_datetimeoffset_nanosecond_component(bool async) - { - await base.Where_datetimeoffset_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Timeline]) % 1000 = 400 -"""); - } - - public override async Task Where_timespan_microsecond_component(bool async) - { - await base.Where_timespan_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Duration]) % 1000 = 200 -"""); - } - - public override async Task Where_timespan_nanosecond_component(bool async) - { - await base.Where_timespan_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Duration]) % 1000 = 400 -"""); - } - - public override async Task Where_timeonly_microsecond_component(bool async) - { - await base.Where_timeonly_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Time]) % 1000 = 200 -"""); - } - - public override async Task Where_timeonly_nanosecond_component(bool async) - { - await base.Where_timeonly_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Time]) % 1000 = 400 -"""); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs index ec322d2887d..62be1d75c6a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTGearsOfWarQuerySqlServerTest.cs @@ -502,9 +502,9 @@ WHERE [s].[Nickname] <> N'Paduk' OR [s].[Nickname] IS NULL """); } - public override async Task Where_enum(bool async) + public override async Task Where_count_subquery_without_collision(bool async) { - await base.Where_enum(async); + await base.Where_count_subquery_without_collision(async); AssertSql( """ @@ -513,213 +513,216 @@ 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 [g].[Rank] = 4 +WHERE ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) = 2 """); } - public override async Task Where_nullable_enum_with_constant(bool async) + public override async Task Where_any_subquery_without_collision(bool async) { - await base.Where_nullable_enum_with_constant(async); + await base.Where_any_subquery_without_collision(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = 1 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) """); } - public override async Task Where_nullable_enum_with_null_constant(bool async) + public override async Task Select_inverted_boolean(bool async) { - await base.Where_nullable_enum_with_null_constant(async); + await base.Select_inverted_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], ~[w].[IsAutomatic] AS [Manual] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL +WHERE [w].[IsAutomatic] = CAST(1 AS bit) """); } - public override async Task Where_nullable_enum_with_non_nullable_parameter(bool async) + public override async Task Select_inverted_nullable_boolean(bool async) { - await base.Where_nullable_enum_with_non_nullable_parameter(async); + await base.Select_inverted_nullable_boolean(async); AssertSql( """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType +SELECT [f].[Id], ~[l].[Eradicated] AS [Alive] +FROM [Factions] AS [f] +INNER JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] """); } - public override async Task Where_nullable_enum_with_nullable_parameter(bool async) + public override async Task Select_comparison_with_null(bool async) { - await base.Where_nullable_enum_with_nullable_parameter(async); + await base.Select_comparison_with_null(async); AssertSql( """ @ammunitionType='1' (Nullable = true) -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] = @ammunitionType AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] = @ammunitionType """, // """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL """); } - public override async Task Where_bitwise_and_enum(bool async) + public override async Task Select_null_parameter(bool async) { - await base.Where_bitwise_and_enum(async); + await base.Select_null_parameter(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & 2 > 0 +@ammunitionType='1' (Nullable = true) + +SELECT [w].[Id], @ammunitionType AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & 2 = 2 -"""); - } - - public override async Task Where_bitwise_and_integral(bool async) - { - await base.Where_bitwise_and_integral(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & 1 = 1 +SELECT [w].[Id], NULL AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 CAST([g].[Rank] AS bigint) & CAST(1 AS bigint) = CAST(1 AS bigint) +@ammunitionType='2' (Nullable = true) + +SELECT [w].[Id], @ammunitionType AS [AmmoType] +FROM [Weapons] AS [w] """, // """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 CAST([g].[Rank] AS smallint) & CAST(1 AS smallint) = CAST(1 AS smallint) +SELECT [w].[Id], NULL AS [AmmoType] +FROM [Weapons] AS [w] """); } - public override async Task Where_bitwise_and_nullable_enum_with_constant(bool async) + public override async Task Select_ternary_operation_with_boolean(bool async) { - await base.Where_bitwise_and_nullable_enum_with_constant(async); + await base.Select_ternary_operation_with_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 + ELSE 0 +END AS [Num] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & 1 > 0 """); } - public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) + public override async Task Select_ternary_operation_with_inverted_boolean(bool async) { - await base.Where_bitwise_and_nullable_enum_with_null_constant(async); + await base.Select_ternary_operation_with_inverted_boolean(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN 1 + ELSE 0 +END AS [Num] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 """); } - public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) + public override async Task Select_ternary_operation_with_has_value_not_null(bool async) { - await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); + await base.Select_ternary_operation_with_has_value_not_null(async); AssertSql( """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 +WHERE [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 """); } - public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) + public override async Task Select_ternary_operation_multiple_conditions(bool async) { - await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); + await base.Select_ternary_operation_multiple_conditions(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[AmmunitionType] = 2 AND [w].[SynergyWithId] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 -""", - // +"""); + } + + public override async Task Select_ternary_operation_multiple_conditions_2(bool async) + { + await base.Select_ternary_operation_multiple_conditions_2(async); + + AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 THEN N'Yes' + ELSE N'No' +END AS [IsCartridge] FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 """); } - public override async Task Where_bitwise_or_enum(bool async) + public override async Task Select_multiple_conditions(bool async) { - await base.Where_bitwise_or_enum(async); + await base.Select_multiple_conditions(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] | 2 > 0 +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [IsCartridge] +FROM [Weapons] AS [w] """); } - public override async Task Bitwise_projects_values_in_select(bool async) + public override async Task Select_nested_ternary_operations(bool async) { - await base.Bitwise_projects_values_in_select(async); + await base.Select_nested_ternary_operations(async); AssertSql( """ -SELECT TOP(1) ~CAST(([g].[Rank] & 2) ^ 2 AS bit) AS [BitwiseTrue], ~CAST(([g].[Rank] & 2) ^ 4 AS bit) AS [BitwiseFalse], [g].[Rank] & 2 AS [BitwiseValue] -FROM [Gears] AS [g] -WHERE [g].[Rank] & 2 = 2 +SELECT [w].[Id], CASE + WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CASE + WHEN [w].[AmmunitionType] = 1 THEN N'ManualCartridge' + ELSE N'Manual' + END + ELSE N'Auto' +END AS [IsManualCartridge] +FROM [Weapons] AS [w] """); } - public override async Task Where_enum_has_flag(bool async) + public override async Task Null_propagation_optimization1(bool async) { - await base.Where_enum_has_flag(async); + await base.Null_propagation_optimization1(async); AssertSql( """ @@ -728,50 +731,15 @@ 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 [g].[Rank] & 2 = 2 -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & 18 = 18 -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & 1 = 1 -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & 1 = 1 -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 2 & [g].[Rank] = [g].[Rank] +WHERE [g].[LeaderNickname] = N'Marcus' """); } - public override async Task Where_enum_has_flag_subquery(bool async) + public override async Task Null_propagation_optimization2(bool async) { - await base.Where_enum_has_flag_subquery(async); + await base.Null_propagation_optimization2(async); + // issue #16050 AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE @@ -779,35 +747,19 @@ 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 [g].[Rank] & COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 2 & COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) +WHERE CASE + WHEN [g].[LeaderNickname] IS NULL THEN NULL + WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async) + public override async Task Null_propagation_optimization3(bool async) { - await base.Where_enum_has_flag_subquery_with_pushdown(async); + await base.Null_propagation_optimization3(async); + // issue #16050 AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE @@ -815,41 +767,20 @@ 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 [g].[Rank] & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 2 & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL +WHERE CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE + WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END +END = CAST(1 AS bit) """); } - public override async Task Where_enum_has_flag_subquery_client_eval(bool async) + public override async Task Null_propagation_optimization4(bool async) { - await base.Where_enum_has_flag_subquery_client_eval(async); + await base.Null_propagation_optimization4(async); + // issue #16050 AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE @@ -857,1204 +788,1249 @@ 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 [g].[Rank] & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL +WHERE CASE + WHEN [g].[LeaderNickname] IS NULL THEN NULL + ELSE CAST(LEN([g].[LeaderNickname]) AS int) +END = 5 """); } - public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool async) + public override async Task Null_propagation_optimization5(bool async) { - await base.Where_enum_has_flag_with_non_nullable_parameter(async); + await base.Null_propagation_optimization5(async); + // issue #16050 AssertSql( """ -@parameter='2' - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE 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 [g].[Rank] & @parameter = @parameter -"""); +WHERE CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) +END = 5 +"""); } - public override async Task Where_has_flag_with_nullable_parameter(bool async) + public override async Task Null_propagation_optimization6(bool async) { - await base.Where_has_flag_with_nullable_parameter(async); + await base.Null_propagation_optimization6(async); + // issue #16050 AssertSql( """ -@parameter='2' (Nullable = true) - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE 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 [g].[Rank] & @parameter = @parameter +WHERE CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) +END = 5 """); } - public override async Task Select_enum_has_flag(bool async) + public override async Task Select_null_propagation_optimization7(bool async) { - await base.Select_enum_has_flag(async); + await base.Select_null_propagation_optimization7(async); + // issue #16050 AssertSql( """ -SELECT TOP(1) ~CAST(([g].[Rank] & 2) ^ 2 AS bit) AS [hasFlagTrue], ~CAST(([g].[Rank] & 4) ^ 4 AS bit) AS [hasFlagFalse] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] +END FROM [Gears] AS [g] -WHERE [g].[Rank] & 2 = 2 """); } - public override async Task Where_count_subquery_without_collision(bool async) + public override async Task Select_null_propagation_optimization8(bool async) { - await base.Where_count_subquery_without_collision(async); + await base.Select_null_propagation_optimization8(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT COALESCE([g].[LeaderNickname], N'') + COALESCE([g].[LeaderNickname], N'') FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) = 2 """); } - public override async Task Where_any_subquery_without_collision(bool async) + public override async Task Select_null_propagation_optimization9(bool async) { - await base.Where_any_subquery_without_collision(async); + await base.Select_null_propagation_optimization9(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT CAST(LEN([g].[FullName]) AS int) FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) """); } - public override async Task Select_inverted_boolean(bool async) + public override async Task Select_null_propagation_negative1(bool async) { - await base.Select_inverted_boolean(async); + await base.Select_null_propagation_negative1(async); AssertSql( """ -SELECT [w].[Id], ~[w].[IsAutomatic] AS [Manual] -FROM [Weapons] AS [w] -WHERE [w].[IsAutomatic] = CAST(1 AS bit) +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_inverted_nullable_boolean(bool async) + public override async Task Select_null_propagation_negative2(bool async) { - await base.Select_inverted_nullable_boolean(async); + await base.Select_null_propagation_negative2(async); AssertSql( """ -SELECT [f].[Id], ~[l].[Eradicated] AS [Alive] -FROM [Factions] AS [f] -INNER JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN [s].[LeaderNickname] +END +FROM [Gears] AS [g] +CROSS JOIN ( + SELECT [g0].[LeaderNickname] + FROM [Gears] AS [g0] +) AS [s] """); } - public override async Task Select_comparison_with_null(bool async) + public override async Task Select_null_propagation_negative3(bool async) { - await base.Select_comparison_with_null(async); + await base.Select_null_propagation_negative3(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) +SELECT [s].[Nickname], CASE + WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CASE + WHEN [s].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END +END AS [Condition] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[LeaderNickname] + FROM [Gears] AS [g0] +) AS [s] ON [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [s].[Nickname] +"""); + } -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = @ammunitionType AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Cartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType -""", - // + public override async Task Select_null_propagation_negative4(bool async) + { + await base.Select_null_propagation_negative4(async); + + AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] IS NULL THEN CAST(1 AS bit) +SELECT CASE + WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END AS [Cartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL +END, [s].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] +) AS [s] ON [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [s].[Nickname] """); } - public override async Task Select_null_parameter(bool async) + public override async Task Select_null_propagation_negative5(bool async) { - await base.Select_null_parameter(async); + await base.Select_null_propagation_negative5(async); AssertSql( """ -@ammunitionType='1' (Nullable = true) +SELECT CASE + WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [s].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] +) AS [s] ON [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [s].[Nickname] +"""); + } -SELECT [w].[Id], @ammunitionType AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -SELECT [w].[Id], NULL AS [AmmoType] -FROM [Weapons] AS [w] -""", - // - """ -@ammunitionType='2' (Nullable = true) + public override async Task Select_null_propagation_negative6(bool async) + { + await base.Select_null_propagation_negative6(async); -SELECT [w].[Id], @ammunitionType AS [AmmoType] -FROM [Weapons] AS [w] -""", - // + AssertSql( """ -SELECT [w].[Id], NULL AS [AmmoType] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(0 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_ternary_operation_with_boolean(bool async) + public override async Task Select_null_propagation_negative7(bool async) { - await base.Select_ternary_operation_with_boolean(async); + await base.Select_null_propagation_negative7(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 - ELSE 0 -END AS [Num] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_ternary_operation_with_inverted_boolean(bool async) + public override async Task Select_null_propagation_negative8(bool async) { - await base.Select_ternary_operation_with_inverted_boolean(async); + await base.Select_null_propagation_negative8(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN 1 - ELSE 0 -END AS [Num] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [s0].[Id] IS NOT NULL THEN [c].[Name] +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] +LEFT JOIN [Cities] AS [c] ON [s].[AssignedCityName] = [c].[Name] """); } - public override async Task Select_ternary_operation_with_has_value_not_null(bool async) + public override async Task Select_null_propagation_negative9(bool async) { - await base.Select_ternary_operation_with_has_value_not_null(async); + await base.Select_null_propagation_negative9(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NOT NULL AND [w].[AmmunitionType] = 1 +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) +END +FROM [Gears] AS [g] """); } - public override async Task Select_ternary_operation_multiple_conditions(bool async) + public override async Task Select_null_propagation_works_for_navigations_with_composite_keys(bool async) { - await base.Select_ternary_operation_multiple_conditions(async); + await base.Select_null_propagation_works_for_navigations_with_composite_keys(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[AmmunitionType] = 2 AND [w].[SynergyWithId] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT [s].[Nickname] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] """); } - public override async Task Select_ternary_operation_multiple_conditions_2(bool async) + public override async Task Select_null_propagation_works_for_multiple_navigations_with_composite_keys(bool async) { - await base.Select_ternary_operation_multiple_conditions_2(async); + await base.Select_null_propagation_works_for_multiple_navigations_with_composite_keys(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 THEN N'Yes' - ELSE N'No' -END AS [IsCartridge] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [c].[Name] IS NOT NULL THEN [c].[Name] +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN [Tags] AS [t0] ON ([s].[Nickname] = [t0].[GearNickName] OR ([s].[Nickname] IS NULL AND [t0].[GearNickName] IS NULL)) AND ([s].[SquadId] = [t0].[GearSquadId] OR ([s].[SquadId] IS NULL AND [t0].[GearSquadId] IS NULL)) +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName] + FROM [Gears] AS [g0] +) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] +LEFT JOIN [Cities] AS [c] ON [s0].[AssignedCityName] = [c].[Name] """); } - public override async Task Select_multiple_conditions(bool async) + public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) { - await base.Select_multiple_conditions(async); + await base.Select_conditional_with_anonymous_type_and_null_constant(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) AND [w].[SynergyWithId] = 1 AND [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END AS [IsCartridge] -FROM [Weapons] AS [w] +END, [g].[HasSoulPatch] +FROM [Gears] AS [g] +ORDER BY [g].[Nickname] """); } - public override async Task Select_nested_ternary_operations(bool async) + public override async Task Select_conditional_with_anonymous_types(bool async) { - await base.Select_nested_ternary_operations(async); + await base.Select_conditional_with_anonymous_types(async); AssertSql( """ -SELECT [w].[Id], CASE - WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CASE - WHEN [w].[AmmunitionType] = 1 THEN N'ManualCartridge' - ELSE N'Manual' - END - ELSE N'Auto' -END AS [IsManualCartridge] -FROM [Weapons] AS [w] +SELECT CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g].[Nickname], [g].[FullName] +FROM [Gears] AS [g] +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization1(bool async) + public override async Task Where_conditional_equality_1(bool async) { - await base.Null_propagation_optimization1(async); + await base.Where_conditional_equality_1(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [g].[LeaderNickname] = N'Marcus' +WHERE [g].[LeaderNickname] IS NULL +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization2(bool async) + public override async Task Where_conditional_equality_2(bool async) { - await base.Null_propagation_optimization2(async); + await base.Where_conditional_equality_2(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname] 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 - WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +WHERE [g].[LeaderNickname] IS NULL +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization3(bool async) + public override async Task Where_conditional_equality_3(bool async) { - await base.Null_propagation_optimization3(async); + await base.Where_conditional_equality_3(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname] 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 CASE - WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END -END = CAST(1 AS bit) +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization4(bool async) + public override async Task Select_coalesce_with_anonymous_types(bool async) { - await base.Null_propagation_optimization4(async); + await base.Select_coalesce_with_anonymous_types(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[LeaderNickname], [g].[FullName] 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 +ORDER BY [g].[Nickname] """); } - public override async Task Null_propagation_optimization5(bool async) + public override async Task Where_compare_anonymous_types(bool async) { - await base.Null_propagation_optimization5(async); + await base.Where_compare_anonymous_types(async); - // issue #16050 - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 -"""); + AssertSql(); } - public override async Task Null_propagation_optimization6(bool async) + public override async Task Where_member_access_on_anonymous_type(bool async) { - await base.Null_propagation_optimization6(async); + await base.Where_member_access_on_anonymous_type(async); - // issue #16050 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname] 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 [g].[LeaderNickname] = N'Marcus' """); } - public override async Task Select_null_propagation_optimization7(bool async) + public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) { - await base.Select_null_propagation_optimization7(async); + await base.Where_compare_anonymous_types_with_uncorrelated_members(async); - // issue #16050 AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] -END +SELECT [g].[Nickname] FROM [Gears] AS [g] +WHERE 0 = 1 """); } - public override async Task Select_null_propagation_optimization8(bool async) + public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool async) { - await base.Select_null_propagation_optimization8(async); + await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(async); AssertSql( """ -SELECT COALESCE([g].[LeaderNickname], N'') + COALESCE([g].[LeaderNickname], N'') -FROM [Gears] AS [g] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] +) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] +WHERE [s].[Nickname] = [s0].[Nickname] OR ([s].[Nickname] IS NULL AND [s0].[Nickname] IS NULL) """); } - public override async Task Select_null_propagation_optimization9(bool async) + public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) { - await base.Select_null_propagation_optimization9(async); + await base.Select_Singleton_Navigation_With_Member_Access(async); AssertSql( """ -SELECT CAST(LEN([g].[FullName]) AS int) -FROM [Gears] AS [g] +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[Nickname] = N'Marcus' AND ([s].[CityOfBirthName] <> N'Ephyra' OR [s].[CityOfBirthName] IS NULL) """); } - public override async Task Select_null_propagation_negative1(bool async) + public override async Task Select_Where_Navigation(bool async) { - await base.Select_null_propagation_negative1(async); + await base.Select_Where_Navigation(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) -END -FROM [Gears] AS [g] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[Nickname] = N'Marcus' """); } - public override async Task Select_null_propagation_negative2(bool async) + public override async Task Select_Where_Navigation_Equals_Navigation(bool async) { - await base.Select_null_propagation_negative2(async); + await base.Select_Where_Navigation_Equals_Navigation(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN [s].[LeaderNickname] -END -FROM [Gears] AS [g] -CROSS JOIN ( - SELECT [g0].[LeaderNickname] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] FROM [Gears] AS [g0] -) AS [s] +) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] +WHERE ([s].[Nickname] = [s0].[Nickname] OR ([s].[Nickname] IS NULL AND [s0].[Nickname] IS NULL)) AND ([s].[SquadId] = [s0].[SquadId] OR ([s].[SquadId] IS NULL AND [s0].[SquadId] IS NULL)) """); } - public override async Task Select_null_propagation_negative3(bool async) + public override async Task Select_Where_Navigation_Null(bool async) { - await base.Select_null_propagation_negative3(async); + await base.Select_Where_Navigation_Null(async); AssertSql( """ -SELECT [s].[Nickname], CASE - WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CASE - WHEN [s].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END -END AS [Condition] -FROM [Gears] AS [g] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[LeaderNickname] - FROM [Gears] AS [g0] -) AS [s] ON [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [s].[Nickname] + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[Nickname] IS NULL OR [s].[SquadId] IS NULL """); } - public override async Task Select_null_propagation_negative4(bool async) + public override async Task Select_Where_Navigation_Null_Reverse(bool async) { - await base.Select_null_propagation_negative4(async); + await base.Select_Where_Navigation_Null_Reverse(async); AssertSql( """ -SELECT CASE - WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [s].[Nickname] -FROM [Gears] AS [g] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] -) AS [s] ON [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [s].[Nickname] + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[Nickname] IS NULL OR [s].[SquadId] IS NULL """); } - public override async Task Select_null_propagation_negative5(bool async) + public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool async) { - await base.Select_null_propagation_negative5(async); + await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(async); AssertSql( """ -SELECT CASE - WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [s].[Nickname] -FROM [Gears] AS [g] +SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] +FROM [Tags] AS [t] +CROSS JOIN [Tags] AS [t0] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId] FROM [Gears] AS [g0] -) AS [s] ON [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [s].[Nickname] +) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] +WHERE [s].[Nickname] = [s0].[Nickname] OR ([s].[Nickname] IS NULL AND [s0].[Nickname] IS NULL) """); } - public override async Task Select_null_propagation_negative6(bool async) + public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool async) { - await base.Select_null_propagation_negative6(async); + await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(0 AS bit) -END -FROM [Gears] AS [g] +SELECT TOP(1) COALESCE([w0].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w].[Id] """); } - public override async Task Select_null_propagation_negative7(bool async) + public override async Task Where_subquery_boolean(bool async) { - await base.Select_null_propagation_negative7(async); + await base.Where_subquery_boolean(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) -END +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_negative8(bool async) + public override async Task Where_subquery_boolean_with_pushdown(bool async) { - await base.Select_null_propagation_negative8(async); + await base.Where_subquery_boolean_with_pushdown(async); AssertSql( """ -SELECT CASE - WHEN [s0].[Id] IS NOT NULL THEN [c].[Name] -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] -LEFT JOIN [Cities] AS [c] ON [s].[AssignedCityName] = [c].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_negative9(bool async) + public override async Task Where_subquery_distinct_firstordefault_boolean(bool async) { - await base.Select_null_propagation_negative9(async); + await base.Where_subquery_distinct_firstordefault_boolean(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) -END +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_works_for_navigations_with_composite_keys(bool async) + public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) { - await base.Select_null_propagation_works_for_navigations_with_composite_keys(async); + await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [s].[Nickname] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_null_propagation_works_for_multiple_navigations_with_composite_keys(bool async) + public override async Task Where_subquery_distinct_first_boolean(bool async) { - await base.Select_null_propagation_works_for_multiple_navigations_with_composite_keys(async); + await base.Where_subquery_distinct_first_boolean(async); AssertSql( """ -SELECT CASE - WHEN [c].[Name] IS NOT NULL THEN [c].[Name] -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN [Tags] AS [t0] ON ([s].[Nickname] = [t0].[GearNickName] OR ([s].[Nickname] IS NULL AND [t0].[GearNickName] IS NULL)) AND ([s].[SquadId] = [t0].[GearSquadId] OR ([s].[SquadId] IS NULL AND [t0].[GearSquadId] IS NULL)) -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName] - FROM [Gears] AS [g0] -) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] -LEFT JOIN [Cities] AS [c] ON [s0].[AssignedCityName] = [c].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) +ORDER BY [g].[Nickname] """); } - public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean1(bool async) { - await base.Select_conditional_with_anonymous_type_and_null_constant(async); + await base.Where_subquery_distinct_singleordefault_boolean1(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[HasSoulPatch] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]), CAST(0 AS bit)) = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Select_conditional_with_anonymous_types(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean2(bool async) { - await base.Select_conditional_with_anonymous_types(async); + await base.Where_subquery_distinct_singleordefault_boolean2(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[Nickname], [g].[FullName] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Where_conditional_equality_1(bool async) + public override async Task Where_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { - await base.Where_conditional_equality_1(async); + await base.Where_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [g].[Nickname] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -WHERE [g].[LeaderNickname] IS NULL +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]) = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Where_conditional_equality_2(bool async) + public override async Task Where_subquery_distinct_lastordefault_boolean(bool async) { - await base.Where_conditional_equality_2(async); + await base.Where_subquery_distinct_lastordefault_boolean(async); AssertSql( """ -SELECT [g].[Nickname] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -WHERE [g].[LeaderNickname] IS NULL +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id] DESC) = CAST(0 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Where_conditional_equality_3(bool async) + public override async Task Where_subquery_distinct_last_boolean(bool async) { - await base.Where_conditional_equality_3(async); + await base.Where_subquery_distinct_last_boolean(async); AssertSql( """ -SELECT [g].[Nickname] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(0 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id] DESC) = CAST(1 AS bit) ORDER BY [g].[Nickname] """); } - public override async Task Select_coalesce_with_anonymous_types(bool async) + public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool async) { - await base.Select_coalesce_with_anonymous_types(async); + await base.Where_subquery_distinct_orderby_firstordefault_boolean(async); AssertSql( """ -SELECT [g].[LeaderNickname], [g].[FullName] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -ORDER BY [g].[Nickname] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Where_compare_anonymous_types(bool async) - { - await base.Where_compare_anonymous_types(async); - - AssertSql(); - } - - public override async Task Where_member_access_on_anonymous_type(bool async) + public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool async) { - await base.Where_member_access_on_anonymous_type(async); + await base.Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [g].[Nickname] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -WHERE [g].[LeaderNickname] = N'Marcus' +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ) AS [w0] + ORDER BY [w0].[Id]) = CAST(1 AS bit) """); } - public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) + public override async Task Where_subquery_union_firstordefault_boolean(bool async) { - await base.Where_compare_anonymous_types_with_uncorrelated_members(async); + await base.Where_subquery_union_firstordefault_boolean(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -WHERE 0 = 1 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [u].[IsAutomatic] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + UNION + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u] + ORDER BY [u].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool async) + public override async Task Where_subquery_join_firstordefault_boolean(bool async) { - await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(async); + await base.Where_subquery_join_firstordefault_boolean(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] -) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] -WHERE [s].[Nickname] = [s0].[Nickname] OR ([s].[Nickname] IS NULL AND [s0].[Nickname] IS NULL) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + INNER JOIN ( + SELECT [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [w1] ON [w].[Id] = [w1].[Id] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) + public override async Task Where_subquery_left_join_firstordefault_boolean(bool async) { - await base.Select_Singleton_Navigation_With_Member_Access(async); + await base.Where_subquery_left_join_firstordefault_boolean(async); AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] = N'Marcus' AND ([s].[CityOfBirthName] <> N'Ephyra' OR [s].[CityOfBirthName] IS NULL) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [w1] ON [w].[Id] = [w1].[Id] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation(bool async) + public override async Task Where_subquery_concat_firstordefault_boolean(bool async) { - await base.Select_Where_Navigation(async); + await base.Where_subquery_concat_firstordefault_boolean(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] = N'Marcus' +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( + SELECT TOP(1) [u].[IsAutomatic] + FROM ( + SELECT [w].[Id], [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + UNION ALL + SELECT [w0].[Id], [w0].[IsAutomatic] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u] + ORDER BY [u].[Id]) = CAST(1 AS bit) """); } - public override async Task Select_Where_Navigation_Equals_Navigation(bool async) + public override async Task Concat_with_count(bool async) { - await base.Select_Where_Navigation_Equals_Navigation(async); + await base.Concat_with_count(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] + UNION ALL + SELECT 1 AS empty FROM [Gears] AS [g0] -) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] -WHERE ([s].[Nickname] = [s0].[Nickname] OR ([s].[Nickname] IS NULL AND [s0].[Nickname] IS NULL)) AND ([s].[SquadId] = [s0].[SquadId] OR ([s].[SquadId] IS NULL AND [s0].[SquadId] IS NULL)) +) AS [u] """); } - public override async Task Select_Where_Navigation_Null(bool async) + public override async Task Concat_scalars_with_count(bool async) { - await base.Select_Where_Navigation_Null(async); + await base.Concat_scalars_with_count(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] IS NULL OR [s].[SquadId] IS NULL + UNION ALL + SELECT 1 AS empty + FROM [Gears] AS [g0] +) AS [u] """); } - public override async Task Select_Where_Navigation_Null_Reverse(bool async) + public override async Task Concat_anonymous_with_count(bool async) { - await base.Select_Where_Navigation_Null_Reverse(async); + await base.Concat_anonymous_with_count(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT COUNT(*) +FROM ( + SELECT 1 AS empty FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] IS NULL OR [s].[SquadId] IS NULL + UNION ALL + SELECT 1 AS empty + FROM [Gears] AS [g0] +) AS [u] """); } - public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool async) + public override async Task Concat_with_scalar_projection(bool async) { - await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(async); + await base.Concat_with_scalar_projection(async); AssertSql( """ -SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] -FROM [Tags] AS [t] -CROSS JOIN [Tags] AS [t0] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] -) AS [s0] ON [t0].[GearNickName] = [s0].[Nickname] AND [t0].[GearSquadId] = [s0].[SquadId] -WHERE [s].[Nickname] = [s0].[Nickname] OR ([s].[Nickname] IS NULL AND [s0].[Nickname] IS NULL) +SELECT [g].[Nickname] +FROM [Gears] AS [g] +UNION ALL +SELECT [g0].[Nickname] +FROM [Gears] AS [g0] """); } - public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool async) + public override async Task Select_navigation_with_concat_and_count(bool async) { - await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(async); + await base.Select_navigation_with_concat_and_count(async); AssertSql( """ -SELECT TOP(1) COALESCE([w0].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w].[Id] +SELECT ( + SELECT COUNT(*) + FROM ( + SELECT 1 AS empty + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + UNION ALL + SELECT 1 AS empty + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u]) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Where_subquery_boolean(bool async) + public override async Task Concat_with_collection_navigations(bool async) { - await base.Where_subquery_boolean(async); + await base.Concat_with_collection_navigations(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT ( + SELECT COUNT(*) + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + UNION + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ) AS [u]) FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Where_subquery_boolean_with_pushdown(bool async) + public override async Task Union_with_collection_navigations(bool async) { - await base.Where_subquery_boolean_with_pushdown(async); + await base.Union_with_collection_navigations(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT ( + SELECT COUNT(*) + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] + UNION + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], CASE + WHEN [o1].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g1] + LEFT JOIN [Officers] AS [o1] ON [g1].[Nickname] = [o1].[Nickname] AND [g1].[SquadId] = [o1].[SquadId] + WHERE [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] + ) AS [u]) FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +WHERE [o].[Nickname] IS NOT NULL """); } - public override async Task Where_subquery_distinct_firstordefault_boolean(bool async) + public override async Task Select_subquery_distinct_firstordefault(bool async) { - await base.Where_subquery_distinct_firstordefault_boolean(async); + await base.Select_subquery_distinct_firstordefault(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] +SELECT ( + SELECT TOP(1) [w0].[Name] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [w0] - ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) + ORDER BY [w0].[Id]) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) + public override async Task Singleton_Navigation_With_Member_Access(bool async) { - await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); + await base.Singleton_Navigation_With_Member_Access(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) +SELECT [s].[CityOfBirthName] AS [B] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[Nickname] = N'Marcus' AND ([s].[CityOfBirthName] <> N'Ephyra' OR [s].[CityOfBirthName] IS NULL) """); } - public override async Task Where_subquery_distinct_first_boolean(bool async) + public override async Task GroupJoin_Composite_Key(bool async) { - await base.Where_subquery_distinct_first_boolean(async); + await base.GroupJoin_Composite_Key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Tags] AS [t] +INNER JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] """); } - public override async Task Where_subquery_distinct_singleordefault_boolean1(bool async) + public override async Task Join_navigation_translated_to_subquery_composite_key(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean1(async); + await base.Join_navigation_translated_to_subquery_composite_key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[FullName], [s0].[Note] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]), CAST(0 AS bit)) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +INNER JOIN ( + SELECT [t].[Note], [s].[FullName] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +) AS [s0] ON [g].[FullName] = [s0].[FullName] """); } - public override async Task Where_subquery_distinct_singleordefault_boolean2(bool async) + public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean2(async); + await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[FullName], [s0].[Note] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +INNER JOIN ( + SELECT [t].[Note], [s].[FullName] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +) AS [s0] ON [g].[FullName] = [s0].[FullName] """); } - public override async Task Where_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) + public override async Task Join_with_order_by_without_skip_or_take(bool async) { - await base.Where_subquery_distinct_singleordefault_boolean_with_pushdown(async); + await base.Join_with_order_by_without_skip_or_take(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [w].[Name], [g].[FullName] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] """); } - public override async Task Where_subquery_distinct_lastordefault_boolean(bool async) + public override async Task Join_with_order_by_without_skip_or_take_nested(bool async) { - await base.Where_subquery_distinct_lastordefault_boolean(async); + await base.Join_with_order_by_without_skip_or_take_nested(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id] DESC) = CAST(0 AS bit) -ORDER BY [g].[Nickname] +SELECT [w].[Name], [s0].[FullName] +FROM [Squads] AS [s] +INNER JOIN ( + SELECT [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +INNER JOIN [Weapons] AS [w] ON [s0].[FullName] = [w].[OwnerFullName] """); } - public override async Task Where_subquery_distinct_last_boolean(bool async) + public override async Task Collection_with_inheritance_and_join_include_joined(bool async) { - await base.Where_subquery_distinct_last_boolean(async); + await base.Collection_with_inheritance_and_join_include_joined(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(0 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id] DESC) = CAST(1 AS bit) -ORDER BY [g].[Nickname] +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +FROM [Tags] AS [t] +INNER JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [o].[Nickname] IS NOT NULL +) AS [s] ON [t].[GearSquadId] = [s].[SquadId] AND [t].[GearNickName] = [s].[Nickname] +LEFT JOIN [Tags] AS [t0] ON [s].[Nickname] = [t0].[GearNickName] AND [s].[SquadId] = [t0].[GearSquadId] """); } - public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool async) + public override async Task Collection_with_inheritance_and_join_include_source(bool async) { - await base.Where_subquery_distinct_orderby_firstordefault_boolean(async); + await base.Collection_with_inheritance_and_join_include_source(async); AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +END AS [Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]), CAST(0 AS bit)) = CAST(1 AS bit) +INNER JOIN [Tags] AS [t] ON [g].[SquadId] = [t].[GearSquadId] AND [g].[Nickname] = [t].[GearNickName] +LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] +WHERE [o].[Nickname] IS NOT NULL """); } - public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool async) + public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(async); + await base.Non_unicode_string_literal_is_used_for_non_unicode_column(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) = CAST(1 AS bit) +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' """); } - public override async Task Where_subquery_union_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column_right(bool async) { - await base.Where_subquery_union_firstordefault_boolean(async); + await base.Non_unicode_string_literal_is_used_for_non_unicode_column_right(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [u].[IsAutomatic] - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u] - ORDER BY [u].[Id]) = CAST(1 AS bit) +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE 'Unknown' = [c].[Location] """); } - public override async Task Where_subquery_join_firstordefault_boolean(bool async) + public override async Task Non_unicode_parameter_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_join_firstordefault_boolean(async); + await base.Non_unicode_parameter_is_used_for_non_unicode_column(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - INNER JOIN ( - SELECT [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [w1] ON [w].[Id] = [w1].[Id] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +@value='Unknown' (Size = 100) (DbType = AnsiString) + +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = @value """); } - public override async Task Where_subquery_left_join_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(bool async) { - await base.Where_subquery_left_join_firstordefault_boolean(async); + await base.Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [w1] ON [w].[Id] = [w1].[Id] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) = CAST(1 AS bit) +@cities='["Unknown","Jacinto\u0027s location","Ephyra\u0027s location"]' (Size = 4000) + +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] IN ( + SELECT [c0].[value] + FROM OPENJSON(@cities) WITH ([value] varchar(100) '$') AS [c0] +) """); } - public override async Task Where_subquery_concat_firstordefault_boolean(bool async) + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(bool async) { - await base.Where_subquery_concat_firstordefault_boolean(async); + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(async); + + AssertSql( + """ +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' AND ( + SELECT COUNT(*) + FROM [Gears] AS [g] + WHERE [c].[Name] = [g].[CityOfBirthName] AND [g].[Nickname] = N'Paduk') = 1 +"""); + } + + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(bool async) + { + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(async); AssertSql( """ @@ -2063,564 +2039,602 @@ 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 [g].[HasSoulPatch] = CAST(1 AS bit) AND ( - SELECT TOP(1) [u].[IsAutomatic] - FROM ( - SELECT [w].[Id], [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION ALL - SELECT [w0].[Id], [w0].[IsAutomatic] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u] - ORDER BY [u].[Id]) = CAST(1 AS bit) +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +WHERE [g].[Nickname] = N'Marcus' AND [c].[Location] = 'Jacinto''s location' """); } - public override async Task Concat_with_count(bool async) + public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(bool async) { - await base.Concat_with_count(async); + await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(async); AssertSql( """ -SELECT COUNT(*) -FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Gears] AS [g0] -) AS [u] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] LIKE '%Jacinto%' """); } - public override async Task Concat_scalars_with_count(bool async) + public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) { - await base.Concat_scalars_with_count(async); + await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); AssertSql( """ -SELECT COUNT(*) -FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty - FROM [Gears] AS [g0] -) AS [u] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE COALESCE([c].[Location], N'') + N'Added' LIKE N'%Add%' """); } - public override async Task Concat_anonymous_with_count(bool async) + public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() { - await base.Concat_anonymous_with_count(async); + base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); + // Issue#16897 AssertSql( """ -SELECT COUNT(*) -FROM ( - SELECT 1 AS empty - FROM [Gears] AS [g] - UNION ALL - SELECT 1 AS empty +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] FROM [Gears] AS [g0] -) AS [u] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Concat_with_scalar_projection(bool async) + public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() { - await base.Concat_with_scalar_projection(async); + base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); + // Issue#16897 AssertSql( """ -SELECT [g].[Nickname] +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -UNION ALL -SELECT [g0].[Nickname] -FROM [Gears] AS [g0] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Select_navigation_with_concat_and_count(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) { - await base.Select_navigation_with_concat_and_count(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(async); + // Issue#16897 AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT 1 AS empty - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION ALL - SELECT 1 AS empty - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u]) +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id] """); } - public override async Task Concat_with_collection_navigations(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) { - await base.Concat_with_collection_navigations(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async); + // Issue#16897 AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - UNION - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ) AS [u]) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [s].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Weapons] AS [w1] ON [s].[FullName] = [w1].[OwnerFullName] +LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id], [w0].[Id], [w1].[Id] """); } - public override async Task Union_with_collection_navigations(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) { - await base.Union_with_collection_navigations(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); + // Issue#16897 AssertSql( """ -SELECT ( - SELECT COUNT(*) - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] - UNION - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], CASE - WHEN [o1].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g1] - LEFT JOIN [Officers] AS [o1] ON [g1].[Nickname] = [o1].[Nickname] AND [g1].[SquadId] = [o1].[SquadId] - WHERE [g].[Nickname] = [g1].[LeaderNickname] AND [g].[SquadId] = [g1].[LeaderSquadId] - ) AS [u]) +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [o].[Nickname] IS NOT NULL +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + WHERE [o0].[Nickname] IS NOT NULL +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id] """); } - public override async Task Select_subquery_distinct_firstordefault(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) { - await base.Select_subquery_distinct_firstordefault(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(async); + // Issue#16897 AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[Name] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ) AS [w0] - ORDER BY [w0].[Id]) +SELECT CASE + WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id] """); } - public override async Task Singleton_Navigation_With_Member_Access(bool async) + public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async) { - await base.Singleton_Navigation_With_Member_Access(async); + await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async); AssertSql( """ -SELECT [s].[CityOfBirthName] AS [B] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId], CASE + WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w3].[Id], [w3].[AmmunitionType], [w3].[IsAutomatic], [w3].[Name], [w3].[OwnerFullName], [w3].[SynergyWithId], [w4].[Id], [w4].[AmmunitionType], [w4].[IsAutomatic], [w4].[Name], [w4].[OwnerFullName], [w4].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Weapons] AS [w0] ON [s].[FullName] = [w0].[OwnerFullName] +LEFT JOIN [Weapons] AS [w1] ON [s].[FullName] = [w1].[OwnerFullName] +LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +LEFT JOIN [Weapons] AS [w3] ON [s].[FullName] = [w3].[OwnerFullName] +LEFT JOIN [Weapons] AS [w4] ON [g].[FullName] = [w4].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id], [w0].[Id], [w1].[Id], [w2].[Id], [w3].[Id] +"""); + } + + public override async Task Coalesce_operator_in_predicate(bool async) + { + await base.Coalesce_operator_in_predicate(async); + + AssertSql( + """ +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[CityOfBirthName] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] = N'Marcus' AND ([s].[CityOfBirthName] <> N'Ephyra' OR [s].[CityOfBirthName] IS NULL) +WHERE COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task GroupJoin_Composite_Key(bool async) + public override async Task Coalesce_operator_in_predicate_with_other_conditions(bool async) { - await base.GroupJoin_Composite_Key(async); + await base.Coalesce_operator_in_predicate_with_other_conditions(async); AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] -INNER JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Join_navigation_translated_to_subquery_composite_key(bool async) + public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) { - await base.Join_navigation_translated_to_subquery_composite_key(async); + await base.Coalesce_operator_in_projection_with_other_conditions(async); AssertSql( """ -SELECT [g].[FullName], [s0].[Note] -FROM [Gears] AS [g] -INNER JOIN ( - SELECT [t].[Note], [s].[FullName] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -) AS [s0] ON [g].[FullName] = [s0].[FullName] +SELECT CASE + WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] """); } - public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate(bool async) { - await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); + await base.Optional_navigation_type_compensation_works_with_predicate(async); AssertSql( """ -SELECT [g].[FullName], [s0].[Note] -FROM [Gears] AS [g] -INNER JOIN ( - SELECT [t].[Note], [s].[FullName] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -) AS [s0] ON [g].[FullName] = [s0].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Join_with_order_by_without_skip_or_take(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate2(bool async) { - await base.Join_with_order_by_without_skip_or_take(async); + await base.Optional_navigation_type_compensation_works_with_predicate2(async); AssertSql( """ -SELECT [w].[Name], [g].[FullName] -FROM [Gears] AS [g] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Join_with_order_by_without_skip_or_take_nested(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated(bool async) { - await base.Join_with_order_by_without_skip_or_take_nested(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated(async); AssertSql( """ -SELECT [w].[Name], [s0].[FullName] -FROM [Squads] AS [s] -INNER JOIN ( - SELECT [g].[SquadId], [g].[FullName] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -INNER JOIN [Weapons] AS [w] ON [s0].[FullName] = [w].[OwnerFullName] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Collection_with_inheritance_and_join_include_joined(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool async) { - await base.Collection_with_inheritance_and_join_include_joined(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(async); AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] -INNER JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE [o].[Nickname] IS NOT NULL -) AS [s] ON [t].[GearSquadId] = [s].[SquadId] AND [t].[GearNickName] = [s].[Nickname] -LEFT JOIN [Tags] AS [t0] ON [s].[Nickname] = [t0].[GearNickName] AND [s].[SquadId] = [t0].[GearSquadId] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [s].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE [s].[HasSoulPatch] +END = CAST(0 AS bit) """); } - public override async Task Collection_with_inheritance_and_join_include_source(bool async) + public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool async) { - await base.Collection_with_inheritance_and_join_include_source(async); + await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Tags] AS [t] ON [g].[SquadId] = [t].[GearSquadId] AND [g].[Nickname] = [t].[GearNickName] -LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE [o].[Nickname] IS NOT NULL +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [s].[HasSoulPatch] = CAST(0 AS bit) THEN CAST(0 AS bit) + ELSE [s].[HasSoulPatch] +END = CAST(0 AS bit) """); } - public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool async) { - await base.Non_unicode_string_literal_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_conditional_expression(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [s].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column_right(bool async) + public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) { - await base.Non_unicode_string_literal_is_used_for_non_unicode_column_right(async); + await base.Optional_navigation_type_compensation_works_with_binary_expression(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE 'Unknown' = [c].[Location] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[HasSoulPatch] = CAST(1 AS bit) OR [t].[Note] LIKE N'%Cole%' """); } - public override async Task Non_unicode_parameter_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) { - await base.Non_unicode_parameter_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); AssertSql( """ -@value='Unknown' (Size = 100) (DbType = AnsiString) - -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = @value +SELECT CASE + WHEN [s].[HasSoulPatch] = CAST(1 AS bit) AND [t].[Note] LIKE N'%Cole%' AND [t].[Note] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] """); } - public override async Task Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(bool async) + public override async Task Optional_navigation_type_compensation_works_with_projection(bool async) { - await base.Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(async); + await base.Optional_navigation_type_compensation_works_with_projection(async); AssertSql( """ -@cities='["Unknown","Jacinto\u0027s location","Ephyra\u0027s location"]' (Size = 4000) - -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] IN ( - SELECT [c0].[value] - FROM OPENJSON(@cities) WITH ([value] varchar(100) '$') AS [c0] -) +SELECT [s].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(bool async) + public override async Task Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(async); + await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' AND ( - SELECT COUNT(*) +SELECT [s].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] - WHERE [c].[Name] = [g].[CityOfBirthName] AND [g].[Nickname] = N'Paduk') = 1 +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(bool async) + public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(async); + await base.Optional_navigation_type_compensation_works_with_DTOs(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -WHERE [g].[Nickname] = N'Marcus' AND [c].[Location] = 'Jacinto''s location' +SELECT [s].[SquadId] AS [Id] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(bool async) + public override async Task Optional_navigation_type_compensation_works_with_list_initializers(bool async) { - await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(async); + await base.Optional_navigation_type_compensation_works_with_list_initializers(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] LIKE '%Jacinto%' +SELECT [s].[SquadId], [s].[SquadId] + 1 +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +ORDER BY [t].[Note] """); } - public override async Task Unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) + public override async Task Optional_navigation_type_compensation_works_with_array_initializers(bool async) { - await base.Unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); + await base.Optional_navigation_type_compensation_works_with_array_initializers(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE COALESCE([c].[Location], N'') + N'Added' LIKE N'%Add%' +SELECT [s].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL """); } - public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() + public override async Task Optional_navigation_type_compensation_works_with_orderby(bool async) { - base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); + await base.Optional_navigation_type_compensation_works_with_orderby(async); - // Issue#16897 AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +ORDER BY [s].[SquadId] """); } - public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() + public override async Task Optional_navigation_type_compensation_works_with_all(bool async) { - base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); + await base.Optional_navigation_type_compensation_works_with_all(async); - // Issue#16897 AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] +SELECT CASE + WHEN NOT EXISTS ( + SELECT 1 + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] + ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] + WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) + public override async Task Optional_navigation_type_compensation_works_with_negated_predicate(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(async); + await base.Optional_navigation_type_compensation_works_with_negated_predicate(async); - // Issue#16897 AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id] + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) + public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async); + await base.Optional_navigation_type_compensation_works_with_contains(async); - // Issue#16897 AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[SquadId] IN ( + SELECT [g0].[SquadId] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [s].[FullName] = [w0].[OwnerFullName] -LEFT JOIN [Weapons] AS [w1] ON [s].[FullName] = [w1].[OwnerFullName] -LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id], [w0].[Id], [w1].[Id] +) """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) + public override async Task Optional_navigation_type_compensation_works_with_skip(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); + await base.Optional_navigation_type_compensation_works_with_skip(async); + + AssertSql(); + } + + public override async Task Optional_navigation_type_compensation_works_with_take(bool async) + { + await base.Optional_navigation_type_compensation_works_with_take(async); + + AssertSql(); + } + + public override async Task Select_correlated_filtered_collection(bool async) + { + await base.Select_correlated_filtered_collection(async); - // Issue#16897 AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - WHERE [o0].[Nickname] IS NOT NULL -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [c].[Name] IN (N'Ephyra', N'Hanover') +ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) + public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(async); + await base.Select_correlated_filtered_collection_with_composite_key(async); - // Issue#16897 AssertSql( """ -SELECT CASE - WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( @@ -2629,6817 +2643,5562 @@ WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] FROM [Gears] AS [g0] LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id] + WHERE [g0].[Nickname] <> N'Dom' +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async) + public override async Task Select_correlated_filtered_collection_works_with_caching(bool async) { - await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async); + await base.Select_correlated_filtered_collection_works_with_caching(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId], CASE - WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w3].[Id], [w3].[AmmunitionType], [w3].[IsAutomatic], [w3].[Name], [w3].[OwnerFullName], [w3].[SynergyWithId], [w4].[Id], [w4].[AmmunitionType], [w4].[IsAutomatic], [w4].[Name], [w4].[OwnerFullName], [w4].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Weapons] AS [w0] ON [s].[FullName] = [w0].[OwnerFullName] -LEFT JOIN [Weapons] AS [w1] ON [s].[FullName] = [w1].[OwnerFullName] -LEFT JOIN [Weapons] AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -LEFT JOIN [Weapons] AS [w3] ON [s].[FullName] = [w3].[OwnerFullName] -LEFT JOIN [Weapons] AS [w4] ON [g].[FullName] = [w4].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [w].[Id], [w0].[Id], [w1].[Id], [w2].[Id], [w3].[Id] + FROM [Gears] AS [g] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] +ORDER BY [t].[Note], [t].[Id], [s].[Nickname] """); } - public override async Task Coalesce_operator_in_predicate(bool async) + public override async Task Join_predicate_value_equals_condition(bool async) { - await base.Coalesce_operator_in_predicate(async); + await base.Join_predicate_value_equals_condition(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Coalesce_operator_in_predicate_with_other_conditions(bool async) + public override async Task Join_predicate_value(bool async) { - await base.Coalesce_operator_in_predicate_with_other_conditions(async); + await base.Join_predicate_value(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +INNER JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) + public override async Task Join_predicate_condition_equals_condition(bool async) { - await base.Coalesce_operator_in_projection_with_other_conditions(async); + await base.Join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT CASE - WHEN ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND COALESCE([s].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate(bool async) + public override async Task Left_join_predicate_value_equals_condition(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate(async); + await base.Left_join_predicate_value_equals_condition(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(1 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate2(bool async) + public override async Task Left_join_predicate_value(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate2(async); + await base.Left_join_predicate_value(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[HasSoulPatch] = CAST(1 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +LEFT JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated(bool async) + public override async Task Left_join_predicate_condition_equals_condition(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated(async); + await base.Left_join_predicate_condition_equals_condition(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[HasSoulPatch] = CAST(0 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool async) + public override async Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( + bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(async); + await base.Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(async); + + AssertSql(); + } + + public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_property(bool async) + { + await base.Complex_predicate_with_AndAlso_and_nullable_bool_property(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + SELECT [g].[FullName], [g].[HasSoulPatch] FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [s].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE [s].[HasSoulPatch] -END = CAST(0 AS bit) +) AS [s] ON [w].[OwnerFullName] = [s].[FullName] +WHERE [w].[Id] <> 50 AND [s].[HasSoulPatch] = CAST(0 AS bit) """); } - public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool async) + public override async Task Distinct_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(async); + await base.Distinct_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [s].[HasSoulPatch] = CAST(0 AS bit) THEN CAST(0 AS bit) - ELSE [s].[HasSoulPatch] -END = CAST(0 AS bit) +SELECT DISTINCT [g].[HasSoulPatch] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool async) + public override async Task Sum_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_conditional_expression(async); + await base.Sum_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [s].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +SELECT COALESCE(SUM([g].[SquadId]), 0) +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) + public override async Task Count_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_binary_expression(async); + await base.Count_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[HasSoulPatch] = CAST(1 AS bit) OR [t].[Note] LIKE N'%Cole%' +SELECT COUNT(*) +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) + public override async Task FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); + await base.FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(async); AssertSql( """ -SELECT CASE - WHEN [s].[HasSoulPatch] = CAST(1 AS bit) AND [t].[Note] LIKE N'%Cole%' AND [t].[Note] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Tags] AS [t] +SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + SELECT [g].[SquadId] FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task Optional_navigation_type_compensation_works_with_projection(bool async) + public override async Task Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_projection(async); + await base.Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(async); AssertSql( """ -SELECT [s].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE NOT EXISTS ( + SELECT 1 FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL + LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] + WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') """); } - public override async Task Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(bool async) + public override async Task All_with_optional_navigation_is_translated_to_sql(bool async) { - await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(async); + await base.All_with_optional_navigation_is_translated_to_sql(async); AssertSql( """ -SELECT [s].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +SELECT CASE + WHEN NOT EXISTS ( + SELECT 1 + FROM [Gears] AS [g] + LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] + WHERE [t].[Note] = N'Foo') THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) + public override async Task Contains_with_local_nullable_guid_list_closure(bool async) { - await base.Optional_navigation_type_compensation_works_with_DTOs(async); + await base.Contains_with_local_nullable_guid_list_closure(async); AssertSql( """ -SELECT [s].[SquadId] AS [Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -"""); - } - - public override async Task Optional_navigation_type_compensation_works_with_list_initializers(bool async) - { - await base.Optional_navigation_type_compensation_works_with_list_initializers(async); +@ids='["df36f493-463f-4123-83f9-6b135deeb7ba","23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3","ab1b82d7-88db-42bd-a132-7eef9aa68af4"]' (Size = 4000) - AssertSql( - """ -SELECT [s].[SquadId], [s].[SquadId] + 1 +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -ORDER BY [t].[Note] +WHERE [t].[Id] IN ( + SELECT [i].[value] + FROM OPENJSON(@ids) WITH ([value] uniqueidentifier '$') AS [i] +) """); } - public override async Task Optional_navigation_type_compensation_works_with_array_initializers(bool async) + public override async Task Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(bool async) { - await base.Optional_navigation_type_compensation_works_with_array_initializers(async); + await base.Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(async); AssertSql( """ -SELECT [s].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL +SELECT [g].[FullName] +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g].[Rank] """); } - public override async Task Optional_navigation_type_compensation_works_with_orderby(bool async) + public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(bool async) { - await base.Optional_navigation_type_compensation_works_with_orderby(async); + await base.Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL -ORDER BY [s].[SquadId] +SELECT [g].[FullName] +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_all(bool async) + public override async Task Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(bool async) { - await base.Optional_navigation_type_compensation_works_with_all(async); + await base.Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(async); AssertSql( """ -SELECT CASE - WHEN NOT EXISTS ( - SELECT 1 - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] - WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(0 AS bit)) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [g].[FullName] +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_negated_predicate(bool async) + public override async Task Where_is_properly_lifted_from_subquery_created_by_include(bool async) { - await base.Optional_navigation_type_compensation_works_with_negated_predicate(async); + await base.Where_is_properly_lifted_from_subquery_created_by_include(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[HasSoulPatch] = CAST(0 AS bit) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [g].[FullName] <> N'Augustus Cole' AND [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) + public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMany(bool async) { - await base.Optional_navigation_type_compensation_works_with_contains(async); + await base.Subquery_is_lifted_from_main_from_clause_of_SelectMany(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE ([t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL) AND [s].[SquadId] IN ( - SELECT [g0].[SquadId] +SELECT [g].[FullName] AS [Name1], [s].[FullName] AS [Name2] +FROM [Gears] AS [g] +CROSS JOIN ( + SELECT [g0].[FullName], [g0].[HasSoulPatch] FROM [Gears] AS [g0] -) +) AS [s] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [s].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Optional_navigation_type_compensation_works_with_skip(bool async) - { - await base.Optional_navigation_type_compensation_works_with_skip(async); - - AssertSql(); - } - - public override async Task Optional_navigation_type_compensation_works_with_take(bool async) - { - await base.Optional_navigation_type_compensation_works_with_take(async); - - AssertSql(); - } - - public override async Task Select_correlated_filtered_collection(bool async) + public override async Task Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(bool async) { - await base.Select_correlated_filtered_collection(async); + await base.Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [g].[FullName] FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Lancer' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [c].[Name] IN (N'Ephyra', N'Hanover') -ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] +CROSS JOIN [Tags] AS [t] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) + public override async Task Subquery_containing_join_projecting_main_from_clause_gets_lifted(bool async) { - await base.Select_correlated_filtered_collection_with_composite_key(async); + await base.Subquery_containing_join_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT [g].[Nickname] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - WHERE [g0].[Nickname] <> N'Dom' -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] +INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +ORDER BY [g].[Nickname] """); } - public override async Task Select_correlated_filtered_collection_works_with_caching(bool async) + public override async Task Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(bool async) { - await base.Select_correlated_filtered_collection_works_with_caching(async); + await base.Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(async); AssertSql( """ -SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] -ORDER BY [t].[Note], [t].[Id], [s].[Nickname] +SELECT [g].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +ORDER BY [g].[Nickname] """); } - public override async Task Join_predicate_value_equals_condition(bool async) + public override async Task Subquery_containing_join_gets_lifted_clashing_names(bool async) { - await base.Join_predicate_value_equals_condition(async); + await base.Subquery_containing_join_gets_lifted_clashing_names(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +INNER JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] +WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL +ORDER BY [g].[Nickname], [t0].[Id] """); } - public override async Task Join_predicate_value(bool async) + public override async Task Subquery_created_by_include_gets_lifted_nested(bool async) { - await base.Join_predicate_value(async); + await base.Subquery_created_by_include_gets_lifted_nested(async); AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +WHERE EXISTS ( + SELECT 1 + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) AND [g].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[Nickname] """); } - public override async Task Join_predicate_condition_equals_condition(bool async) + public override async Task Subquery_is_lifted_from_additional_from_clause(bool async) { - await base.Join_predicate_condition_equals_condition(async); + await base.Subquery_is_lifted_from_additional_from_clause(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[FullName] AS [Name1], [s].[FullName] AS [Name2] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +CROSS JOIN ( + SELECT [g0].[FullName], [g0].[HasSoulPatch] + FROM [Gears] AS [g0] +) AS [s] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [s].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [g].[FullName] """); } - public override async Task Left_join_predicate_value_equals_condition(bool async) + public override async Task Subquery_with_result_operator_is_not_lifted(bool async) { - await base.Left_join_predicate_value_equals_condition(async); + await base.Subquery_with_result_operator_is_not_lifted(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +@p='2' + +SELECT [s].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) + ORDER BY [g].[FullName] +) AS [s] +ORDER BY [s].[Rank] """); } - public override async Task Left_join_predicate_value(bool async) + public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down(bool async) { - await base.Left_join_predicate_value(async); + await base.Skip_with_orderby_followed_by_orderBy_is_pushed_down(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -LEFT JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit) +@p='1' + +SELECT [s].[FullName] +FROM ( + SELECT [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) + ORDER BY [g].[FullName] + OFFSET @p ROWS +) AS [s] +ORDER BY [s].[Rank] """); } - public override async Task Left_join_predicate_condition_equals_condition(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) { - await base.Left_join_predicate_condition_equals_condition(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL +@p='999' + +SELECT [s].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +) AS [s] +ORDER BY [s].[Rank] """); } - public override async Task Where_datetimeoffset_now(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) { - await base.Where_datetimeoffset_now(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] <> SYSDATETIMEOFFSET() +@p='999' + +SELECT [s].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +) AS [s] +ORDER BY [s].[Rank] """); } - public override async Task Where_datetimeoffset_utcnow(bool async) + public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) { - await base.Where_datetimeoffset_utcnow(async); + await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) +@p='999' + +SELECT [s].[FullName] +FROM ( + SELECT TOP(@p) [g].[FullName], [g].[Rank] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(0 AS bit) +) AS [s] +ORDER BY [s].[FullName], [s].[Rank] """); } - public override async Task Where_datetimeoffset_date_component(bool async) + public override async Task Select_length_of_string_property(bool async) { - await base.Where_datetimeoffset_date_component(async); + await base.Select_length_of_string_property(async); AssertSql( """ -@Date='0001-01-01T00:00:00.0000000' - -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONVERT(date, [m].[Timeline]) > @Date +SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] +FROM [Weapons] AS [w] """); } - public override async Task Where_datetimeoffset_year_component(bool async) + public override async Task Client_method_on_collection_navigation_in_outer_join_key(bool async) { - await base.Where_datetimeoffset_year_component(async); + await base.Client_method_on_collection_navigation_in_outer_join_key(async); - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(year, [m].[Timeline]) = 2 -"""); + AssertSql(); } - public override async Task Where_datetimeoffset_month_component(bool async) + public override async Task Member_access_on_derived_entity_using_cast(bool async) { - await base.Where_datetimeoffset_month_component(async); + await base.Member_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(month, [m].[Timeline]) = 1 +SELECT [f].[Name], [l].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task Where_datetimeoffset_dayofyear_component(bool async) + public override async Task Member_access_on_derived_materialized_entity_using_cast(bool async) { - await base.Where_datetimeoffset_dayofyear_component(async); + await base.Member_access_on_derived_materialized_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(dayofyear, [m].[Timeline]) = 2 +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task Where_datetimeoffset_day_component(bool async) + public override async Task Member_access_on_derived_entity_using_cast_and_let(bool async) { - await base.Where_datetimeoffset_day_component(async); + await base.Member_access_on_derived_entity_using_cast_and_let(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(day, [m].[Timeline]) = 2 +SELECT [f].[Name], [l].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task Where_datetimeoffset_hour_component(bool async) + public override async Task Property_access_on_derived_entity_using_cast(bool async) { - await base.Where_datetimeoffset_hour_component(async); + await base.Property_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Timeline]) = 10 +SELECT [f].[Name], [l].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task Where_datetimeoffset_minute_component(bool async) + public override async Task Navigation_access_on_derived_entity_using_cast(bool async) { - await base.Where_datetimeoffset_minute_component(async); + await base.Navigation_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Timeline]) = 0 +SELECT [f].[Name], [s].[ThreatLevel] AS [Threat] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[ThreatLevel] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task Where_datetimeoffset_second_component(bool async) + public override async Task Navigation_access_on_derived_materialized_entity_using_cast(bool async) { - await base.Where_datetimeoffset_second_component(async); + await base.Navigation_access_on_derived_materialized_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Timeline]) = 0 +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator], [s].[ThreatLevel] AS [Threat] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[ThreatLevel] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task Where_datetimeoffset_millisecond_component(bool async) + public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) { - await base.Where_datetimeoffset_millisecond_component(async); + await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Timeline]) = 0 +SELECT [f].[Name], [s].[ThreatLevel] AS [Threat] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[ThreatLevel] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddMonths(bool async) + public override async Task Navigation_access_fk_on_derived_entity_using_cast(bool async) { - await base.DateTimeOffset_DateAdd_AddMonths(async); + await base.Navigation_access_fk_on_derived_entity_using_cast(async); AssertSql( """ -SELECT DATEADD(month, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [f].[Name], [s].[Name] AS [CommanderName] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddDays(bool async) + public override async Task Collection_navigation_access_on_derived_entity_using_cast(bool async) { - await base.DateTimeOffset_DateAdd_AddDays(async); + await base.Collection_navigation_access_on_derived_entity_using_cast(async); AssertSql( """ -SELECT DATEADD(day, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [f].[Name], ( + SELECT COUNT(*) + FROM [LocustLeaders] AS [l0] + WHERE [f].[Id] = [l0].[LocustHordeId]) AS [LeadersCount] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddHours(bool async) + public override async Task Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(bool async) { - await base.DateTimeOffset_DateAdd_AddHours(async); + await base.Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(async); AssertSql( """ -SELECT DATEADD(hour, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [f].[Name], [s].[Name] AS [LeaderName] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +INNER JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId] + FROM [LocustLeaders] AS [l0] +) AS [s] ON [f].[Id] = [s].[LocustHordeId] +WHERE [l].[Id] IS NOT NULL +ORDER BY [s].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddMinutes(bool async) + public override async Task Include_on_derived_entity_using_OfType(bool async) { - await base.DateTimeOffset_DateAdd_AddMinutes(async); + await base.Include_on_derived_entity_using_OfType(async); AssertSql( """ -SELECT DATEADD(minute, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +LEFT JOIN ( + SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId], CASE + WHEN [l3].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator] + FROM [LocustLeaders] AS [l2] + LEFT JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] +) AS [s0] ON [f].[Id] = [s0].[LocustHordeId] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Name], [f].[Id], [s].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddSeconds(bool async) + public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) { - await base.DateTimeOffset_DateAdd_AddSeconds(async); + await base.Distinct_on_subquery_doesnt_get_lifted(async); AssertSql( """ -SELECT DATEADD(second, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [s].[HasSoulPatch] +FROM ( + SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] """); } - public override async Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) + public override async Task Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(bool async) { - await base.DateTimeOffset_DateAdd_AddMilliseconds(async); + await base.Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(async); AssertSql( """ -SELECT DATEADD(millisecond, CAST(300.0E0 AS int), [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [l].[Eradicated] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] """); } - public override async Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) + public override async Task Comparing_two_collection_navigations_composite_key(bool async) { - await base.Where_datetimeoffset_milliseconds_parameter_and_constant(async); + await base.Comparing_two_collection_navigations_composite_key(async); AssertSql( """ -SELECT COUNT(*) -FROM [Missions] AS [m] -WHERE [m].[Timeline] = '1902-01-02T10:00:00.1234567+01:30' +SELECT [g].[Nickname] AS [Nickname1], [s].[Nickname] AS [Nickname2] +FROM [Gears] AS [g] +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] +) AS [s] +WHERE [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] +ORDER BY [g].[Nickname] """); } - public override async Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( - bool async) - { - await base.Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(async); - - AssertSql(); - } - - public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_property(bool async) + public override async Task Comparing_two_collection_navigations_inheritance(bool async) { - await base.Complex_predicate_with_AndAlso_and_nullable_bool_property(async); + await base.Comparing_two_collection_navigations_inheritance(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[FullName], [g].[HasSoulPatch] +SELECT [f].[Name], [s].[Nickname] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +CROSS JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] -) AS [s] ON [w].[OwnerFullName] = [s].[FullName] -WHERE [w].[Id] <> 50 AND [s].[HasSoulPatch] = CAST(0 AS bit) + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] + WHERE [o].[Nickname] IS NOT NULL +) AS [s] +LEFT JOIN ( + SELECT [l0].[Name], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s0] ON [l].[CommanderName] = [s0].[Name] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] +) AS [s1] ON [s0].[DefeatedByNickname] = [s1].[Nickname] AND [s0].[DefeatedBySquadId] = [s1].[SquadId] +WHERE [l].[Id] IS NOT NULL AND [s].[HasSoulPatch] = CAST(1 AS bit) AND [s1].[Nickname] = [s].[Nickname] AND [s1].[SquadId] = [s].[SquadId] """); } - public override async Task Distinct_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Comparing_entities_using_Equals_inheritance(bool async) { - await base.Distinct_with_optional_navigation_is_translated_to_sql(async); + await base.Comparing_entities_using_Equals_inheritance(async); AssertSql( """ -SELECT DISTINCT [g].[HasSoulPatch] +SELECT [g].[Nickname] AS [Nickname1], [s].[Nickname] AS [Nickname2] FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] + WHERE [o].[Nickname] IS NOT NULL +) AS [s] +WHERE [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] +ORDER BY [g].[Nickname], [s].[Nickname] """); } - public override async Task Sum_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Contains_on_nullable_array_produces_correct_sql(bool async) { - await base.Sum_with_optional_navigation_is_translated_to_sql(async); + await base.Contains_on_nullable_array_produces_correct_sql(async); AssertSql( """ -SELECT COALESCE(SUM([g].[SquadId]), 0) -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL -"""); - } - - public override async Task Count_with_optional_navigation_is_translated_to_sql(bool async) - { - await base.Count_with_optional_navigation_is_translated_to_sql(async); +@cities_without_nulls='["Ephyra"]' (Size = 4000) - AssertSql( - """ -SELECT COUNT(*) +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +WHERE [g].[SquadId] < 2 AND ([c].[Name] IN ( + SELECT [c0].[value] + FROM OPENJSON(@cities_without_nulls) AS [c0] +) OR [c].[Name] IS NULL) """); } - public override async Task FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(bool async) + public override async Task Optional_navigation_with_collection_composite_key(bool async) { - await base.FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(async); + await base.Optional_navigation_with_collection_composite_key(async); AssertSql( """ -SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[SquadId] + SELECT [g].[Nickname], [g].[SquadId], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] FROM [Gears] AS [g] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -WHERE [s].[Name] = N'Kilo' + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE [s].[Discriminator] = N'Officer' AND ( + SELECT COUNT(*) + FROM [Gears] AS [g0] + WHERE [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL AND [s].[Nickname] = [g0].[LeaderNickname] AND [s].[SquadId] = [g0].[LeaderSquadId] AND [g0].[Nickname] = N'Dom') > 0 """); } - public override async Task Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(bool async) + public override async Task Select_null_conditional_with_inheritance(bool async) { - await base.Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(async); + await base.Select_null_conditional_with_inheritance(async); AssertSql( """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE NOT EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] - WHERE [s].[Id] = [g].[SquadId] AND [t].[Note] = N'Dom''s Tag') +SELECT CASE + WHEN [l].[CommanderName] IS NOT NULL THEN [l].[CommanderName] +END +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +WHERE [l].[Id] IS NOT NULL """); } - public override async Task All_with_optional_navigation_is_translated_to_sql(bool async) + public override async Task Select_null_conditional_with_inheritance_negative(bool async) { - await base.All_with_optional_navigation_is_translated_to_sql(async); + await base.Select_null_conditional_with_inheritance_negative(async); AssertSql( """ SELECT CASE - WHEN NOT EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] - WHERE [t].[Note] = N'Foo') THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) + WHEN [l].[CommanderName] IS NOT NULL THEN [l].[Eradicated] END +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +WHERE [l].[Id] IS NOT NULL """); } - public override async Task Contains_with_local_nullable_guid_list_closure(bool async) + public override async Task Project_collection_navigation_with_inheritance1(bool async) { - await base.Contains_with_local_nullable_guid_list_closure(async); + await base.Project_collection_navigation_with_inheritance1(async); AssertSql( """ -@ids='["df36f493-463f-4123-83f9-6b135deeb7ba","23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3","ab1b82d7-88db-42bd-a132-7eef9aa68af4"]' (Size = 4000) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] IN ( - SELECT [i].[value] - FROM OPENJSON(@ids) WITH ([value] uniqueidentifier '$') AS [i] -) +SELECT [f].[Id], [s].[Name], [s0].[Id], [s1].[Name], [s1].[LocustHordeId], [s1].[ThreatLevel], [s1].[ThreatLevelByte], [s1].[ThreatLevelNullableByte], [s1].[DefeatedByNickname], [s1].[DefeatedBySquadId], [s1].[HighCommandId], [s1].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +LEFT JOIN ( + SELECT [f0].[Id], [l2].[CommanderName] + FROM [Factions] AS [f0] + INNER JOIN [LocustHordes] AS [l2] ON [f0].[Id] = [l2].[Id] +) AS [s0] ON [s].[Name] = [s0].[CommanderName] +LEFT JOIN ( + SELECT [l3].[Name], [l3].[LocustHordeId], [l3].[ThreatLevel], [l3].[ThreatLevelByte], [l3].[ThreatLevelNullableByte], [l4].[DefeatedByNickname], [l4].[DefeatedBySquadId], [l4].[HighCommandId], CASE + WHEN [l4].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator] + FROM [LocustLeaders] AS [l3] + LEFT JOIN [LocustCommanders] AS [l4] ON [l3].[Name] = [l4].[Name] +) AS [s1] ON [s0].[Id] = [s1].[LocustHordeId] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Id], [s].[Name], [s0].[Id] """); } - public override async Task Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(bool async) + public override async Task Project_collection_navigation_with_inheritance2(bool async) { - await base.Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(async); + await base.Project_collection_navigation_with_inheritance2(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g].[Rank] +SELECT [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] +) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] """); } - public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(bool async) + public override async Task Project_collection_navigation_with_inheritance3(bool async) { - await base.Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(async); + await base.Project_collection_navigation_with_inheritance3(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +SELECT [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] +) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] +WHERE [l].[Id] IS NOT NULL +ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] """); } - public override async Task Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(bool async) + public override async Task Include_reference_on_derived_type_using_string(bool async) { - await base.Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(async); + await base.Include_reference_on_derived_type_using_string(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] """); } - public override async Task Where_is_properly_lifted_from_subquery_created_by_include(bool async) + public override async Task Include_reference_on_derived_type_using_string_nested1(bool async) { - await base.Where_is_properly_lifted_from_subquery_created_by_include(async); + await base.Include_reference_on_derived_type_using_string_nested1(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [g].[FullName] <> N'Augustus Cole' AND [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s0].[Id], [s0].[Banner], [s0].[Banner5], [s0].[InternalNumber], [s0].[Name] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] +LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] """); } - public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMany(bool async) + public override async Task Include_reference_on_derived_type_using_string_nested2(bool async) { - await base.Subquery_is_lifted_from_main_from_clause_of_SelectMany(async); + await base.Include_reference_on_derived_type_using_string_nested2(async); AssertSql( """ -SELECT [g].[FullName] AS [Name1], [s].[FullName] AS [Name2] -FROM [Gears] AS [g] -CROSS JOIN ( - SELECT [g0].[FullName], [g0].[HasSoulPatch] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation] FROM [Gears] AS [g0] -) AS [s] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [s].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] +) AS [s0] ON ([s].[Nickname] = [s0].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s0].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s0].[LeaderSquadId] +ORDER BY [l].[Name], [s].[Nickname], [s].[SquadId], [s0].[Nickname], [s0].[SquadId] """); } - public override async Task Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Include_reference_on_derived_type_using_lambda(bool async) { - await base.Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(async); + await base.Include_reference_on_derived_type_using_lambda(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -CROSS JOIN [Tags] AS [t] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g].[FullName] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] """); } - public override async Task Subquery_containing_join_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Include_reference_on_derived_type_using_lambda_with_soft_cast(bool async) { - await base.Subquery_containing_join_projecting_main_from_clause_gets_lifted(async); + await base.Include_reference_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -ORDER BY [g].[Nickname] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] """); } - public override async Task Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(bool async) + public override async Task Include_reference_on_derived_type_using_lambda_with_tracking(bool async) { - await base.Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(async); + await base.Include_reference_on_derived_type_using_lambda_with_tracking(async); AssertSql( """ -SELECT [g].[Nickname] -FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -ORDER BY [g].[Nickname] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] """); } - public override async Task Subquery_containing_join_gets_lifted_clashing_names(bool async) + public override async Task Include_collection_on_derived_type_using_string(bool async) { - await base.Subquery_containing_join_gets_lifted_clashing_names(async); + await base.Include_collection_on_derived_type_using_string(async); AssertSql( """ -SELECT [g].[Nickname] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] -INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -INNER JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] -WHERE [t].[GearNickName] <> N'Cole Train' OR [t].[GearNickName] IS NULL -ORDER BY [g].[Nickname], [t0].[Id] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Subquery_created_by_include_gets_lifted_nested(bool async) + public override async Task Include_collection_on_derived_type_using_lambda(bool async) { - await base.Subquery_created_by_include_gets_lifted_nested(async); + await base.Include_collection_on_derived_type_using_lambda(async); AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation] +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -WHERE EXISTS ( - SELECT 1 - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) AND [g].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[Nickname] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Subquery_is_lifted_from_additional_from_clause(bool async) + public override async Task Include_collection_on_derived_type_using_lambda_with_soft_cast(bool async) { - await base.Subquery_is_lifted_from_additional_from_clause(async); + await base.Include_collection_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( """ -SELECT [g].[FullName] AS [Name1], [s].[FullName] AS [Name2] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] -CROSS JOIN ( - SELECT [g0].[FullName], [g0].[HasSoulPatch] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] FROM [Gears] AS [g0] -) AS [s] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) AND [s].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [g].[FullName] -"""); - } - - public override async Task Subquery_with_result_operator_is_not_lifted(bool async) - { - await base.Subquery_with_result_operator_is_not_lifted(async); - - AssertSql( - """ -@p='2' - -SELECT [s].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) - ORDER BY [g].[FullName] -) AS [s] -ORDER BY [s].[Rank] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down(bool async) + public override async Task Include_base_navigation_on_derived_entity(bool async) { - await base.Skip_with_orderby_followed_by_orderBy_is_pushed_down(async); + await base.Include_base_navigation_on_derived_entity(async); AssertSql( """ -@p='1' - -SELECT [s].[FullName] -FROM ( - SELECT [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) - ORDER BY [g].[FullName] - OFFSET @p ROWS -) AS [s] -ORDER BY [s].[Rank] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) + public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); + await base.ThenInclude_collection_on_derived_after_base_reference(async); AssertSql( """ -@p='999' - -SELECT [s].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -) AS [s] -ORDER BY [s].[Rank] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) + public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); + await base.ThenInclude_collection_on_derived_after_derived_reference(async); AssertSql( """ -@p='999' - -SELECT [s].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -) AS [s] -ORDER BY [s].[Rank] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] +ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] """); } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) + public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) { - await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); + await base.ThenInclude_collection_on_derived_after_derived_collection(async); AssertSql( """ -@p='999' - -SELECT [s].[FullName] -FROM ( - SELECT TOP(@p) [g].[FullName], [g].[Rank] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(0 AS bit) -) AS [s] -ORDER BY [s].[FullName], [s].[Rank] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Nickname0], [s0].[SquadId0], [s0].[AssignedCityName0], [s0].[CityOfBirthName0], [s0].[FullName0], [s0].[HasSoulPatch0], [s0].[LeaderNickname0], [s0].[LeaderSquadId0], [s0].[Rank0], [s0].[Discriminator0] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], [s].[Nickname] AS [Nickname0], [s].[SquadId] AS [SquadId0], [s].[AssignedCityName] AS [AssignedCityName0], [s].[CityOfBirthName] AS [CityOfBirthName0], [s].[FullName] AS [FullName0], [s].[HasSoulPatch] AS [HasSoulPatch0], [s].[LeaderNickname] AS [LeaderNickname0], [s].[LeaderSquadId] AS [LeaderSquadId0], [s].[Rank] AS [Rank0], [s].[Discriminator] AS [Discriminator0] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], CASE + WHEN [o1].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g1] + LEFT JOIN [Officers] AS [o1] ON [g1].[Nickname] = [o1].[Nickname] AND [g1].[SquadId] = [o1].[SquadId] + ) AS [s] ON [g0].[Nickname] = [s].[LeaderNickname] AND [g0].[SquadId] = [s].[LeaderSquadId] +) AS [s0] ON [g].[Nickname] = [s0].[LeaderNickname] AND [g].[SquadId] = [s0].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Nickname], [s0].[SquadId], [s0].[Nickname0] """); } - public override async Task Select_length_of_string_property(bool async) + public override async Task ThenInclude_reference_on_derived_after_derived_collection(bool async) { - await base.Select_length_of_string_property(async); + await base.ThenInclude_reference_on_derived_after_derived_collection(async); AssertSql( """ -SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] -FROM [Weapons] AS [w] +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator], [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator0] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE + WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] AS [Discriminator0] + FROM [LocustLeaders] AS [l0] + LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] + LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] + ) AS [s] ON [l1].[DefeatedByNickname] = [s].[Nickname] AND [l1].[DefeatedBySquadId] = [s].[SquadId] +) AS [s0] ON [f].[Id] = [s0].[LocustHordeId] +ORDER BY [f].[Id], [s0].[Name], [s0].[Nickname] """); } - public override async Task Client_method_on_collection_navigation_in_outer_join_key(bool async) - { - await base.Client_method_on_collection_navigation_in_outer_join_key(async); - - AssertSql(); - } - - public override async Task Member_access_on_derived_entity_using_cast(bool async) + public override async Task Multiple_derived_included_on_one_method(bool async) { - await base.Member_access_on_derived_entity_using_cast(async); + await base.Multiple_derived_included_on_one_method(async); AssertSql( """ -SELECT [f].[Name], [l].[Eradicated] +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] FROM [Factions] AS [f] LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] +ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] """); } - public override async Task Member_access_on_derived_materialized_entity_using_cast(bool async) + public override async Task Include_on_derived_multi_level(bool async) { - await base.Member_access_on_derived_materialized_entity_using_cast(async); + await base.Include_on_derived_multi_level(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Id], [s1].[Banner], [s1].[Banner5], [s1].[InternalNumber], [s1].[Name], [s1].[SquadId0], [s1].[MissionId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[SquadId] AS [SquadId0], [s0].[MissionId] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + INNER JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] + LEFT JOIN [SquadMissions] AS [s0] ON [s].[Id] = [s0].[SquadId] +) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] +ORDER BY [g].[Nickname], [g].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[SquadId0] """); } - public override async Task Member_access_on_derived_entity_using_cast_and_let(bool async) + public override async Task Projecting_nullable_bool_in_conditional_works(bool async) { - await base.Member_access_on_derived_entity_using_cast_and_let(async); + await base.Projecting_nullable_bool_in_conditional_works(async); AssertSql( """ -SELECT [f].[Name], [l].[Eradicated] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +SELECT CASE + WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN [s].[HasSoulPatch] + ELSE CAST(0 AS bit) +END AS [Prop] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] """); } - public override async Task Property_access_on_derived_entity_using_cast(bool async) + public override async Task ToString_enum_property_projection(bool async) { - await base.Property_access_on_derived_entity_using_cast(async); + await base.ToString_enum_property_projection(async); AssertSql( """ -SELECT [f].[Name], [l].[Eradicated] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +SELECT CASE [g].[Rank] + WHEN 0 THEN N'None' + WHEN 1 THEN N'Private' + WHEN 2 THEN N'Corporal' + WHEN 4 THEN N'Sergeant' + WHEN 8 THEN N'Lieutenant' + WHEN 16 THEN N'Captain' + WHEN 32 THEN N'Major' + WHEN 64 THEN N'Colonel' + WHEN 128 THEN N'General' + ELSE CAST([g].[Rank] AS nvarchar(max)) +END +FROM [Gears] AS [g] """); } - public override async Task Navigation_access_on_derived_entity_using_cast(bool async) + public override async Task ToString_nullable_enum_property_projection(bool async) { - await base.Navigation_access_on_derived_entity_using_cast(async); + await base.ToString_nullable_enum_property_projection(async); AssertSql( """ -SELECT [f].[Name], [s].[ThreatLevel] AS [Threat] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[ThreatLevel] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +SELECT CASE [w].[AmmunitionType] + WHEN 1 THEN N'Cartridge' + WHEN 2 THEN N'Shell' + ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') +END +FROM [Weapons] AS [w] """); } - public override async Task Navigation_access_on_derived_materialized_entity_using_cast(bool async) + public override async Task ToString_enum_contains(bool async) { - await base.Navigation_access_on_derived_materialized_entity_using_cast(async); + await base.ToString_enum_contains(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator], [s].[ThreatLevel] AS [Threat] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[ThreatLevel] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +SELECT [m].[CodeName] +FROM [Missions] AS [m] +WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' """); } - public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) + public override async Task ToString_nullable_enum_contains(bool async) { - await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); + await base.ToString_nullable_enum_contains(async); AssertSql( """ -SELECT [f].[Name], [s].[ThreatLevel] AS [Threat] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[ThreatLevel] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +SELECT [w].[Name] +FROM [Weapons] AS [w] +WHERE CASE [w].[AmmunitionType] + WHEN 1 THEN N'Cartridge' + WHEN 2 THEN N'Shell' + ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') +END LIKE N'%Cart%' """); } - public override async Task Navigation_access_fk_on_derived_entity_using_cast(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) { - await base.Navigation_access_fk_on_derived_entity_using_cast(async); + await base.Correlated_collections_naked_navigation_with_ToList(async); AssertSql( """ -SELECT [f].[Name], [s].[Name] AS [CommanderName] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Collection_navigation_access_on_derived_entity_using_cast(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool async) { - await base.Collection_navigation_access_on_derived_entity_using_cast(async); + await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(async); AssertSql( """ -SELECT [f].[Name], ( +SELECT ( SELECT COUNT(*) - FROM [LocustLeaders] AS [l0] - WHERE [f].[Id] = [l0].[LocustHordeId]) AS [LeadersCount] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) +FROM [Gears] AS [g] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname] """); } - public override async Task Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(bool async) + public override async Task Correlated_collections_naked_navigation_with_ToArray(bool async) { - await base.Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(async); + await base.Correlated_collections_naked_navigation_with_ToArray(async); AssertSql( """ -SELECT [f].[Name], [s].[Name] AS [LeaderName] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -INNER JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId] - FROM [LocustLeaders] AS [l0] -) AS [s] ON [f].[Id] = [s].[LocustHordeId] -WHERE [l].[Id] IS NOT NULL -ORDER BY [s].[Name] +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Include_on_derived_entity_using_OfType(bool async) + public override async Task Correlated_collections_basic_projection(bool async) { - await base.Include_on_derived_entity_using_OfType(async); + await base.Correlated_collections_basic_projection(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId], CASE - WHEN [l3].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator] - FROM [LocustLeaders] AS [l2] - LEFT JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] -) AS [s0] ON [f].[Id] = [s0].[LocustHordeId] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Name], [f].[Id], [s].[Name] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) + public override async Task Correlated_collections_basic_projection_explicit_to_list(bool async) { - await base.Distinct_on_subquery_doesnt_get_lifted(async); + await base.Correlated_collections_basic_projection_explicit_to_list(async); AssertSql( """ -SELECT [s].[HasSoulPatch] -FROM ( - SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(bool async) + public override async Task Correlated_collections_basic_projection_explicit_to_array(bool async) { - await base.Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(async); + await base.Correlated_collections_basic_projection_explicit_to_array(async); AssertSql( """ -SELECT [l].[Eradicated] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Comparing_two_collection_navigations_composite_key(bool async) + public override async Task Correlated_collections_basic_projection_ordered(bool async) { - await base.Comparing_two_collection_navigations_composite_key(async); + await base.Correlated_collections_basic_projection_ordered(async); AssertSql( """ -SELECT [g].[Nickname] AS [Nickname1], [s].[Nickname] AS [Nickname2] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] -) AS [s] -WHERE [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] -ORDER BY [g].[Nickname] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] DESC """); } - public override async Task Comparing_two_collection_navigations_inheritance(bool async) + public override async Task Correlated_collections_basic_projection_composite_key(bool async) { - await base.Comparing_two_collection_navigations_inheritance(async); + await base.Correlated_collections_basic_projection_composite_key(async); AssertSql( """ -SELECT [f].[Name], [s].[Nickname] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -CROSS JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE [o].[Nickname] IS NOT NULL -) AS [s] -LEFT JOIN ( - SELECT [l0].[Name], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s0] ON [l].[CommanderName] = [s0].[Name] +SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[FullName], [s].[SquadId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] + SELECT [g0].[Nickname], [g0].[FullName], [g0].[SquadId], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] -) AS [s1] ON [s0].[DefeatedByNickname] = [s1].[Nickname] AND [s0].[DefeatedBySquadId] = [s1].[SquadId] -WHERE [l].[Id] IS NOT NULL AND [s].[HasSoulPatch] = CAST(1 AS bit) AND [s1].[Nickname] = [s].[Nickname] AND [s1].[SquadId] = [s].[SquadId] + WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL AND [g].[Nickname] <> N'Foo' +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Comparing_entities_using_Equals_inheritance(bool async) + public override async Task Correlated_collections_basic_projecting_single_property(bool async) { - await base.Comparing_entities_using_Equals_inheritance(async); + await base.Correlated_collections_basic_projecting_single_property(async); AssertSql( """ -SELECT [g].[Nickname] AS [Nickname1], [s].[Nickname] AS [Nickname2] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[Id] FROM [Gears] AS [g] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] - WHERE [o].[Nickname] IS NOT NULL -) AS [s] -WHERE [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] -ORDER BY [g].[Nickname], [s].[Nickname] +LEFT JOIN ( + SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Contains_on_nullable_array_produces_correct_sql(bool async) + public override async Task Correlated_collections_basic_projecting_constant(bool async) { - await base.Contains_on_nullable_array_produces_correct_sql(async); + await base.Correlated_collections_basic_projecting_constant(async); AssertSql( """ -@cities_without_nulls='["Ephyra"]' (Size = 4000) - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE [g].[SquadId] < 2 AND ([c].[Name] IN ( - SELECT [c0].[value] - FROM OPENJSON(@cities_without_nulls) AS [c0] -) OR [c].[Name] IS NULL) +LEFT JOIN ( + SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Optional_navigation_with_collection_composite_key(bool async) + public override async Task Correlated_collections_basic_projecting_constant_bool(bool async) { - await base.Optional_navigation_with_collection_composite_key(async); + await base.Correlated_collections_basic_projecting_constant_bool(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] +SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], CASE - 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] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Discriminator] = N'Officer' AND ( - SELECT COUNT(*) - FROM [Gears] AS [g0] - WHERE [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL AND [s].[Nickname] = [g0].[LeaderNickname] AND [s].[SquadId] = [g0].[LeaderSquadId] AND [g0].[Nickname] = N'Dom') > 0 + SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Select_null_conditional_with_inheritance(bool async) + public override async Task Correlated_collections_projection_of_collection_thru_navigation(bool async) { - await base.Select_null_conditional_with_inheritance(async); + await base.Correlated_collections_projection_of_collection_thru_navigation(async); AssertSql( """ -SELECT CASE - WHEN [l].[CommanderName] IS NOT NULL THEN [l].[CommanderName] -END -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -WHERE [l].[Id] IS NOT NULL +SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId], [s1].[MissionId] +FROM [Gears] AS [g] +INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +LEFT JOIN ( + SELECT [s0].[SquadId], [s0].[MissionId] + FROM [SquadMissions] AS [s0] + WHERE [s0].[MissionId] <> 17 +) AS [s1] ON [s].[Id] = [s1].[SquadId] +WHERE [g].[Nickname] <> N'Marcus' +ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] """); } - public override async Task Select_null_conditional_with_inheritance_negative(bool async) + public override async Task Correlated_collections_project_anonymous_collection_result(bool async) { - await base.Select_null_conditional_with_inheritance_negative(async); + await base.Correlated_collections_project_anonymous_collection_result(async); AssertSql( """ -SELECT CASE - WHEN [l].[CommanderName] IS NOT NULL THEN [l].[Eradicated] -END -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -WHERE [l].[Id] IS NOT NULL +SELECT [s].[Name], [s].[Id], [s0].[FullName], [s0].[Rank], [s0].[Nickname], [s0].[SquadId] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g].[FullName], [g].[Rank], [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +WHERE [s].[Id] < 20 +ORDER BY [s].[Id], [s0].[Nickname] """); } - public override async Task Project_collection_navigation_with_inheritance1(bool async) + public override async Task Correlated_collections_nested(bool async) { - await base.Project_collection_navigation_with_inheritance1(async); + await base.Correlated_collections_nested(async); AssertSql( """ -SELECT [f].[Id], [s].[Name], [s0].[Id], [s1].[Name], [s1].[LocustHordeId], [s1].[ThreatLevel], [s1].[ThreatLevelByte], [s1].[ThreatLevelNullableByte], [s1].[DefeatedByNickname], [s1].[DefeatedBySquadId], [s1].[HighCommandId], [s1].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -LEFT JOIN ( - SELECT [f0].[Id], [l2].[CommanderName] - FROM [Factions] AS [f0] - INNER JOIN [LocustHordes] AS [l2] ON [f0].[Id] = [l2].[Id] -) AS [s0] ON [s].[Name] = [s0].[CommanderName] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [l3].[Name], [l3].[LocustHordeId], [l3].[ThreatLevel], [l3].[ThreatLevelByte], [l3].[ThreatLevelNullableByte], [l4].[DefeatedByNickname], [l4].[DefeatedBySquadId], [l4].[HighCommandId], CASE - WHEN [l4].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator] - FROM [LocustLeaders] AS [l3] - LEFT JOIN [LocustCommanders] AS [l4] ON [l3].[Name] = [l4].[Name] -) AS [s1] ON [s0].[Id] = [s1].[LocustHordeId] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Id], [s].[Name], [s0].[Id] + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 7 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 42 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task Project_collection_navigation_with_inheritance2(bool async) + public override async Task Correlated_collections_nested_mixed_streaming_with_buffer1(bool async) { - await base.Project_collection_navigation_with_inheritance2(async); + await base.Correlated_collections_nested_mixed_streaming_with_buffer1(async); AssertSql( """ -SELECT [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] -) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 2 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 3 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task Project_collection_navigation_with_inheritance3(bool async) + public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) { - await base.Project_collection_navigation_with_inheritance3(async); + await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); AssertSql( """ -SELECT [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] +SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] -) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] -WHERE [l].[Id] IS NOT NULL -ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] + SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] + FROM [SquadMissions] AS [s0] + INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] + LEFT JOIN ( + SELECT [s1].[SquadId], [s1].[MissionId] + FROM [SquadMissions] AS [s1] + WHERE [s1].[SquadId] < 7 + ) AS [s2] ON [m].[Id] = [s2].[MissionId] + WHERE [s0].[MissionId] < 42 +) AS [s3] ON [s].[Id] = [s3].[SquadId] +ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] """); } - public override async Task Include_reference_on_derived_type_using_string(bool async) + public override async Task Correlated_collections_nested_with_custom_ordering(bool async) { - await base.Include_reference_on_derived_type_using_string(async); + await base.Correlated_collections_nested_with_custom_ordering(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g0].[Rank], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] + WHERE [g0].[FullName] <> N'Foo' +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[HasSoulPatch] DESC, [g].[Nickname], [g].[SquadId], [s].[Rank], [s].[Nickname], [s].[SquadId], [s].[IsAutomatic] """); } - public override async Task Include_reference_on_derived_type_using_string_nested1(bool async) + public override async Task Correlated_collections_same_collection_projected_multiple_times(bool async) { - await base.Include_reference_on_derived_type_using_string_nested1(async); + await base.Correlated_collections_same_collection_projected_multiple_times(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s0].[Id], [s0].[Banner], [s0].[Banner5], [s0].[InternalNumber], [s0].[Name] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] -LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(1 AS bit) +) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [w1].[Id] """); } - public override async Task Include_reference_on_derived_type_using_string_nested2(bool async) + public override async Task Correlated_collections_similar_collection_projected_multiple_times(bool async) { - await base.Include_reference_on_derived_type_using_string_nested2(async); + await base.Correlated_collections_similar_collection_projected_multiple_times(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] -) AS [s0] ON ([s].[Nickname] = [s0].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s0].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s0].[LeaderSquadId] -ORDER BY [l].[Name], [s].[Nickname], [s].[SquadId], [s0].[Nickname], [s0].[SquadId] + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(0 AS bit) +) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] +ORDER BY [g].[Rank], [g].[Nickname], [g].[SquadId], [w1].[OwnerFullName], [w1].[Id], [w2].[IsAutomatic] """); } - public override async Task Include_reference_on_derived_type_using_lambda(bool async) + public override async Task Correlated_collections_different_collections_projected(bool async) { - await base.Include_reference_on_derived_type_using_lambda(async); + await base.Correlated_collections_different_collections_projected(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[IsAutomatic], [w0].[Id], [s].[Nickname], [s].[Rank], [s].[SquadId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] + SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[Rank], [g0].[SquadId], [g0].[FullName], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [w0].[Id], [s].[FullName], [s].[Nickname] """); } - public override async Task Include_reference_on_derived_type_using_lambda_with_soft_cast(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(bool async) { - await base.Include_reference_on_derived_type_using_lambda_with_soft_cast(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] +SELECT [g].[FullName] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note] """); } - public override async Task Include_reference_on_derived_type_using_lambda_with_tracking(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) { - await base.Include_reference_on_derived_type_using_lambda_with_tracking(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Nickname], [s1].[SquadId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] -"""); - } - - public override async Task Include_collection_on_derived_type_using_string(bool async) - { - await base.Include_collection_on_derived_type_using_string(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s0].[Nickname], [s0].[SquadId] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] + FROM [Gears] AS [g2] + ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] +) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] +WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( + SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[IsAutomatic], [s1].[Nickname] DESC, [s1].[Id] """); } - public override async Task Include_collection_on_derived_type_using_lambda(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( + bool async) { - await base.Include_collection_on_derived_type_using_lambda(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Nickname], [s1].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s0].[Nickname], [s0].[SquadId] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] + FROM [Gears] AS [g2] + ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] +) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] +WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( + SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[IsAutomatic], [s1].[Nickname] DESC, [s1].[Id] """); } - public override async Task Include_collection_on_derived_type_using_lambda_with_soft_cast(bool async) + public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( + bool async) { - await base.Include_collection_on_derived_type_using_lambda_with_soft_cast(async); + await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Nickname], [s1].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s0].[Nickname], [s0].[SquadId], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [s0].[FullName] IS NOT NULL AND [s0].[FullName] = [w0].[OwnerFullName]) AS [c] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] + FROM [Gears] AS [g2] + ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] +) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] +WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( + SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id] DESC, [s1].[c], [s1].[Nickname] """); } - public override async Task Include_base_navigation_on_derived_entity(bool async) + public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) { - await base.Include_base_navigation_on_derived_entity(async); + await base.Correlated_collections_multiple_nested_complex_collections(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s5].[FullName], [s5].[Nickname], [s5].[SquadId], [s5].[Id], [s5].[Nickname0], [s5].[SquadId0], [s5].[Id0], [s5].[Name], [s5].[IsAutomatic], [s5].[Id1], [s5].[Nickname00], [s5].[HasSoulPatch], [s5].[SquadId00], [s6].[Id], [s6].[AmmunitionType], [s6].[IsAutomatic], [s6].[Name], [s6].[OwnerFullName], [s6].[SynergyWithId], [s6].[Nickname], [s6].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id] -"""); - } - - public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) - { - await base.ThenInclude_collection_on_derived_after_base_reference(async); - - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) - { - await base.ThenInclude_collection_on_derived_after_derived_reference(async); - - AssertSql( - """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] + SELECT [g2].[FullName], [g2].[Nickname], [g2].[SquadId], [s4].[Id], [s4].[Nickname] AS [Nickname0], [s4].[SquadId] AS [SquadId0], [s4].[Id0], [s4].[Name], [s4].[IsAutomatic], [s4].[Id1], [s4].[Nickname0] AS [Nickname00], [s4].[HasSoulPatch], [s4].[SquadId0] AS [SquadId00], [g2].[Rank], [s4].[IsAutomatic0], [g2].[LeaderNickname], [g2].[LeaderSquadId] + FROM [Gears] AS [g2] + LEFT JOIN ( + SELECT [w].[Id], [s0].[Nickname], [s0].[SquadId], [s1].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [s3].[Nickname] AS [Nickname0], [s3].[HasSoulPatch], [s3].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g3].[Nickname], [g3].[SquadId], [g3].[FullName] + FROM [Gears] AS [g3] + ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] + LEFT JOIN [Squads] AS [s1] ON [s0].[SquadId] = [s1].[Id] + LEFT JOIN [Weapons] AS [w0] ON [s0].[FullName] = [w0].[OwnerFullName] + LEFT JOIN ( + SELECT [g4].[Nickname], [g4].[HasSoulPatch], [g4].[SquadId] + FROM [Gears] AS [g4] + ) AS [s3] ON [s1].[Id] = [s3].[SquadId] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [s4] ON [g2].[FullName] = [s4].[OwnerFullName] + WHERE [g2].[FullName] <> N'Foo' +) AS [s5] ON [g].[Nickname] = [s5].[LeaderNickname] AND [g].[SquadId] = [s5].[LeaderSquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [s2].[Nickname], [s2].[SquadId] + FROM [Weapons] AS [w1] + LEFT JOIN ( + SELECT [g5].[Nickname], [g5].[SquadId], [g5].[FullName] + FROM [Gears] AS [g5] + ) AS [s2] ON [w1].[OwnerFullName] = [s2].[FullName] +) AS [s6] ON [s].[FullName] = [s6].[OwnerFullName] +WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( + SELECT 1 FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] -ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) +ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s5].[Rank], [s5].[Nickname], [s5].[SquadId], [s5].[IsAutomatic0], [s5].[Id], [s5].[Nickname0], [s5].[SquadId0], [s5].[Id0], [s5].[Id1], [s5].[Nickname00], [s5].[SquadId00], [s6].[IsAutomatic], [s6].[Nickname] DESC, [s6].[Id] """); } - public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) + public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) { - await base.ThenInclude_collection_on_derived_after_derived_collection(async); + await base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Nickname0], [s0].[SquadId0], [s0].[AssignedCityName0], [s0].[CityOfBirthName0], [s0].[FullName0], [s0].[HasSoulPatch0], [s0].[LeaderNickname0], [s0].[LeaderSquadId0], [s0].[Rank0], [s0].[Discriminator0] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[ReportName], [s].[OfficerName], [s].[Nickname], [s].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [s].[Nickname] AS [Nickname0], [s].[SquadId] AS [SquadId0], [s].[AssignedCityName] AS [AssignedCityName0], [s].[CityOfBirthName] AS [CityOfBirthName0], [s].[FullName] AS [FullName0], [s].[HasSoulPatch] AS [HasSoulPatch0], [s].[LeaderNickname] AS [LeaderNickname0], [s].[LeaderSquadId] AS [LeaderSquadId0], [s].[Rank] AS [Rank0], [s].[Discriminator] AS [Discriminator0] +OUTER APPLY ( + SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], CASE - WHEN [o1].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g1] - LEFT JOIN [Officers] AS [o1] ON [g1].[Nickname] = [o1].[Nickname] AND [g1].[SquadId] = [o1].[SquadId] - ) AS [s] ON [g0].[Nickname] = [s].[LeaderNickname] AND [g0].[SquadId] = [s].[LeaderSquadId] -) AS [s0] ON [g].[Nickname] = [s0].[LeaderNickname] AND [g].[SquadId] = [s0].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Nickname], [s0].[SquadId], [s0].[Nickname0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +) AS [s] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task ThenInclude_reference_on_derived_after_derived_collection(bool async) + public override async Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) { - await base.ThenInclude_reference_on_derived_after_derived_collection(async); + await base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator], [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator0] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE - WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] AS [Discriminator0] - FROM [LocustLeaders] AS [l0] - LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] - LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] - ) AS [s] ON [l1].[DefeatedByNickname] = [s].[Nickname] AND [l1].[DefeatedBySquadId] = [s].[SquadId] -) AS [s0] ON [f].[Id] = [s0].[LocustHordeId] -ORDER BY [f].[Id], [s0].[Name], [s0].[Nickname] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[ReportName], [s].[Nickname], [s].[SquadId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +OUTER APPLY ( + SELECT [g0].[FullName] AS [ReportName], [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g].[FullName] <> N'Foo' +) AS [s] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Multiple_derived_included_on_one_method(bool async) + public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) { - await base.Multiple_derived_included_on_one_method(async); + await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s0] ON [s].[DefeatedByNickname] = [s0].[Nickname] AND [s].[DefeatedBySquadId] = [s0].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s1] ON ([s0].[Nickname] = [s1].[LeaderNickname] OR ([s0].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s0].[SquadId] = [s1].[LeaderSquadId] -ORDER BY [f].[Id], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s1].[Nickname] -"""); - } - - public override async Task Include_on_derived_multi_level(bool async) - { - await base.Include_on_derived_multi_level(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Id], [s1].[Banner], [s1].[Banner5], [s1].[InternalNumber], [s1].[Name], [s1].[SquadId0], [s1].[MissionId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[SquadId] AS [SquadId0], [s0].[MissionId] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - INNER JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] - LEFT JOIN [SquadMissions] AS [s0] ON [s].[Id] = [s0].[SquadId] -) AS [s1] ON [g].[Nickname] = [s1].[LeaderNickname] AND [g].[SquadId] = [s1].[LeaderSquadId] -ORDER BY [g].[Nickname], [g].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[SquadId0] -"""); - } - - public override async Task Projecting_nullable_bool_in_conditional_works(bool async) - { - await base.Projecting_nullable_bool_in_conditional_works(async); - - AssertSql( - """ -SELECT CASE - WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN [s].[HasSoulPatch] - ELSE CAST(0 AS bit) -END AS [Prop] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -"""); - } - - public override async Task ToString_enum_property_projection(bool async) - { - await base.ToString_enum_property_projection(async); - - AssertSql( - """ -SELECT CASE [g].[Rank] - WHEN 0 THEN N'None' - WHEN 1 THEN N'Private' - WHEN 2 THEN N'Corporal' - WHEN 4 THEN N'Sergeant' - WHEN 8 THEN N'Lieutenant' - WHEN 16 THEN N'Captain' - WHEN 32 THEN N'Major' - WHEN 64 THEN N'Colonel' - WHEN 128 THEN N'General' - ELSE CAST([g].[Rank] AS nvarchar(max)) -END -FROM [Gears] AS [g] -"""); - } - - public override async Task ToString_nullable_enum_property_projection(bool async) - { - await base.ToString_nullable_enum_property_projection(async); - - AssertSql( - """ -SELECT CASE [w].[AmmunitionType] - WHEN 1 THEN N'Cartridge' - WHEN 2 THEN N'Shell' - ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') -END -FROM [Weapons] AS [w] -"""); - } - - public override async Task ToString_enum_contains(bool async) - { - await base.ToString_enum_contains(async); - - AssertSql( - """ -SELECT [m].[CodeName] -FROM [Missions] AS [m] -WHERE CAST([m].[Difficulty] AS nvarchar(max)) LIKE N'%Med%' -"""); - } - - public override async Task ToString_nullable_enum_contains(bool async) - { - await base.ToString_nullable_enum_contains(async); - - AssertSql( - """ -SELECT [w].[Name] -FROM [Weapons] AS [w] -WHERE CASE [w].[AmmunitionType] - WHEN 1 THEN N'Cartridge' - WHEN 2 THEN N'Shell' - ELSE COALESCE(CAST([w].[AmmunitionType] AS nvarchar(max)), N'') -END LIKE N'%Cart%' -"""); - } - - public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) - { - await base.Correlated_collections_naked_navigation_with_ToList(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool async) - { - await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(async); - - AssertSql( - """ -SELECT ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) -FROM [Gears] AS [g] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname] -"""); - } - - public override async Task Correlated_collections_naked_navigation_with_ToArray(bool async) - { - await base.Correlated_collections_naked_navigation_with_ToArray(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection(bool async) - { - await base.Correlated_collections_basic_projection(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection_explicit_to_list(bool async) - { - await base.Correlated_collections_basic_projection_explicit_to_list(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection_explicit_to_array(bool async) - { - await base.Correlated_collections_basic_projection_explicit_to_array(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projection_ordered(bool async) - { - await base.Correlated_collections_basic_projection_ordered(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId], [w0].[Name] DESC -"""); - } - - public override async Task Correlated_collections_basic_projection_composite_key(bool async) - { - await base.Correlated_collections_basic_projection_composite_key(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[FullName], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[FullName], [g0].[SquadId], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL AND [g].[Nickname] <> N'Foo' -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] -"""); - } - - public override async Task Correlated_collections_basic_projecting_single_property(bool async) - { - await base.Correlated_collections_basic_projecting_single_property(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[Id] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projecting_constant(bool async) - { - await base.Correlated_collections_basic_projecting_constant(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_basic_projecting_constant_bool(bool async) - { - await base.Correlated_collections_basic_projecting_constant_bool(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[c], [w0].[Id] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[Nickname], [g].[SquadId] -"""); - } - - public override async Task Correlated_collections_projection_of_collection_thru_navigation(bool async) - { - await base.Correlated_collections_projection_of_collection_thru_navigation(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId], [s1].[MissionId] -FROM [Gears] AS [g] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId] - FROM [SquadMissions] AS [s0] - WHERE [s0].[MissionId] <> 17 -) AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE [g].[Nickname] <> N'Marcus' -ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - - public override async Task Correlated_collections_project_anonymous_collection_result(bool async) - { - await base.Correlated_collections_project_anonymous_collection_result(async); - - AssertSql( - """ -SELECT [s].[Name], [s].[Id], [s0].[FullName], [s0].[Rank], [s0].[Nickname], [s0].[SquadId] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [g].[FullName], [g].[Rank], [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -WHERE [s].[Id] < 20 -ORDER BY [s].[Id], [s0].[Nickname] -"""); - } - - public override async Task Correlated_collections_nested(bool async) - { - await base.Correlated_collections_nested(async); - - AssertSql( - """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 7 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 42 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] -"""); - } - - public override async Task Correlated_collections_nested_mixed_streaming_with_buffer1(bool async) - { - await base.Correlated_collections_nested_mixed_streaming_with_buffer1(async); - - AssertSql( - """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 2 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 3 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] -"""); - } - - public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) - { - await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); - - AssertSql( - """ -SELECT [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0], [s3].[MissionId0] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [s2].[SquadId] AS [SquadId0], [s2].[MissionId] AS [MissionId0] - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - LEFT JOIN ( - SELECT [s1].[SquadId], [s1].[MissionId] - FROM [SquadMissions] AS [s1] - WHERE [s1].[SquadId] < 7 - ) AS [s2] ON [m].[Id] = [s2].[MissionId] - WHERE [s0].[MissionId] < 42 -) AS [s3] ON [s].[Id] = [s3].[SquadId] -ORDER BY [s].[Id], [s3].[SquadId], [s3].[MissionId], [s3].[Id], [s3].[SquadId0] -"""); - } - - public override async Task Correlated_collections_nested_with_custom_ordering(bool async) - { - await base.Correlated_collections_nested_with_custom_ordering(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g0].[Rank], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] - WHERE [g0].[FullName] <> N'Foo' -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[HasSoulPatch] DESC, [g].[Nickname], [g].[SquadId], [s].[Rank], [s].[Nickname], [s].[SquadId], [s].[IsAutomatic] -"""); - } - - public override async Task Correlated_collections_same_collection_projected_multiple_times(bool async) - { - await base.Correlated_collections_same_collection_projected_multiple_times(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(1 AS bit) -) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [w1].[Id] -"""); - } - - public override async Task Correlated_collections_similar_collection_projected_multiple_times(bool async) - { - await base.Correlated_collections_similar_collection_projected_multiple_times(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [w2].[Id], [w2].[AmmunitionType], [w2].[IsAutomatic], [w2].[Name], [w2].[OwnerFullName], [w2].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(0 AS bit) -) AS [w2] ON [g].[FullName] = [w2].[OwnerFullName] -ORDER BY [g].[Rank], [g].[Nickname], [g].[SquadId], [w1].[OwnerFullName], [w1].[Id], [w2].[IsAutomatic] -"""); - } - - public override async Task Correlated_collections_different_collections_projected(bool async) - { - await base.Correlated_collections_different_collections_projected(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [w0].[Name], [w0].[IsAutomatic], [w0].[Id], [s].[Nickname], [s].[Rank], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[Rank], [g0].[SquadId], [g0].[FullName], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [w0].[Id], [s].[FullName], [s].[Nickname] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); - - AssertSql( - """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Nickname], [s1].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s0].[Nickname], [s0].[SquadId] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] - FROM [Gears] AS [g2] - ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] -) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] -WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[IsAutomatic], [s1].[Nickname] DESC, [s1].[Id] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( - bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Nickname], [s1].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s0].[Nickname], [s0].[SquadId] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] - FROM [Gears] AS [g2] - ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] -) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] -WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[IsAutomatic], [s1].[Nickname] DESC, [s1].[Id] -"""); - } - - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( - bool async) - { - await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Nickname], [s1].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [s0].[Nickname], [s0].[SquadId], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [s0].[FullName] IS NOT NULL AND [s0].[FullName] = [w0].[OwnerFullName]) AS [c] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g2].[Nickname], [g2].[SquadId], [g2].[FullName] - FROM [Gears] AS [g2] - ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] -) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] -WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id] DESC, [s1].[c], [s1].[Nickname] -"""); - } - - public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) - { - await base.Correlated_collections_multiple_nested_complex_collections(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s5].[FullName], [s5].[Nickname], [s5].[SquadId], [s5].[Id], [s5].[Nickname0], [s5].[SquadId0], [s5].[Id0], [s5].[Name], [s5].[IsAutomatic], [s5].[Id1], [s5].[Nickname00], [s5].[HasSoulPatch], [s5].[SquadId00], [s6].[Id], [s6].[AmmunitionType], [s6].[IsAutomatic], [s6].[Name], [s6].[OwnerFullName], [s6].[SynergyWithId], [s6].[Nickname], [s6].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [g2].[FullName], [g2].[Nickname], [g2].[SquadId], [s4].[Id], [s4].[Nickname] AS [Nickname0], [s4].[SquadId] AS [SquadId0], [s4].[Id0], [s4].[Name], [s4].[IsAutomatic], [s4].[Id1], [s4].[Nickname0] AS [Nickname00], [s4].[HasSoulPatch], [s4].[SquadId0] AS [SquadId00], [g2].[Rank], [s4].[IsAutomatic0], [g2].[LeaderNickname], [g2].[LeaderSquadId] - FROM [Gears] AS [g2] - LEFT JOIN ( - SELECT [w].[Id], [s0].[Nickname], [s0].[SquadId], [s1].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [s3].[Nickname] AS [Nickname0], [s3].[HasSoulPatch], [s3].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g3].[Nickname], [g3].[SquadId], [g3].[FullName] - FROM [Gears] AS [g3] - ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] - LEFT JOIN [Squads] AS [s1] ON [s0].[SquadId] = [s1].[Id] - LEFT JOIN [Weapons] AS [w0] ON [s0].[FullName] = [w0].[OwnerFullName] - LEFT JOIN ( - SELECT [g4].[Nickname], [g4].[HasSoulPatch], [g4].[SquadId] - FROM [Gears] AS [g4] - ) AS [s3] ON [s1].[Id] = [s3].[SquadId] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [s4] ON [g2].[FullName] = [s4].[OwnerFullName] - WHERE [g2].[FullName] <> N'Foo' -) AS [s5] ON [g].[Nickname] = [s5].[LeaderNickname] AND [g].[SquadId] = [s5].[LeaderSquadId] -LEFT JOIN ( - SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [s2].[Nickname], [s2].[SquadId] - FROM [Weapons] AS [w1] - LEFT JOIN ( - SELECT [g5].[Nickname], [g5].[SquadId], [g5].[FullName] - FROM [Gears] AS [g5] - ) AS [s2] ON [w1].[OwnerFullName] = [s2].[FullName] -) AS [s6] ON [s].[FullName] = [s6].[OwnerFullName] -WHERE [o].[Nickname] IS NOT NULL AND EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId]) -ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [s].[Nickname], [s].[SquadId], [s5].[Rank], [s5].[Nickname], [s5].[SquadId], [s5].[IsAutomatic0], [s5].[Id], [s5].[Nickname0], [s5].[SquadId0], [s5].[Id0], [s5].[Id1], [s5].[Nickname00], [s5].[SquadId00], [s6].[IsAutomatic], [s6].[Nickname] DESC, [s6].[Id] -"""); - } - - public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) - { - await base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[ReportName], [s].[OfficerName], [s].[Nickname], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -OUTER APPLY ( - SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -) AS [s] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] -"""); - } - - public override async Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) - { - await base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[ReportName], [s].[Nickname], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -OUTER APPLY ( - SELECT [g0].[FullName] AS [ReportName], [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g].[FullName] <> N'Foo' -) AS [s] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] -"""); - } - - public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) - { - await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - OUTER APPLY ( - SELECT [w].[Name], [g0].[Nickname], [w].[Id] - FROM [Weapons] AS [w] - WHERE [g0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) - ) AS [w0] - WHERE [g0].[FullName] <> N'Foo' -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) - { - await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -OUTER APPLY ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL - ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[FullName] <> N'Foo' -) AS [s] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_on_select_many(bool async) - { - await base.Correlated_collections_on_select_many(async); - - AssertSql( - """ -SELECT [g].[Nickname], [s].[Name], [g].[SquadId], [s].[Id], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] -FROM [Gears] AS [g] -CROSS JOIN [Squads] AS [s] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] - WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) -) AS [s0] ON [s].[Id] = [s0].[SquadId] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) -ORDER BY [g].[Nickname], [s].[Id] DESC, [g].[SquadId], [w0].[Id], [s0].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Skip(bool async) - { - await base.Correlated_collections_with_Skip(async); - - AssertSql( - """ -SELECT [s].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] - FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - ) AS [s0] - WHERE 1 < [s0].[row] -) AS [s1] ON [s].[Id] = [s1].[SquadId] -ORDER BY [s].[Name], [s].[Id], [s1].[SquadId], [s1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Take(bool async) - { - await base.Correlated_collections_with_Take(async); - - AssertSql( - """ -SELECT [s].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] - FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - ) AS [s0] - WHERE [s0].[row] <= 2 -) AS [s1] ON [s].[Id] = [s1].[SquadId] -ORDER BY [s].[Name], [s].[Id], [s1].[SquadId], [s1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_Distinct(bool async) - { - await base.Correlated_collections_with_Distinct(async); - - AssertSql( - """ -SELECT [s].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Squads] AS [s] -OUTER APPLY ( - SELECT DISTINCT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] - FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [s].[Id] = [g].[SquadId] - ORDER BY [g].[Nickname] - OFFSET 0 ROWS - ) AS [s0] -) AS [s1] -ORDER BY [s].[Name], [s].[Id], [s1].[Nickname] -"""); - } - - public override async Task Correlated_collections_with_FirstOrDefault(bool async) - { - await base.Correlated_collections_with_FirstOrDefault(async); - - AssertSql( - """ -SELECT ( - SELECT TOP(1) [g].[FullName] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] - ORDER BY [g].[Nickname]) -FROM [Squads] AS [s] -ORDER BY [s].[Name] -"""); - } - - public override async Task Correlated_collections_on_left_join_with_predicate(bool async) - { - await base.Correlated_collections_on_left_join_with_predicate(async); - - AssertSql( - """ -SELECT [s].[Nickname], [t].[Id], [s].[SquadId], [w].[Name], [w].[Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -WHERE [s].[HasSoulPatch] = CAST(0 AS bit) -ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_on_left_join_with_null_value(bool async) - { - await base.Correlated_collections_on_left_join_with_null_value(async); - - AssertSql( - """ -SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [w].[Name], [w].[Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collections_left_join_with_self_reference(bool async) - { - await base.Correlated_collections_left_join_with_self_reference(async); - - AssertSql( - """ -SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[FullName], [s0].[Nickname], [s0].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE [o].[Nickname] IS NOT NULL -) AS [s] ON [t].[GearNickName] = [s].[Nickname] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] -) AS [s0] ON ([s].[Nickname] = [s0].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s0].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s0].[LeaderSquadId] -ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Nickname] -"""); - } - - public override async Task Correlated_collections_deeply_nested_left_join(bool async) - { - await base.Correlated_collections_deeply_nested_left_join(async); - - AssertSql( - """ -SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] -LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) - ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] - WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) -) AS [s1] ON [s0].[Id] = [s1].[SquadId] -ORDER BY [t].[Note], [s].[Nickname] DESC, [t].[Id], [s].[SquadId], [s0].[Id], [s1].[Nickname], [s1].[SquadId] -"""); - } - - public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) - { - await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); - - AssertSql( - """ -SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Rank] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] -) AS [s] ON [w].[OwnerFullName] = [s].[FullName] -LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g0].[Rank], [g0].[FullName] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w0] - WHERE [w0].[IsAutomatic] = CAST(0 AS bit) - ) AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] -) AS [s1] ON [s0].[Id] = [s1].[SquadId] -ORDER BY [w].[Name], [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id], [s1].[FullName] DESC, [s1].[Nickname], [s1].[SquadId], [s1].[Id] -"""); - } - - public override async Task Correlated_collections_complex_scenario1(bool async) - { - await base.Correlated_collections_complex_scenario1(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0], [s2].[HasSoulPatch], [s2].[SquadId0] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] - LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId] - FROM [Gears] AS [g1] - ) AS [s1] ON [s0].[Id] = [s1].[SquadId] -) AS [s2] ON [g].[FullName] = [s2].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0] -"""); - } - - public override async Task Correlated_collections_complex_scenario2(bool async) - { - await base.Correlated_collections_complex_scenario2(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s3].[FullName], [s3].[Nickname], [s3].[SquadId], [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00], [s3].[HasSoulPatch], [s3].[SquadId00] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s2].[Id], [s2].[Nickname] AS [Nickname0], [s2].[SquadId] AS [SquadId0], [s2].[Id0], [s2].[Nickname0] AS [Nickname00], [s2].[HasSoulPatch], [s2].[SquadId0] AS [SquadId00], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] - ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] - LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] - LEFT JOIN ( - SELECT [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId] - FROM [Gears] AS [g2] - ) AS [s1] ON [s0].[Id] = [s1].[SquadId] - ) AS [s2] ON [g0].[FullName] = [s2].[OwnerFullName] -) AS [s3] ON [g].[Nickname] = [s3].[LeaderNickname] AND [g].[SquadId] = [s3].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s3].[Nickname], [s3].[SquadId], [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00] -"""); - } - - public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) - { - await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0], [s2].[HasSoulPatch], [s2].[SquadId0] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] - LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId] - FROM [Gears] AS [g1] - ) AS [s1] ON [s0].[Id] = [s1].[SquadId] -) AS [s2] ON [g].[FullName] = [s2].[OwnerFullName] -ORDER BY [g].[FullName], [g].[Nickname] DESC, [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0] -"""); - } - - public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) - { - await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); - - AssertSql( - """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s3].[FullName], [s3].[Nickname], [s3].[SquadId], [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00], [s3].[HasSoulPatch], [s3].[SquadId00] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s2].[Id], [s2].[Nickname] AS [Nickname0], [s2].[SquadId] AS [SquadId0], [s2].[Id0], [s2].[Nickname0] AS [Nickname00], [s2].[HasSoulPatch], [s2].[SquadId0] AS [SquadId00], [g0].[HasSoulPatch] AS [HasSoulPatch0], [s2].[IsAutomatic], [s2].[Name], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN ( - SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] - FROM [Gears] AS [g1] - ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] - LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] - LEFT JOIN ( - SELECT [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId] - FROM [Gears] AS [g2] - ) AS [s1] ON [s0].[Id] = [s1].[SquadId] - ) AS [s2] ON [g0].[FullName] = [s2].[OwnerFullName] -) AS [s3] ON [g].[Nickname] = [s3].[LeaderNickname] AND [g].[SquadId] = [s3].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[HasSoulPatch], [g].[LeaderNickname], [g].[FullName], [g].[Nickname], [g].[SquadId], [s3].[FullName], [s3].[HasSoulPatch0] DESC, [s3].[Nickname], [s3].[SquadId], [s3].[IsAutomatic], [s3].[Name] DESC, [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00] -"""); - } - - public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) - { - await base.Correlated_collection_with_top_level_FirstOrDefault(async); - - AssertSql( - """ -SELECT [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[Nickname] -) AS [s] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collection_with_top_level_Count(bool async) - { - await base.Correlated_collection_with_top_level_Count(async); - - AssertSql( - """ -SELECT COUNT(*) -FROM [Gears] AS [g] -"""); - } - - public override async Task Correlated_collection_with_top_level_Last_with_orderby_on_outer(bool async) - { - await base.Correlated_collection_with_top_level_Last_with_orderby_on_outer(async); - - AssertSql( - """ -SELECT [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[FullName] -) AS [s] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [s].[FullName], [s].[Nickname], [s].[SquadId] -"""); - } - - public override async Task Correlated_collection_with_top_level_Last_with_order_by_on_inner(bool async) - { - await base.Correlated_collection_with_top_level_Last_with_order_by_on_inner(async); - - AssertSql( - """ -SELECT [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[FullName] DESC -) AS [s] -LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [s].[FullName] DESC, [s].[Nickname], [s].[SquadId], [w].[Name] -"""); - } - - public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) - { - await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); - - AssertSql( - """ -SELECT [s].[Id], [s].[CapitalName], [s].[Name], [s].[ServerAddress], [s].[CommanderName], [s].[Eradicated], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -INNER JOIN ( - SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l0].[CommanderName], [l0].[Eradicated], CASE - WHEN [l0].[Id] IS NOT NULL THEN N'LocustHorde' - END AS [Discriminator] - FROM [Factions] AS [f] - LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] - WHERE [l0].[Id] IS NOT NULL AND [f].[Name] = N'Swarm' -) AS [s] ON [l].[Name] = [s].[CommanderName] -WHERE [s].[Eradicated] = CAST(0 AS bit) OR [s].[Eradicated] IS NULL -"""); - } - - public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) - { - await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); - - AssertSql( - """ -SELECT [s].[Id], [s].[CapitalName], [s].[Name], [s].[ServerAddress], [s].[CommanderName], [s].[Eradicated], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN ( - SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l0].[CommanderName], [l0].[Eradicated], CASE - WHEN [l0].[Id] IS NOT NULL THEN N'LocustHorde' - END AS [Discriminator] - FROM [Factions] AS [f] - LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] - WHERE [l0].[Id] IS NOT NULL AND [f].[Name] = N'Swarm' -) AS [s] ON [l].[Name] = [s].[CommanderName] -WHERE [s].[Eradicated] = CAST(0 AS bit) OR [s].[Eradicated] IS NULL -"""); - } - - public override async Task Include_on_derived_type_with_order_by_and_paging(bool async) - { - await base.Include_on_derived_type_with_order_by_and_paging(async); - - AssertSql( - """ -@p='10' - -SELECT [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator0] AS [Discriminator], [s0].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM ( - SELECT TOP(@p) [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] AS [Discriminator0], [t].[Id], [t].[Note] - FROM [LocustLeaders] AS [l] - LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] - LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] - ) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] - LEFT JOIN [Tags] AS [t] ON ([s].[Nickname] = [t].[GearNickName] OR ([s].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([s].[SquadId] = [t].[GearSquadId] OR ([s].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) - ORDER BY [t].[Note] -) AS [s0] -LEFT JOIN [Weapons] AS [w] ON [s0].[FullName] = [w].[OwnerFullName] -ORDER BY [s0].[Note], [s0].[Name], [s0].[Nickname], [s0].[SquadId], [s0].[Id] -"""); - } - - public override async Task Select_required_navigation_on_derived_type(bool async) - { - await base.Select_required_navigation_on_derived_type(async); - - AssertSql( - """ -SELECT [l1].[Name] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -LEFT JOIN [LocustHighCommands] AS [l1] ON [l0].[HighCommandId] = [l1].[Id] -"""); - } - - public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) - { - await base.Select_required_navigation_on_the_same_type_with_cast(async); - - AssertSql( - """ -SELECT [c].[Name] -FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -"""); - } - - public override async Task Where_required_navigation_on_derived_type(bool async) - { - await base.Where_required_navigation_on_derived_type(async); - - AssertSql( - """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -LEFT JOIN [LocustHighCommands] AS [l1] ON [l0].[HighCommandId] = [l1].[Id] -WHERE [l1].[IsOperational] = CAST(1 AS bit) -"""); - } - - public override async Task Outer_parameter_in_join_key(bool async) - { - await base.Outer_parameter_in_join_key(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [s0].[Note], [s0].[Id], [s0].[Nickname], [s0].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] - FROM [Tags] AS [t] - INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - ) AS [s] ON [g].[FullName] = [s].[FullName] -) AS [s0] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname] -"""); - } - - public override async Task Outer_parameter_in_join_key_inner_and_outer(bool async) - { - await base.Outer_parameter_in_join_key_inner_and_outer(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [s0].[Note], [s0].[Id], [s0].[Nickname], [s0].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] - FROM [Tags] AS [t] - INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - ) AS [s] ON [g].[FullName] = [g].[Nickname] -) AS [s0] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname] -"""); - } - - public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) - { - await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); - - AssertSql( - """ -SELECT [g].[Nickname], [g].[SquadId], [s0].[Note], [s0].[Id], [s0].[Nickname], [s0].[SquadId] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -OUTER APPLY ( - SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - ) AS [s] ON [g].[FullName] = [s].[FullName] -) AS [s0] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname] -"""); - } - - public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) - { - await base.Negated_bool_ternary_inside_anonymous_type_in_projection(async); - - AssertSql( - """ -SELECT ~CASE - WHEN [s].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) - ELSE COALESCE([s].[HasSoulPatch], CAST(1 AS bit)) -END AS [c] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -"""); - } - - public override async Task Order_by_entity_qsre(bool async) - { - await base.Order_by_entity_qsre(async); - - AssertSql( - """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -ORDER BY [c].[Name], [g].[Nickname] DESC -"""); - } - - public override async Task Order_by_entity_qsre_with_inheritance(bool async) - { - await base.Order_by_entity_qsre_with_inheritance(async); - - AssertSql( - """ -SELECT [l].[Name] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -INNER JOIN [LocustHighCommands] AS [l1] ON [l0].[HighCommandId] = [l1].[Id] -WHERE [l0].[Name] IS NOT NULL -ORDER BY [l1].[Id], [l].[Name] -"""); - } - - public override async Task Order_by_entity_qsre_composite_key(bool async) - { - await base.Order_by_entity_qsre_composite_key(async); - - AssertSql( - """ -SELECT [w].[Name] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] -) AS [s] ON [w].[OwnerFullName] = [s].[FullName] -ORDER BY [s].[Nickname], [s].[SquadId], [w].[Id] -"""); - } - - public override async Task Order_by_entity_qsre_with_other_orderbys(bool async) - { - await base.Order_by_entity_qsre_with_other_orderbys(async); - - AssertSql( - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] -) AS [s] ON [w].[OwnerFullName] = [s].[FullName] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w].[IsAutomatic], [s].[Nickname] DESC, [s].[SquadId] DESC, [w0].[Id], [w].[Name] -"""); - } - - public override async Task Join_on_entity_qsre_keys(bool async) - { - await base.Join_on_entity_qsre_keys(async); - - AssertSql( - """ -SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] -FROM [Weapons] AS [w] -INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id] -"""); - } - - public override async Task Join_on_entity_qsre_keys_composite_key(bool async) - { - await base.Join_on_entity_qsre_keys_composite_key(async); - - AssertSql( - """ -SELECT [g].[FullName] AS [GearName1], [s].[FullName] AS [GearName2] -FROM [Gears] AS [g] -INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] -) AS [s] ON [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inheritance(bool async) - { - await base.Join_on_entity_qsre_keys_inheritance(async); - - AssertSql( - """ -SELECT [g].[FullName] AS [GearName], [s].[FullName] AS [OfficerName] -FROM [Gears] AS [g] -INNER JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] - WHERE [o].[Nickname] IS NOT NULL -) AS [s] ON [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] -"""); - } - - public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_outer_key_is_navigation(async); - - AssertSql( - """ -SELECT [w].[Name] AS [Name1], [w1].[Name] AS [Name2] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -INNER JOIN [Weapons] AS [w1] ON [w0].[Id] = [w1].[Id] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_inner_key_is_navigation(async); - - AssertSql( - """ -SELECT [c].[Name] AS [CityName], [s].[Nickname] AS [GearNickname] -FROM [Cities] AS [c] -INNER JOIN ( - SELECT [g].[Nickname], [c0].[Name] - FROM [Gears] AS [g] - LEFT JOIN [Cities] AS [c0] ON [g].[AssignedCityName] = [c0].[Name] -) AS [s] ON [c].[Name] = [s].[Name] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) - { - await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); - - AssertSql( - """ -SELECT [g].[Nickname], [s0].[Note] -FROM [Gears] AS [g] -INNER JOIN ( - SELECT [t].[Note], [s].[Nickname], [s].[SquadId] - FROM [Tags] AS [t] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] - WHERE [t].[Note] IN (N'Cole''s Tag', N'Dom''s Tag') -) AS [s0] ON [g].[Nickname] = [s0].[Nickname] AND [g].[SquadId] = [s0].[SquadId] -"""); - } - - public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) - { - await base.Join_on_entity_qsre_keys_inner_key_is_nested_navigation(async); - - AssertSql( - """ -SELECT [s].[Name] AS [SquadName], [s2].[Name] AS [WeaponName] -FROM [Squads] AS [s] -INNER JOIN ( - SELECT [w].[Name], [s1].[Id] AS [Id0] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] - LEFT JOIN [Squads] AS [s1] ON [s0].[SquadId] = [s1].[Id] - WHERE [w].[IsAutomatic] = CAST(1 AS bit) -) AS [s2] ON [s].[Id] = [s2].[Id0] -"""); - } - - public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) - { - await base.GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(async); - - AssertSql( - """ -SELECT [s].[Name] AS [SquadName], [s2].[Name] AS [WeaponName] -FROM [Squads] AS [s] -LEFT JOIN ( - SELECT [w].[Name], [s1].[Id] AS [Id0] - FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] - LEFT JOIN [Squads] AS [s1] ON [s0].[SquadId] = [s1].[Id] -) AS [s2] ON [s].[Id] = [s2].[Id0] -"""); - } - - public override async Task Streaming_correlated_collection_issue_11403(bool async) - { - await base.Streaming_correlated_collection_issue_11403(async); - - AssertSql( - """ -SELECT [s].[Nickname], [s].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM ( - SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] - ORDER BY [g].[Nickname] -) AS [s] -LEFT JOIN ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = CAST(0 AS bit) -) AS [w0] ON [s].[FullName] = [w0].[OwnerFullName] -ORDER BY [s].[Nickname], [s].[SquadId], [w0].[Id] + OUTER APPLY ( + SELECT [w].[Name], [g0].[Nickname], [w].[Id] + FROM [Weapons] AS [w] + WHERE [g0].[FullName] = [w].[OwnerFullName] AND ([w].[Name] <> N'Bar' OR [w].[Name] IS NULL) + ) AS [w0] + WHERE [g0].[FullName] <> N'Foo' +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Project_one_value_type_from_empty_collection(bool async) + public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) { - await base.Project_one_value_type_from_empty_collection(async); + await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async); AssertSql( """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) [g].[SquadId] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[FullName], [s].[Nickname], [s].[SquadId], [s].[Name], [s].[Nickname0], [s].[Id] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +OUTER APPLY ( + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [w0].[Name], [w0].[Nickname] AS [Nickname0], [w0].[Id] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[Name] <> N'Bar' OR [w].[Name] IS NULL + ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] AND [g0].[FullName] <> N'Foo' +) AS [s] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId] """); } - public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) + public override async Task Correlated_collections_on_select_many(bool async) { - await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); + await base.Correlated_collections_on_select_many(async); AssertSql( """ -SELECT [s].[Name], ( - SELECT TOP(1) [g].[SquadId] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' +SELECT [g].[Nickname], [s].[Name], [g].[SquadId], [s].[Id], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] +FROM [Gears] AS [g] +CROSS JOIN [Squads] AS [s] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) OR [w].[Name] <> N'foo' OR [w].[Name] IS NULL +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] + WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) +) AS [s0] ON [s].[Id] = [s0].[SquadId] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +ORDER BY [g].[Nickname], [s].[Id] DESC, [g].[SquadId], [w0].[Id], [s0].[Nickname] """); } - public override async Task Project_one_value_type_with_client_projection_from_empty_collection(bool async) + public override async Task Correlated_collections_with_Skip(bool async) { - await base.Project_one_value_type_with_client_projection_from_empty_collection(async); + await base.Correlated_collections_with_Skip(async); AssertSql( """ -SELECT [s].[Name], [s1].[SquadId], [s1].[LeaderSquadId], [s1].[c] +SELECT [s].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] FROM [Squads] AS [s] LEFT JOIN ( - SELECT [s0].[SquadId], [s0].[LeaderSquadId], [s0].[c] + SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] FROM ( - SELECT [g].[SquadId], [g].[LeaderSquadId], 1 AS [c], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] ) AS [s0] - WHERE [s0].[row] <= 1 + WHERE 1 < [s0].[row] ) AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE [s].[Name] = N'Kilo' -"""); - } - - public override async Task Filter_on_subquery_projecting_one_value_type_from_empty_collection(bool async) - { - await base.Filter_on_subquery_projecting_one_value_type_from_empty_collection(async); - - AssertSql( - """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Kilo' AND COALESCE(( - SELECT TOP(1) [g].[SquadId] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 +ORDER BY [s].[Name], [s].[Id], [s1].[SquadId], [s1].[Nickname] """); } - public override async Task Select_subquery_projecting_single_constant_int(bool async) + public override async Task Correlated_collections_with_Take(bool async) { - await base.Select_subquery_projecting_single_constant_int(async); + await base.Correlated_collections_with_Take(async); AssertSql( """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) 42 - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] +SELECT [s].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname]) AS [row] + FROM [Gears] AS [g] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] + ) AS [s0] + WHERE [s0].[row] <= 2 +) AS [s1] ON [s].[Id] = [s1].[SquadId] +ORDER BY [s].[Name], [s].[Id], [s1].[SquadId], [s1].[Nickname] """); } - public override async Task Select_subquery_projecting_single_constant_string(bool async) + public override async Task Correlated_collections_with_Distinct(bool async) { - await base.Select_subquery_projecting_single_constant_string(async); + await base.Correlated_collections_with_Distinct(async); AssertSql( """ -SELECT [s].[Name], ( - SELECT TOP(1) N'Foo' - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] +SELECT [s].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] FROM [Squads] AS [s] +OUTER APPLY ( + SELECT DISTINCT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] + FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [s].[Id] = [g].[SquadId] + ORDER BY [g].[Nickname] + OFFSET 0 ROWS + ) AS [s0] +) AS [s1] +ORDER BY [s].[Name], [s].[Id], [s1].[Nickname] """); } - public override async Task Select_subquery_projecting_single_constant_bool(bool async) + public override async Task Correlated_collections_with_FirstOrDefault(bool async) { - await base.Select_subquery_projecting_single_constant_bool(async); + await base.Correlated_collections_with_FirstOrDefault(async); AssertSql( """ -SELECT [s].[Name], COALESCE(( - SELECT TOP(1) CAST(1 AS bit) +SELECT ( + SELECT TOP(1) [g].[FullName] FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] + WHERE [s].[Id] = [g].[SquadId] + ORDER BY [g].[Nickname]) FROM [Squads] AS [s] +ORDER BY [s].[Name] """); } - public override async Task Select_subquery_projecting_single_constant_inside_anonymous(bool async) + public override async Task Correlated_collections_on_left_join_with_predicate(bool async) { - await base.Select_subquery_projecting_single_constant_inside_anonymous(async); + await base.Correlated_collections_on_left_join_with_predicate(async); AssertSql( """ -SELECT [s].[Name], [s1].[One] -FROM [Squads] AS [s] +SELECT [s].[Nickname], [t].[Id], [s].[SquadId], [w].[Name], [w].[Id] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [s0].[One], [s0].[SquadId] - FROM ( - SELECT 1 AS [One], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [s0] - WHERE [s0].[row] <= 1 -) AS [s1] ON [s].[Id] = [s1].[SquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +WHERE [s].[HasSoulPatch] = CAST(0 AS bit) +ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId] """); } - public override async Task Select_subquery_projecting_multiple_constants_inside_anonymous(bool async) + public override async Task Correlated_collections_on_left_join_with_null_value(bool async) { - await base.Select_subquery_projecting_multiple_constants_inside_anonymous(async); + await base.Correlated_collections_on_left_join_with_null_value(async); AssertSql( """ -SELECT [s].[Name], [s1].[True1], [s1].[False1], [s1].[c] -FROM [Squads] AS [s] +SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [w].[Name], [w].[Id] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [s0].[True1], [s0].[False1], [s0].[c], [s0].[SquadId] - FROM ( - SELECT CAST(1 AS bit) AS [True1], CAST(0 AS bit) AS [False1], 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [s0] - WHERE [s0].[row] <= 1 -) AS [s1] ON [s].[Id] = [s1].[SquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] """); } - public override async Task Include_with_order_by_constant(bool async) + public override async Task Correlated_collections_left_join_with_self_reference(bool async) { - await base.Include_with_order_by_constant(async); + await base.Correlated_collections_left_join_with_self_reference(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] -FROM [Squads] AS [s] +SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[FullName], [s0].[Nickname], [s0].[SquadId] +FROM [Tags] AS [t] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -ORDER BY [s].[Id], [s0].[Nickname] + WHERE [o].[Nickname] IS NOT NULL +) AS [s] ON [t].[GearNickName] = [s].[Nickname] +LEFT JOIN ( + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] +) AS [s0] ON ([s].[Nickname] = [s0].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s0].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s0].[LeaderSquadId] +ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Nickname] """); } - public override async Task Correlated_collection_order_by_constant(bool async) + public override async Task Correlated_collections_deeply_nested_left_join(bool async) { - await base.Correlated_collection_order_by_constant(async); + await base.Correlated_collections_deeply_nested_left_join(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId] +SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] +LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) + ) AS [w0] ON [g0].[FullName] = [w0].[OwnerFullName] + WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) +) AS [s1] ON [s0].[Id] = [s1].[SquadId] +ORDER BY [t].[Note], [s].[Nickname] DESC, [t].[Id], [s].[SquadId], [s0].[Id], [s1].[Nickname], [s1].[SquadId] """); } - public override async Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool async) + public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) { - await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(async); + await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); AssertSql( """ -SELECT [s].[Name], [s1].[c] -FROM [Squads] AS [s] +SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id], [s1].[Nickname], [s1].[SquadId], [s1].[Id], [s1].[AmmunitionType], [s1].[IsAutomatic], [s1].[Name], [s1].[OwnerFullName], [s1].[SynergyWithId], [s1].[Rank] +FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [s0].[c], [s0].[SquadId] - FROM ( - SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [s0] - WHERE [s0].[row] <= 1 -) AS [s1] ON [s].[Id] = [s1].[SquadId] + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] +) AS [s] ON [w].[OwnerFullName] = [s].[FullName] +LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g0].[Rank], [g0].[FullName] + FROM [Gears] AS [g0] + LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w0] + WHERE [w0].[IsAutomatic] = CAST(0 AS bit) + ) AS [w1] ON [g0].[FullName] = [w1].[OwnerFullName] +) AS [s1] ON [s0].[Id] = [s1].[SquadId] +ORDER BY [w].[Name], [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id], [s1].[FullName] DESC, [s1].[Nickname], [s1].[SquadId], [s1].[Id] """); } - public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool async) + public override async Task Correlated_collections_complex_scenario1(bool async) { - await base.Select_subquery_projecting_single_constant_of_non_mapped_type(async); + await base.Correlated_collections_complex_scenario1(async); AssertSql( """ -SELECT [s].[Name], [s1].[c] -FROM [Squads] AS [s] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0], [s2].[HasSoulPatch], [s2].[SquadId0] +FROM [Gears] AS [g] LEFT JOIN ( - SELECT [s0].[c], [s0].[SquadId] - FROM ( - SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] - FROM [Gears] AS [g] - WHERE [g].[HasSoulPatch] = CAST(1 AS bit) - ) AS [s0] - WHERE [s0].[row] <= 1 -) AS [s1] ON [s].[Id] = [s1].[SquadId] + SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] + LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId] + FROM [Gears] AS [g1] + ) AS [s1] ON [s0].[Id] = [s1].[SquadId] +) AS [s2] ON [g].[FullName] = [s2].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0] """); } - public override async Task Include_collection_OrderBy_aggregate(bool async) + public override async Task Correlated_collections_complex_scenario2(bool async) { - await base.Include_collection_OrderBy_aggregate(async); + await base.Correlated_collections_complex_scenario2(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s3].[FullName], [s3].[Nickname], [s3].[SquadId], [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00], [s3].[HasSoulPatch], [s3].[SquadId00] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s2].[Id], [s2].[Nickname] AS [Nickname0], [s2].[SquadId] AS [SquadId0], [s2].[Id0], [s2].[Nickname0] AS [Nickname00], [s2].[HasSoulPatch], [s2].[SquadId0] AS [SquadId00], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] + LEFT JOIN ( + SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] + ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] + LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] + LEFT JOIN ( + SELECT [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId] + FROM [Gears] AS [g2] + ) AS [s1] ON [s0].[Id] = [s1].[SquadId] + ) AS [s2] ON [g0].[FullName] = [s2].[OwnerFullName] +) AS [s3] ON [g].[Nickname] = [s3].[LeaderNickname] AND [g].[SquadId] = [s3].[LeaderSquadId] WHERE [o].[Nickname] IS NOT NULL -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [s].[Nickname] +ORDER BY [g].[Nickname], [g].[SquadId], [s3].[Nickname], [s3].[SquadId], [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00] """); } - public override async Task Include_collection_with_complex_OrderBy2(bool async) + public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) { - await base.Include_collection_with_complex_OrderBy2(async); + await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0], [s2].[HasSoulPatch], [s2].[SquadId0] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY ( - SELECT TOP(1) [w].[IsAutomatic] + SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), [g].[Nickname], [g].[SquadId], [s].[Nickname] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] + LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId] + FROM [Gears] AS [g1] + ) AS [s1] ON [s0].[Id] = [s1].[SquadId] +) AS [s2] ON [g].[FullName] = [s2].[OwnerFullName] +ORDER BY [g].[FullName], [g].[Nickname] DESC, [g].[SquadId], [s2].[Id], [s2].[Nickname], [s2].[SquadId], [s2].[Id0], [s2].[Nickname0] """); } - public override async Task Include_collection_with_complex_OrderBy3(bool async) + public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) { - await base.Include_collection_with_complex_OrderBy3(async); + await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s3].[FullName], [s3].[Nickname], [s3].[SquadId], [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00], [s3].[HasSoulPatch], [s3].[SquadId00] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] + SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [s2].[Id], [s2].[Nickname] AS [Nickname0], [s2].[SquadId] AS [SquadId0], [s2].[Id0], [s2].[Nickname0] AS [Nickname00], [s2].[HasSoulPatch], [s2].[SquadId0] AS [SquadId00], [g0].[HasSoulPatch] AS [HasSoulPatch0], [s2].[IsAutomatic], [s2].[Name], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] + LEFT JOIN ( + SELECT [w].[Id], [s].[Nickname], [s].[SquadId], [s0].[Id] AS [Id0], [s1].[Nickname] AS [Nickname0], [s1].[HasSoulPatch], [s1].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[FullName] + FROM [Gears] AS [g1] + ) AS [s] ON [w].[OwnerFullName] = [s].[FullName] + LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] + LEFT JOIN ( + SELECT [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId] + FROM [Gears] AS [g2] + ) AS [s1] ON [s0].[Id] = [s1].[SquadId] + ) AS [s2] ON [g0].[FullName] = [s2].[OwnerFullName] +) AS [s3] ON [g].[Nickname] = [s3].[LeaderNickname] AND [g].[SquadId] = [s3].[LeaderSquadId] WHERE [o].[Nickname] IS NOT NULL -ORDER BY COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)), [g].[Nickname], [g].[SquadId], [s].[Nickname] +ORDER BY [g].[HasSoulPatch], [g].[LeaderNickname], [g].[FullName], [g].[Nickname], [g].[SquadId], [s3].[FullName], [s3].[HasSoulPatch0] DESC, [s3].[Nickname], [s3].[SquadId], [s3].[IsAutomatic], [s3].[Name] DESC, [s3].[Id], [s3].[Nickname0], [s3].[SquadId0], [s3].[Id0], [s3].[Nickname00] """); } - public override async Task Correlated_collection_with_complex_OrderBy(bool async) + public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) { - await base.Correlated_collection_with_complex_OrderBy(async); + await base.Correlated_collection_with_top_level_FirstOrDefault(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [s].[Nickname] +SELECT [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[Nickname] +) AS [s] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [s].[Nickname], [s].[SquadId] """); } - public override async Task Correlated_collection_with_very_complex_order_by(bool async) + public override async Task Correlated_collection_with_top_level_Count(bool async) { - await base.Correlated_collection_with_very_complex_order_by(async); + await base.Correlated_collection_with_top_level_Count(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT COUNT(*) FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g1] - LEFT JOIN [Officers] AS [o0] ON [g1].[Nickname] = [o0].[Nickname] AND [g1].[SquadId] = [o0].[SquadId] - WHERE [g1].[HasSoulPatch] = CAST(0 AS bit) -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( - SELECT TOP(1) [g0].[HasSoulPatch] - FROM [Gears] AS [g0] - WHERE [g0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Cast_to_derived_type_after_OfType_works(bool async) + public override async Task Correlated_collection_with_top_level_Last_with_orderby_on_outer(bool async) { - await base.Cast_to_derived_type_after_OfType_works(async); + await base.Correlated_collection_with_top_level_Last_with_orderby_on_outer(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [o].[Nickname] IS NOT NULL +SELECT [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[FullName] +) AS [s] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [s].[FullName], [s].[Nickname], [s].[SquadId] """); } - public override async Task Select_subquery_boolean(bool async) + public override async Task Correlated_collection_with_top_level_Last_with_order_by_on_inner(bool async) { - await base.Select_subquery_boolean(async); + await base.Correlated_collection_with_top_level_Last_with_order_by_on_inner(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), CAST(0 AS bit)) -FROM [Gears] AS [g] +SELECT [s].[Nickname], [s].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[FullName] DESC +) AS [s] +LEFT JOIN [Weapons] AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [s].[FullName] DESC, [s].[Nickname], [s].[SquadId], [w].[Name] """); } - public override async Task Select_subquery_boolean_with_pushdown(bool async) + public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) { - await base.Select_subquery_boolean_with_pushdown(async); + await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]) -FROM [Gears] AS [g] +SELECT [s].[Id], [s].[CapitalName], [s].[Name], [s].[ServerAddress], [s].[CommanderName], [s].[Eradicated], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +INNER JOIN ( + SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l0].[CommanderName], [l0].[Eradicated], CASE + WHEN [l0].[Id] IS NOT NULL THEN N'LocustHorde' + END AS [Discriminator] + FROM [Factions] AS [f] + LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] + WHERE [l0].[Id] IS NOT NULL AND [f].[Name] = N'Swarm' +) AS [s] ON [l].[Name] = [s].[CommanderName] +WHERE [s].[Eradicated] = CAST(0 AS bit) OR [s].[Eradicated] IS NULL +"""); + } + + public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) + { + await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); + + AssertSql( + """ +SELECT [s].[Id], [s].[CapitalName], [s].[Name], [s].[ServerAddress], [s].[CommanderName], [s].[Eradicated], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN ( + SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l0].[CommanderName], [l0].[Eradicated], CASE + WHEN [l0].[Id] IS NOT NULL THEN N'LocustHorde' + END AS [Discriminator] + FROM [Factions] AS [f] + LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] + WHERE [l0].[Id] IS NOT NULL AND [f].[Name] = N'Swarm' +) AS [s] ON [l].[Name] = [s].[CommanderName] +WHERE [s].[Eradicated] = CAST(0 AS bit) OR [s].[Eradicated] IS NULL """); } - public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) + public override async Task Include_on_derived_type_with_order_by_and_paging(bool async) { - await base.Select_subquery_int_with_inside_cast_and_coalesce(async); + await base.Include_on_derived_type_with_order_by_and_paging(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 42) -FROM [Gears] AS [g] +@p='10' + +SELECT [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator0] AS [Discriminator], [s0].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM ( + SELECT TOP(@p) [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] AS [Discriminator0], [t].[Id], [t].[Note] + FROM [LocustLeaders] AS [l] + LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] + LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] + ) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] + LEFT JOIN [Tags] AS [t] ON ([s].[Nickname] = [t].[GearNickName] OR ([s].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([s].[SquadId] = [t].[GearSquadId] OR ([s].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) + ORDER BY [t].[Note] +) AS [s0] +LEFT JOIN [Weapons] AS [w] ON [s0].[FullName] = [w].[OwnerFullName] +ORDER BY [s0].[Note], [s0].[Name], [s0].[Nickname], [s0].[SquadId], [s0].[Id] """); } - public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bool async) + public override async Task Select_required_navigation_on_derived_type(bool async) { - await base.Select_subquery_int_with_outside_cast_and_coalesce(async); + await base.Select_required_navigation_on_derived_type(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 0) -FROM [Gears] AS [g] +SELECT [l1].[Name] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN [LocustHighCommands] AS [l1] ON [l0].[HighCommandId] = [l1].[Id] """); } - public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool async) + public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) { - await base.Select_subquery_int_with_pushdown_and_coalesce(async); + await base.Select_required_navigation_on_the_same_type_with_cast(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), 42) +SELECT [c].[Name] FROM [Gears] AS [g] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] """); } - public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool async) + public override async Task Where_required_navigation_on_derived_type(bool async) { - await base.Select_subquery_int_with_pushdown_and_coalesce2(async); + await base.Where_required_navigation_on_derived_type(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[Id] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] - ORDER BY [w].[Id]), ( - SELECT TOP(1) [w0].[Id] - FROM [Weapons] AS [w0] - WHERE [g].[FullName] = [w0].[OwnerFullName] - ORDER BY [w0].[Id])) -FROM [Gears] AS [g] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN [LocustHighCommands] AS [l1] ON [l0].[HighCommandId] = [l1].[Id] +WHERE [l1].[IsOperational] = CAST(1 AS bit) """); } - public override async Task Select_subquery_boolean_empty(bool async) + public override async Task Outer_parameter_in_join_key(bool async) { - await base.Select_subquery_boolean_empty(async); + await base.Outer_parameter_in_join_key(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ORDER BY [w].[Id]), CAST(0 AS bit)) +SELECT [g].[Nickname], [g].[SquadId], [s0].[Note], [s0].[Id], [s0].[Nickname], [s0].[SquadId] FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] + FROM [Tags] AS [t] + INNER JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + ) AS [s] ON [g].[FullName] = [s].[FullName] +) AS [s0] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname] """); } - public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) + public override async Task Outer_parameter_in_join_key_inner_and_outer(bool async) { - await base.Select_subquery_boolean_empty_with_pushdown(async); + await base.Outer_parameter_in_join_key_inner_and_outer(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ORDER BY [w].[Id]) +SELECT [g].[Nickname], [g].[SquadId], [s0].[Note], [s0].[Id], [s0].[Nickname], [s0].[SquadId] FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] + FROM [Tags] AS [t] + INNER JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + ) AS [s] ON [g].[FullName] = [g].[Nickname] +) AS [s0] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) + public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean1(async); + await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]), CAST(0 AS bit)) +SELECT [g].[Nickname], [g].[SquadId], [s0].[Note], [s0].[Id], [s0].[Nickname], [s0].[SquadId] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +OUTER APPLY ( + SELECT [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + ) AS [s] ON [g].[FullName] = [s].[FullName] +) AS [s0] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s0].[Id], [s0].[Nickname] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean2(bool async) + public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean2(async); + await base.Negated_bool_ternary_inside_anonymous_type_in_projection(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT ~CASE + WHEN [s].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) + ELSE COALESCE([s].[HasSoulPatch], CAST(1 AS bit)) +END AS [c] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) + public override async Task Order_by_entity_qsre(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_with_pushdown(async); + await base.Order_by_entity_qsre(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' - ) AS [w0]) +SELECT [g].[FullName] FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +ORDER BY [c].[Name], [g].[Nickname] DESC """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty1(bool async) + public override async Task Order_by_entity_qsre_with_inheritance(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty1(async); + await base.Order_by_entity_qsre_with_inheritance(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ) AS [w0]), CAST(0 AS bit)) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [l].[Name] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +INNER JOIN [LocustHighCommands] AS [l1] ON [l0].[HighCommandId] = [l1].[Id] +WHERE [l0].[Name] IS NOT NULL +ORDER BY [l1].[Id], [l].[Name] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty2(bool async) + public override async Task Order_by_entity_qsre_composite_key(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty2(async); + await base.Order_by_entity_qsre_composite_key(async); AssertSql( """ -SELECT COALESCE(( - SELECT TOP(1) [w].[IsAutomatic] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG'), CAST(0 AS bit)) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [w].[Name] +FROM [Weapons] AS [w] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] +) AS [s] ON [w].[OwnerFullName] = [s].[FullName] +ORDER BY [s].[Nickname], [s].[SquadId], [w].[Id] """); } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) + public override async Task Order_by_entity_qsre_with_other_orderbys(bool async) { - await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); + await base.Order_by_entity_qsre_with_other_orderbys(async); AssertSql( """ -SELECT ( - SELECT TOP(1) [w0].[IsAutomatic] - FROM ( - SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' - ) AS [w0]) -FROM [Gears] AS [g] -WHERE [g].[HasSoulPatch] = CAST(1 AS bit) +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] +) AS [s] ON [w].[OwnerFullName] = [s].[FullName] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w].[IsAutomatic], [s].[Nickname] DESC, [s].[SquadId] DESC, [w0].[Id], [w].[Name] """); } - public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool async) + public override async Task Join_on_entity_qsre_keys(bool async) { - await base.Cast_subquery_to_base_type_using_typed_ToList(async); + await base.Join_on_entity_qsre_keys(async); AssertSql( """ -SELECT [c].[Name], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Nickname], [s].[Rank], [s].[SquadId] -FROM [Cities] AS [c] -LEFT JOIN ( - SELECT [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId], [g].[AssignedCityName] - FROM [Gears] AS [g] -) AS [s] ON [c].[Name] = [s].[AssignedCityName] -WHERE [c].[Name] = N'Ephyra' -ORDER BY [c].[Name], [s].[Nickname] +SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] +FROM [Weapons] AS [w] +INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id] """); } - public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArray(bool async) + public override async Task Join_on_entity_qsre_keys_composite_key(bool async) { - await base.Cast_ordered_subquery_to_base_type_using_typed_ToArray(async); + await base.Join_on_entity_qsre_keys_composite_key(async); AssertSql( """ -SELECT [c].[Name], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Nickname], [s].[Rank], [s].[SquadId] -FROM [Cities] AS [c] -LEFT JOIN ( - SELECT [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId], [g].[AssignedCityName] - FROM [Gears] AS [g] -) AS [s] ON [c].[Name] = [s].[AssignedCityName] -WHERE [c].[Name] = N'Ephyra' -ORDER BY [c].[Name], [s].[Nickname] DESC +SELECT [g].[FullName] AS [GearName1], [s].[FullName] AS [GearName2] +FROM [Gears] AS [g] +INNER JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] +) AS [s] ON [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] """); } - public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) + public override async Task Join_on_entity_qsre_keys_inheritance(bool async) { - await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); + await base.Join_on_entity_qsre_keys_inheritance(async); AssertSql( """ -@nicknames='[]' (Size = 4000) - -SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] +SELECT [g].[FullName] AS [GearName], [s].[FullName] AS [OfficerName] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY CASE - WHEN [g].[Nickname] IN ( - SELECT [n].[value] - FROM OPENJSON(@nicknames) WITH ([value] nvarchar(450) '$') AS [n] - ) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END DESC, [g].[Nickname], [g].[SquadId] +INNER JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] + WHERE [o].[Nickname] IS NOT NULL +) AS [s] ON [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] """); } - public override async Task Double_order_by_on_nullable_bool_coming_from_optional_navigation(bool async) + public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool async) { - await base.Double_order_by_on_nullable_bool_coming_from_optional_navigation(async); + await base.Join_on_entity_qsre_keys_outer_key_is_navigation(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +SELECT [w].[Name] AS [Name1], [w1].[Name] AS [Name2] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w0].[IsAutomatic], [w0].[Id] +INNER JOIN [Weapons] AS [w1] ON [w0].[Id] = [w1].[Id] """); } - public override async Task Double_order_by_on_Like(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool async) { - await base.Double_order_by_on_Like(async); + await base.Join_on_entity_qsre_keys_inner_key_is_navigation(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] LIKE N'%Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [c].[Name] AS [CityName], [s].[Nickname] AS [GearNickname] +FROM [Cities] AS [c] +INNER JOIN ( + SELECT [g].[Nickname], [c0].[Name] + FROM [Gears] AS [g] + LEFT JOIN [Cities] AS [c0] ON [g].[AssignedCityName] = [c0].[Name] +) AS [s] ON [c].[Name] = [s].[Name] """); } - public override async Task Double_order_by_on_is_null(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) { - await base.Double_order_by_on_is_null(async); + await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [g].[Nickname], [s0].[Note] +FROM [Gears] AS [g] +INNER JOIN ( + SELECT [t].[Note], [s].[Nickname], [s].[SquadId] + FROM [Tags] AS [t] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] + WHERE [t].[Note] IN (N'Cole''s Tag', N'Dom''s Tag') +) AS [s0] ON [g].[Nickname] = [s0].[Nickname] AND [g].[SquadId] = [s0].[SquadId] """); } - public override async Task Double_order_by_on_string_compare(bool async) + public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { - await base.Double_order_by_on_string_compare(async); + await base.Join_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -ORDER BY CASE - WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w].[Id] +SELECT [s].[Name] AS [SquadName], [s2].[Name] AS [WeaponName] +FROM [Squads] AS [s] +INNER JOIN ( + SELECT [w].[Name], [s1].[Id] AS [Id0] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] + LEFT JOIN [Squads] AS [s1] ON [s0].[SquadId] = [s1].[Id] + WHERE [w].[IsAutomatic] = CAST(1 AS bit) +) AS [s2] ON [s].[Id] = [s2].[Id0] """); } - public override async Task Double_order_by_binary_expression(bool async) + public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { - await base.Double_order_by_binary_expression(async); + await base.GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( """ -SELECT [w].[Id] + 2 AS [Binary] -FROM [Weapons] AS [w] -ORDER BY [w].[Id] + 2 +SELECT [s].[Name] AS [SquadName], [s2].[Name] AS [WeaponName] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [w].[Name], [s1].[Id] AS [Id0] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] + LEFT JOIN [Squads] AS [s1] ON [s0].[SquadId] = [s1].[Id] +) AS [s2] ON [s].[Id] = [s2].[Id0] """); } - public override async Task String_compare_with_null_conditional_argument(bool async) + public override async Task Streaming_correlated_collection_issue_11403(bool async) { - await base.String_compare_with_null_conditional_argument(async); + await base.Streaming_correlated_collection_issue_11403(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [s].[Nickname], [s].[SquadId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM ( + SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] + ORDER BY [g].[Nickname] +) AS [s] +LEFT JOIN ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = CAST(0 AS bit) +) AS [w0] ON [s].[FullName] = [w0].[OwnerFullName] +ORDER BY [s].[Nickname], [s].[SquadId], [w0].[Id] """); } - public override async Task String_compare_with_null_conditional_argument2(bool async) + public override async Task Project_one_value_type_from_empty_collection(bool async) { - await base.String_compare_with_null_conditional_argument2(async); + await base.Project_one_value_type_from_empty_collection(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY CASE - WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [SquadId] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task String_concat_with_null_conditional_argument(bool async) + public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) { - await base.String_concat_with_null_conditional_argument(async); + await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY COALESCE([w0].[Name], N'') + CAST(5 AS nvarchar(max)) +SELECT [s].[Name], ( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [SquadId] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task String_concat_with_null_conditional_argument2(bool async) + public override async Task Project_one_value_type_with_client_projection_from_empty_collection(bool async) { - await base.String_concat_with_null_conditional_argument2(async); + await base.Project_one_value_type_with_client_projection_from_empty_collection(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY COALESCE([w0].[Name], N'') + N'Marcus'' Lancer' +SELECT [s].[Name], [s1].[SquadId], [s1].[LeaderSquadId], [s1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [s0].[SquadId], [s0].[LeaderSquadId], [s0].[c] + FROM ( + SELECT [g].[SquadId], [g].[LeaderSquadId], 1 AS [c], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [s0] + WHERE [s0].[row] <= 1 +) AS [s1] ON [s].[Id] = [s1].[SquadId] +WHERE [s].[Name] = N'Kilo' """); } - public override async Task String_concat_on_various_types(bool async) + public override async Task Filter_on_subquery_projecting_one_value_type_from_empty_collection(bool async) { - await base.String_concat_on_various_types(async); + await base.Filter_on_subquery_projecting_one_value_type_from_empty_collection(async); AssertSql( """ -SELECT N'HasSoulPatch ' + CAST([g].[HasSoulPatch] AS nvarchar(max)) + N' HasSoulPatch' AS [HasSoulPatch], N'Rank ' + CAST([g].[Rank] AS nvarchar(max)) + N' Rank' AS [Rank], N'SquadId ' + CAST([g].[SquadId] AS nvarchar(max)) + N' SquadId' AS [SquadId], N'Rating ' + COALESCE(CAST([m].[Rating] AS nvarchar(max)), N'') + N' Rating' AS [Rating], N'Timeline ' + CAST([m].[Timeline] AS nvarchar(max)) + N' Timeline' AS [Timeline] -FROM [Gears] AS [g] -CROSS JOIN [Missions] AS [m] -ORDER BY [g].[Nickname], [m].[Id] +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Kilo' AND COALESCE(( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) <> 0 """); } - public override async Task Time_of_day_datetimeoffset(bool async) + public override async Task Select_subquery_projecting_single_constant_int(bool async) { - await base.Time_of_day_datetimeoffset(async); + await base.Select_subquery_projecting_single_constant_int(async); AssertSql( """ -SELECT CONVERT(time, [m].[Timeline]) -FROM [Missions] AS [m] +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) 42 + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), 0) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task GroupBy_Property_Include_Select_Average(bool async) + public override async Task Select_subquery_projecting_single_constant_string(bool async) { - await base.GroupBy_Property_Include_Select_Average(async); + await base.Select_subquery_projecting_single_constant_string(async); AssertSql( """ -SELECT AVG(CAST([g].[SquadId] AS float)) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Name], ( + SELECT TOP(1) N'Foo' + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task GroupBy_Property_Include_Select_Sum(bool async) + public override async Task Select_subquery_projecting_single_constant_bool(bool async) { - await base.GroupBy_Property_Include_Select_Sum(async); + await base.Select_subquery_projecting_single_constant_bool(async); AssertSql( """ -SELECT COALESCE(SUM([g].[SquadId]), 0) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Name], COALESCE(( + SELECT TOP(1) CAST(1 AS bit) + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit)), CAST(0 AS bit)) AS [Gear] +FROM [Squads] AS [s] """); } - public override async Task GroupBy_Property_Include_Select_Count(bool async) + public override async Task Select_subquery_projecting_single_constant_inside_anonymous(bool async) { - await base.GroupBy_Property_Include_Select_Count(async); + await base.Select_subquery_projecting_single_constant_inside_anonymous(async); AssertSql( """ -SELECT COUNT(*) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Name], [s1].[One] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [s0].[One], [s0].[SquadId] + FROM ( + SELECT 1 AS [One], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [s0] + WHERE [s0].[row] <= 1 +) AS [s1] ON [s].[Id] = [s1].[SquadId] """); } - public override async Task GroupBy_Property_Include_Select_LongCount(bool async) + public override async Task Select_subquery_projecting_multiple_constants_inside_anonymous(bool async) { - await base.GroupBy_Property_Include_Select_LongCount(async); + await base.Select_subquery_projecting_multiple_constants_inside_anonymous(async); AssertSql( """ -SELECT COUNT_BIG(*) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Name], [s1].[True1], [s1].[False1], [s1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [s0].[True1], [s0].[False1], [s0].[c], [s0].[SquadId] + FROM ( + SELECT CAST(1 AS bit) AS [True1], CAST(0 AS bit) AS [False1], 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [s0] + WHERE [s0].[row] <= 1 +) AS [s1] ON [s].[Id] = [s1].[SquadId] """); } - public override async Task GroupBy_Property_Include_Select_Min(bool async) + public override async Task Include_with_order_by_constant(bool async) { - await base.GroupBy_Property_Include_Select_Min(async); + await base.Include_with_order_by_constant(async); AssertSql( """ -SELECT MIN([g].[SquadId]) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +ORDER BY [s].[Id], [s0].[Nickname] """); } - public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(bool async) + public override async Task Correlated_collection_order_by_constant(bool async) { - await base.GroupBy_Property_Include_Aggregate_with_anonymous_selector(async); + await base.Correlated_collection_order_by_constant(async); AssertSql( """ -SELECT [g].[Nickname] AS [Key], COUNT(*) AS [c] +SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] FROM [Gears] AS [g] -GROUP BY [g].[Nickname] -ORDER BY [g].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Group_by_with_include_with_entity_in_result_selector(bool async) + public override async Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool async) { - await base.Group_by_with_include_with_entity_in_result_selector(async); + await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(async); AssertSql( """ -SELECT [s].[Rank], [s].[c], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Name], [s1].[Location], [s1].[Nation] -FROM ( - SELECT [g].[Rank], COUNT(*) AS [c] - FROM [Gears] AS [g] - GROUP BY [g].[Rank] -) AS [s] +SELECT [s].[Name], [s1].[c] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] + SELECT [s0].[c], [s0].[SquadId] FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname]) AS [row] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] - INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] + SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ) AS [s0] WHERE [s0].[row] <= 1 -) AS [s1] ON [s].[Rank] = [s1].[Rank] -ORDER BY [s].[Rank] +) AS [s1] ON [s].[Id] = [s1].[SquadId] """); } - public override async Task GroupBy_Property_Include_Select_Max(bool async) + public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool async) { - await base.GroupBy_Property_Include_Select_Max(async); + await base.Select_subquery_projecting_single_constant_of_non_mapped_type(async); AssertSql( """ -SELECT MAX([g].[SquadId]) -FROM [Gears] AS [g] -GROUP BY [g].[Rank] +SELECT [s].[Name], [s1].[c] +FROM [Squads] AS [s] +LEFT JOIN ( + SELECT [s0].[c], [s0].[SquadId] + FROM ( + SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] + FROM [Gears] AS [g] + WHERE [g].[HasSoulPatch] = CAST(1 AS bit) + ) AS [s0] + WHERE [s0].[row] <= 1 +) AS [s1] ON [s].[Id] = [s1].[SquadId] """); } - public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) + public override async Task Include_collection_OrderBy_aggregate(bool async) { - await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); + await base.Include_collection_OrderBy_aggregate(async); AssertSql( """ -SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Name], [s1].[Location], [s1].[Nation] -FROM ( - SELECT [g].[Rank] - FROM [Gears] AS [g] - GROUP BY [g].[Rank] -) AS [s] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname], [g0].[SquadId], [c].[Name]) AS [row] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] - INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] - WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) - ) AS [s0] - WHERE [s0].[row] <= 1 -) AS [s1] ON [s].[Rank] = [s1].[Rank] + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Include_collection_with_Cast_to_base(bool async) + public override async Task Include_collection_with_complex_OrderBy2(bool async) { - await base.Include_collection_with_Cast_to_base(async); + await base.Include_collection_with_complex_OrderBy2(async); AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId] +ORDER BY ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Include_with_client_method_and_member_access_still_applies_includes(bool async) + public override async Task Include_collection_with_complex_OrderBy3(bool async) { - await base.Include_with_client_method_and_member_access_still_applies_includes(async); + await base.Include_collection_with_complex_OrderBy3(async); AssertSql( """ SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)), [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Include_with_projection_of_unmapped_property_still_gets_applied(bool async) + public override async Task Correlated_collection_with_complex_OrderBy(bool async) { - await base.Include_with_projection_of_unmapped_property_still_gets_applied(async); + await base.Correlated_collection_with_complex_OrderBy(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection() + public override async Task Correlated_collection_with_very_complex_order_by(bool async) { - await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); + await base.Correlated_collection_with_very_complex_order_by(async); AssertSql( """ -SELECT [s].[Name], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] -FROM [Squads] AS [s] +SELECT [g].[Nickname], [g].[SquadId], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -) AS [s0] ON [s].[Id] = [s0].[SquadId] -WHERE [s].[Name] = N'Delta' -ORDER BY [s].[Id], [s0].[Nickname], [s0].[SquadId] + SELECT [g1].[Nickname], [g1].[SquadId], [g1].[AssignedCityName], [g1].[CityOfBirthName], [g1].[FullName], [g1].[HasSoulPatch], [g1].[LeaderNickname], [g1].[LeaderSquadId], [g1].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g1] + LEFT JOIN [Officers] AS [o0] ON [g1].[Nickname] = [o0].[Nickname] AND [g1].[SquadId] = [o0].[SquadId] + WHERE [g1].[HasSoulPatch] = CAST(0 AS bit) +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = COALESCE(( + SELECT TOP(1) [g0].[HasSoulPatch] + FROM [Gears] AS [g0] + WHERE [g0].[Nickname] = N'Marcus'), CAST(0 AS bit))), [g].[Nickname], [g].[SquadId], [s].[Nickname] """); } - public override async Task OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(bool async) + public override async Task Cast_to_derived_type_after_OfType_works(bool async) { - await base.OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(async); + await base.Cast_to_derived_type_after_OfType_works(async); AssertSql( """ -SELECT CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) -END +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -ORDER BY CASE - WHEN CASE - WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) - END IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE [o].[Nickname] IS NOT NULL """); } - public override async Task GetValueOrDefault_in_projection(bool async) + public override async Task Select_subquery_boolean(bool async) { - await base.GetValueOrDefault_in_projection(async); + await base.Select_subquery_boolean(async); AssertSql( """ -SELECT COALESCE([w].[SynergyWithId], 0) -FROM [Weapons] AS [w] +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), CAST(0 AS bit)) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_in_filter(bool async) + public override async Task Select_subquery_boolean_with_pushdown(bool async) { - await base.GetValueOrDefault_in_filter(async); + await base.Select_subquery_boolean_with_pushdown(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], 0) = 0 +SELECT ( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool async) + public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) { - await base.GetValueOrDefault_in_filter_non_nullable_column(async); + await base.Select_subquery_int_with_inside_cast_and_coalesce(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[Id] = 0 +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 42) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_in_order_by(bool async) + public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bool async) { - await base.GetValueOrDefault_in_order_by(async); + await base.Select_subquery_int_with_outside_cast_and_coalesce(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -ORDER BY COALESCE([w].[SynergyWithId], 0), [w].[Id] +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 0) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_with_argument(bool async) + public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool async) { - await base.GetValueOrDefault_with_argument(async); + await base.Select_subquery_int_with_pushdown_and_coalesce(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], [w].[Id]) = 1 +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), 42) +FROM [Gears] AS [g] """); } - public override async Task GetValueOrDefault_with_argument_complex(bool async) + public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool async) { - await base.GetValueOrDefault_with_argument_complex(async); + await base.Select_subquery_int_with_pushdown_and_coalesce2(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE COALESCE([w].[SynergyWithId], CAST(LEN([w].[Name]) AS int) + 42) > 10 +SELECT COALESCE(( + SELECT TOP(1) [w].[Id] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] + ORDER BY [w].[Id]), ( + SELECT TOP(1) [w0].[Id] + FROM [Weapons] AS [w0] + WHERE [g].[FullName] = [w0].[OwnerFullName] + ORDER BY [w0].[Id])) +FROM [Gears] AS [g] """); } - public override async Task Filter_with_complex_predicate_containing_subquery(bool async) + public override async Task Select_subquery_boolean_empty(bool async) { - await base.Filter_with_complex_predicate_containing_subquery(async); + await base.Select_subquery_boolean_empty(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[FullName] <> N'Dom' AND EXISTS ( - SELECT 1 +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit)) + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ORDER BY [w].[Id]), CAST(0 AS bit)) +FROM [Gears] AS [g] """); } - public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( - bool async) + public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) { - await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(async); + await base.Select_subquery_boolean_empty_with_pushdown(async); AssertSql( """ -SELECT [g].[Nickname], ( - SELECT TOP(1) [w].[Name] +SELECT ( + SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit) - ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ORDER BY [w].[Id]) FROM [Gears] AS [g] -WHERE [g].[Nickname] <> N'Dom' """); } - public override async Task - Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); + await base.Select_subquery_distinct_singleordefault_boolean1(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE SUBSTRING([t].[Note], 0 + 1, [s].[SquadId]) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s].[SquadId] IS NULL) AND [t].[GearNickName] IS NULL) +SELECT COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]), CAST(0 AS bit)) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task - Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean2(bool async) { - await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( - async); + await base.Select_subquery_distinct_singleordefault_boolean2(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] -WHERE SUBSTRING([t].[Note], 0 + 1, CAST(LEN([s0].[Name]) AS int)) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s0].[Name] IS NULL) AND [t].[GearNickName] IS NULL) +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%'), CAST(0 AS bit)) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Filter_with_new_Guid(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { - await base.Filter_with_new_Guid(async); + await base.Select_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] = 'df36f493-463f-4123-83f9-6b135deeb7ba' +SELECT ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Lancer%' + ) AS [w0]) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task Filter_with_new_Guid_closure(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty1(bool async) { - await base.Filter_with_new_Guid_closure(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty1(async); AssertSql( """ -@p='df36f493-463f-4123-83f9-6b135deeb7bd' - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] = @p -""", - // - """ -@p='b39a6fba-9026-4d69-828e-fd7068673e57' - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] -FROM [Tags] AS [t] -WHERE [t].[Id] = @p +SELECT COALESCE(( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ) AS [w0]), CAST(0 AS bit)) +FROM [Gears] AS [g] +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task OfTypeNav1(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty2(bool async) { - await base.OfTypeNav1(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty2(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT COALESCE(( + SELECT TOP(1) [w].[IsAutomatic] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG'), CAST(0 AS bit)) FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task OfTypeNav2(bool async) + public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) { - await base.OfTypeNav2(async); + await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT ( + SELECT TOP(1) [w0].[IsAutomatic] + FROM ( + SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] = N'BFG' + ) AS [w0]) FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) +WHERE [g].[HasSoulPatch] = CAST(1 AS bit) """); } - public override async Task OfTypeNav3(bool async) + public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool async) { - await base.OfTypeNav3(async); + await base.Cast_subquery_to_base_type_using_typed_ToList(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] -LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] -WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +SELECT [c].[Name], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Nickname], [s].[Rank], [s].[SquadId] +FROM [Cities] AS [c] +LEFT JOIN ( + SELECT [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId], [g].[AssignedCityName] + FROM [Gears] AS [g] +) AS [s] ON [c].[Name] = [s].[AssignedCityName] +WHERE [c].[Name] = N'Ephyra' +ORDER BY [c].[Name], [s].[Nickname] """); } - public override async Task Nav_rewrite_Distinct_with_convert() + public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArray(bool async) { - await base.Nav_rewrite_Distinct_with_convert(); + await base.Cast_ordered_subquery_to_base_type_using_typed_ToArray(async); - AssertSql(); + AssertSql( + """ +SELECT [c].[Name], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Nickname], [s].[Rank], [s].[SquadId] +FROM [Cities] AS [c] +LEFT JOIN ( + SELECT [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId], [g].[AssignedCityName] + FROM [Gears] AS [g] +) AS [s] ON [c].[Name] = [s].[AssignedCityName] +WHERE [c].[Name] = N'Ephyra' +ORDER BY [c].[Name], [s].[Nickname] DESC +"""); } - public override async Task Nav_rewrite_Distinct_with_convert_anonymous() + public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) { - await base.Nav_rewrite_Distinct_with_convert_anonymous(); + await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); + + AssertSql( + """ +@nicknames='[]' (Size = 4000) - AssertSql(); +SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY CASE + WHEN [g].[Nickname] IN ( + SELECT [n].[value] + FROM OPENJSON(@nicknames) WITH ([value] nvarchar(450) '$') AS [n] + ) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END DESC, [g].[Nickname], [g].[SquadId] +"""); } - public override async Task Nav_rewrite_with_convert1(bool async) + public override async Task Double_order_by_on_nullable_bool_coming_from_optional_navigation(bool async) { - await base.Nav_rewrite_with_convert1(async); + await base.Double_order_by_on_nullable_bool_coming_from_optional_navigation(async); AssertSql( """ -SELECT [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w0].[IsAutomatic], [w0].[Id] """); } - public override async Task Nav_rewrite_with_convert2(bool async) + public override async Task Double_order_by_on_Like(bool async) { - await base.Nav_rewrite_with_convert2(async); + await base.Double_order_by_on_Like(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] -LEFT JOIN ( - SELECT [l0].[Name] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([s].[Name] <> N'Bar' OR [s].[Name] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] LIKE N'%Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Nav_rewrite_with_convert3(bool async) + public override async Task Double_order_by_on_is_null(bool async) { - await base.Nav_rewrite_with_convert3(async); + await base.Double_order_by_on_is_null(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] -LEFT JOIN ( - SELECT [l0].[Name] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([s].[Name] <> N'Bar' OR [s].[Name] IS NULL) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Where_contains_on_navigation_with_composite_keys(bool async) + public override async Task Double_order_by_on_string_compare(bool async) { - await base.Where_contains_on_navigation_with_composite_keys(async); + await base.Double_order_by_on_string_compare(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 EXISTS ( - SELECT 1 - FROM [Cities] AS [c] - WHERE EXISTS ( - SELECT 1 - FROM [Gears] AS [g0] - WHERE [c].[Name] = [g0].[CityOfBirthName] AND [g0].[Nickname] = [g].[Nickname] AND [g0].[SquadId] = [g].[SquadId])) +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +ORDER BY CASE + WHEN [w].[Name] = N'Marcus'' Lancer' AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w].[Id] """); } - public override async Task Include_with_complex_order_by(bool async) + public override async Task Double_order_by_binary_expression(bool async) { - await base.Include_with_complex_order_by(async); + await base.Double_order_by_binary_expression(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] -ORDER BY ( - SELECT TOP(1) [w].[Name] - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Gnasher%'), [g].[Nickname], [g].[SquadId] +SELECT [w].[Id] + 2 AS [Binary] +FROM [Weapons] AS [w] +ORDER BY [w].[Id] + 2 """); } - public override async Task Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(bool async) + public override async Task String_compare_with_null_conditional_argument(bool async) { - await base.Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(async); + await base.String_compare_with_null_conditional_argument(async); AssertSql( """ -@p='25' - -SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId] -FROM ( - SELECT TOP(@p) [g].[FullName] - FROM [Gears] AS [g] -) AS [s] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] - FROM [Weapons] AS [w] - ) AS [w0] - WHERE [w0].[row] <= 1 -) AS [w1] ON [s].[FullName] = [w1].[OwnerFullName] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN [w0].[Name] = N'Marcus'' Lancer' AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Bool_projection_from_subquery_treated_appropriately_in_where(bool async) + public override async Task String_compare_with_null_conditional_argument2(bool async) { - await base.Bool_projection_from_subquery_treated_appropriately_in_where(async); + await base.String_compare_with_null_conditional_argument2(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE ( - SELECT TOP(1) [g].[HasSoulPatch] - FROM [Gears] AS [g] - ORDER BY [g].[Nickname], [g].[SquadId]) = CAST(1 AS bit) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY CASE + WHEN N'Marcus'' Lancer' = [w0].[Name] AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) + public override async Task String_concat_with_null_conditional_argument(bool async) { - await base.DateTimeOffset_Contains_Less_than_Greater_than(async); + await base.String_concat_with_null_conditional_argument(async); AssertSql( """ -@start='1902-01-01T10:00:00.1234567+01:30' -@end='1902-01-03T10:00:00.1234567+01:30' -@dates='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) - -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE @start <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @end AND [m].[Timeline] IN ( - SELECT [d].[value] - FROM OPENJSON(@dates) WITH ([value] datetimeoffset '$') AS [d] -) +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY COALESCE([w0].[Name], N'') + CAST(5 AS nvarchar(max)) """); } - public override Task DateTimeOffsetNow_minus_timespan(bool async) - => AssertTranslationFailed(() => base.DateTimeOffsetNow_minus_timespan(async)); - - public override async Task Navigation_inside_interpolated_string_expanded(bool async) + public override async Task String_concat_with_null_conditional_argument2(bool async) { - await base.Navigation_inside_interpolated_string_expanded(async); + await base.String_concat_with_null_conditional_argument2(async); AssertSql( """ -SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [w0].[OwnerFullName] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY COALESCE([w0].[Name], N'') + N'Marcus'' Lancer' """); } - public override async Task Left_join_projection_using_coalesce_tracking(bool async) + public override async Task String_concat_on_various_types(bool async) { - await base.Left_join_projection_using_coalesce_tracking(async); + await base.String_concat_on_various_types(async); AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT N'HasSoulPatch ' + CAST([g].[HasSoulPatch] AS nvarchar(max)) + N' HasSoulPatch' AS [HasSoulPatch], N'Rank ' + CAST([g].[Rank] AS nvarchar(max)) + N' Rank' AS [Rank], N'SquadId ' + CAST([g].[SquadId] AS nvarchar(max)) + N' SquadId' AS [SquadId], N'Rating ' + COALESCE(CAST([m].[Rating] AS nvarchar(max)), N'') + N' Rating' AS [Rating], N'Timeline ' + CAST([m].[Timeline] AS nvarchar(max)) + N' Timeline' AS [Timeline] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +CROSS JOIN [Missions] AS [m] +ORDER BY [g].[Nickname], [m].[Id] """); } - public override async Task Left_join_projection_using_conditional_tracking(bool async) + public override async Task GroupBy_Property_Include_Select_Average(bool async) { - await base.Left_join_projection_using_conditional_tracking(async); + await base.GroupBy_Property_Include_Select_Average(async); AssertSql( """ -SELECT CASE - WHEN [s].[Nickname] IS NULL OR [s].[SquadId] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +SELECT AVG(CAST([g].[SquadId] AS float)) FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] +GROUP BY [g].[Rank] """); } - public override async Task Project_collection_navigation_nested_with_take_composite_key(bool async) + public override async Task GroupBy_Property_Include_Select_Sum(bool async) { - await base.Project_collection_navigation_nested_with_take_composite_key(async); + await base.GroupBy_Property_Include_Select_Sum(async); AssertSql( - """ -SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], CASE - 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] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] - FROM ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator], ROW_NUMBER() OVER(PARTITION BY [g0].[LeaderNickname], [g0].[LeaderSquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) AS [row] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - ) AS [s0] - WHERE [s0].[row] <= 50 -) AS [s1] ON ([s].[Nickname] = [s1].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s1].[LeaderSquadId] -WHERE [s].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Nickname] + """ +SELECT COALESCE(SUM([g].[SquadId]), 0) +FROM [Gears] AS [g] +GROUP BY [g].[Rank] """); } - public override async Task Project_collection_navigation_nested_composite_key(bool async) + public override async Task GroupBy_Property_Include_Select_Count(bool async) { - await base.Project_collection_navigation_nested_composite_key(async); + await base.GroupBy_Property_Include_Select_Count(async); AssertSql( """ -SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], CASE - 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] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] -) AS [s0] ON ([s].[Nickname] = [s0].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s0].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s0].[LeaderSquadId] -WHERE [s].[Discriminator] = N'Officer' -ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Nickname] +SELECT COUNT(*) +FROM [Gears] AS [g] +GROUP BY [g].[Rank] """); } - public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) + public override async Task GroupBy_Property_Include_Select_LongCount(bool async) { - await base.Null_checks_in_correlated_predicate_are_correctly_translated(async); + await base.GroupBy_Property_Include_Select_LongCount(async); AssertSql( """ -SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] AND [t].[Note] IS NOT NULL -ORDER BY [t].[Id], [s].[Nickname] +SELECT COUNT_BIG(*) +FROM [Gears] AS [g] +GROUP BY [g].[Rank] """); } - public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(bool async) + public override async Task GroupBy_Property_Include_Select_Min(bool async) { - await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(async); + await base.GroupBy_Property_Include_Select_Min(async); AssertSql( """ -@isAutomatic='True' - -SELECT [g].[Nickname], [g].[FullName], CASE - WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Collection] +SELECT MIN([g].[SquadId]) FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[OwnerFullName] - FROM [Weapons] AS [w] - WHERE [w].[IsAutomatic] = @isAutomatic -) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +GROUP BY [g].[Rank] """); } - public override async Task Join_with_inner_being_a_subquery_projecting_single_property(bool async) + public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(bool async) { - await base.Join_with_inner_being_a_subquery_projecting_single_property(async); + await base.GroupBy_Property_Include_Aggregate_with_anonymous_selector(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname] AS [Key], COUNT(*) AS [c] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN ( - SELECT [g0].[Nickname] - FROM [Gears] AS [g0] -) AS [s] ON [g].[Nickname] = [s].[Nickname] +GROUP BY [g].[Nickname] +ORDER BY [g].[Nickname] """); } - public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) + public override async Task Group_by_with_include_with_entity_in_result_selector(bool async) { - await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); + await base.Group_by_with_include_with_entity_in_result_selector(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [s].[Rank], [s].[c], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Name], [s1].[Location], [s1].[Nation] +FROM ( + SELECT [g].[Rank], COUNT(*) AS [c] + FROM [Gears] AS [g] + GROUP BY [g].[Rank] +) AS [s] +LEFT JOIN ( + SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname]) AS [row] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] + INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] + ) AS [s0] + WHERE [s0].[row] <= 1 +) AS [s1] ON [s].[Rank] = [s1].[Rank] +ORDER BY [s].[Rank] +"""); + } + + public override async Task GroupBy_Property_Include_Select_Max(bool async) + { + await base.GroupBy_Property_Include_Select_Max(async); + + AssertSql( + """ +SELECT MAX([g].[SquadId]) FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN ( - SELECT [g0].[Nickname] - FROM [Gears] AS [g0] -) AS [s] ON [g].[Nickname] = [s].[Nickname] +GROUP BY [g].[Rank] """); } - public override async Task Navigation_based_on_complex_expression1(bool async) + public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) { - await base.Navigation_based_on_complex_expression1(async); + await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator], [s1].[Name], [s1].[Location], [s1].[Nation] +FROM ( + SELECT [g].[Rank] + FROM [Gears] AS [g] + GROUP BY [g].[Rank] +) AS [s] LEFT JOIN ( - SELECT [l0].[Name] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE CASE - WHEN [l].[Id] IS NOT NULL AND [s].[Name] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) + SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Name], [s0].[Location], [s0].[Nation] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], [c].[Name], [c].[Location], [c].[Nation], ROW_NUMBER() OVER(PARTITION BY [g0].[Rank] ORDER BY [g0].[Nickname], [g0].[SquadId], [c].[Name]) AS [row] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o] ON [g0].[Nickname] = [o].[Nickname] AND [g0].[SquadId] = [o].[SquadId] + INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] + WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) + ) AS [s0] + WHERE [s0].[row] <= 1 +) AS [s1] ON [s].[Rank] = [s1].[Rank] """); } - public override async Task Navigation_based_on_complex_expression2(bool async) + public override async Task Include_collection_with_Cast_to_base(bool async) { - await base.Navigation_based_on_complex_expression2(async); + await base.Include_collection_with_Cast_to_base(async); AssertSql( """ -SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE - WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' -END AS [Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [l].[Id] IS NOT NULL AND [s].[Name] IS NOT NULL +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Navigation_based_on_complex_expression3(bool async) + public override async Task Include_with_client_method_and_member_access_still_applies_includes(bool async) { - await base.Navigation_based_on_complex_expression3(async); + await base.Include_with_client_method_and_member_access_still_applies_includes(async); AssertSql( """ -SELECT [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -LEFT JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] - FROM [LocustLeaders] AS [l0] - INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] -) AS [s] ON [l].[CommanderName] = [s].[Name] -WHERE [l].[Id] IS NOT NULL +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] """); } - public override async Task Navigation_based_on_complex_expression4(bool async) + public override async Task Include_with_projection_of_unmapped_property_still_gets_applied(bool async) { - await base.Navigation_based_on_complex_expression4(async); + await base.Include_with_projection_of_unmapped_property_still_gets_applied(async); AssertSql( """ -SELECT CASE - WHEN [l].[Id] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -CROSS JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE - WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator] - FROM [LocustLeaders] AS [l0] - LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] - WHERE [l1].[Name] IS NOT NULL -) AS [s] -LEFT JOIN ( - SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId] - FROM [LocustLeaders] AS [l2] - INNER JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] -) AS [s0] ON [l].[CommanderName] = [s0].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Navigation_based_on_complex_expression5(bool async) + public override async Task Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection() { - await base.Navigation_based_on_complex_expression5(async); + await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); AssertSql( """ -SELECT [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -CROSS JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE - WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator] - FROM [LocustLeaders] AS [l0] - LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] - WHERE [l1].[Name] IS NOT NULL -) AS [s] +SELECT [s].[Name], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator], [s0].[Id], [s0].[AmmunitionType], [s0].[IsAutomatic], [s0].[Name], [s0].[OwnerFullName], [s0].[SynergyWithId] +FROM [Squads] AS [s] LEFT JOIN ( - SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId] - FROM [LocustLeaders] AS [l2] - INNER JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] -) AS [s0] ON [l].[CommanderName] = [s0].[Name] -WHERE [l].[Id] IS NOT NULL + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Gears] AS [g] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] + LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +) AS [s0] ON [s].[Id] = [s0].[SquadId] +WHERE [s].[Name] = N'Delta' +ORDER BY [s].[Id], [s0].[Nickname], [s0].[SquadId] """); } - public override async Task Navigation_based_on_complex_expression6(bool async) + public override async Task OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(bool async) { - await base.Navigation_based_on_complex_expression6(async); + await base.OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(async); AssertSql( """ SELECT CASE - WHEN [s0].[Name] = N'Queen Myrrah' AND [s0].[Name] IS NOT NULL THEN CAST(1 AS bit) + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) +END +FROM [Gears] AS [g] +ORDER BY CASE + WHEN CASE + WHEN [g].[LeaderNickname] IS NOT NULL THEN ~CAST(CAST(LEN([g].[Nickname]) AS int) ^ 5 AS bit) + END IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END, [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator] -FROM [Factions] AS [f] -LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] -CROSS JOIN ( - SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE - WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator] - FROM [LocustLeaders] AS [l0] - LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] - WHERE [l1].[Name] IS NOT NULL -) AS [s] -LEFT JOIN ( - SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId] - FROM [LocustLeaders] AS [l2] - INNER JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] -) AS [s0] ON [l].[CommanderName] = [s0].[Name] -WHERE [l].[Id] IS NOT NULL +END """); } - public override async Task Select_as_operator(bool async) + public override async Task GetValueOrDefault_in_projection(bool async) { - await base.Select_as_operator(async); + await base.GetValueOrDefault_in_projection(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +SELECT COALESCE([w].[SynergyWithId], 0) +FROM [Weapons] AS [w] """); } - public override async Task Select_datetimeoffset_comparison_in_projection(bool async) + public override async Task GetValueOrDefault_in_filter(bool async) { - await base.Select_datetimeoffset_comparison_in_projection(async); + await base.GetValueOrDefault_in_filter(async); AssertSql( """ -SELECT CASE - WHEN [m].[Timeline] > SYSDATETIMEOFFSET() THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Missions] AS [m] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], 0) = 0 """); } - public override async Task OfType_in_subquery_works(bool async) + public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool async) { - await base.OfType_in_subquery_works(async); + await base.GetValueOrDefault_in_filter_non_nullable_column(async); AssertSql( """ -SELECT [s].[Name], [s].[Location], [s].[Nation] -FROM [Gears] AS [g] -INNER JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN ( - SELECT [c].[Name], [c].[Location], [c].[Nation], [g0].[LeaderNickname], [g0].[LeaderSquadId] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] - WHERE [o0].[Nickname] IS NOT NULL -) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[Id] = 0 """); } - public override async Task Nullable_bool_comparison_is_translated_to_server(bool async) + public override async Task GetValueOrDefault_in_order_by(bool async) { - await base.Nullable_bool_comparison_is_translated_to_server(async); + await base.GetValueOrDefault_in_order_by(async); AssertSql( """ -SELECT CASE - WHEN [l].[Eradicated] = CAST(1 AS bit) AND [l].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [IsEradicated] -FROM [Factions] AS [f] -INNER JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +ORDER BY COALESCE([w].[SynergyWithId], 0), [w].[Id] """); } - public override async Task Accessing_reference_navigation_collection_composition_generates_single_query(bool async) + public override async Task GetValueOrDefault_with_argument(bool async) { - await base.Accessing_reference_navigation_collection_composition_generates_single_query(async); + await base.GetValueOrDefault_with_argument(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s].[IsAutomatic], [s].[Name], [s].[Id0] -FROM [Gears] AS [g] -LEFT JOIN ( - SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] - FROM [Weapons] AS [w] - LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [g].[FullName] = [s].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], [w].[Id]) = 1 """); } - public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) + public override async Task GetValueOrDefault_with_argument_complex(bool async) { - await base.Reference_include_chain_loads_correctly_when_middle_is_null(async); + await base.GetValueOrDefault_with_argument_complex(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s0].[Id], [s0].[Banner], [s0].[Banner5], [s0].[InternalNumber], [s0].[Name] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] -ORDER BY [t].[Note] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE COALESCE([w].[SynergyWithId], CAST(LEN([w].[Name]) AS int) + 42) > 10 """); } - public override async Task Accessing_property_of_optional_navigation_in_child_projection_works(bool async) + public override async Task Filter_with_complex_predicate_containing_subquery(bool async) { - await base.Accessing_property_of_optional_navigation_in_child_projection_works(async); + await base.Filter_with_complex_predicate_containing_subquery(async); AssertSql( """ -SELECT CASE - WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Nickname], [s1].[Id], [s1].[SquadId] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN ( - SELECT [s0].[Nickname], [w].[Id], [s0].[SquadId], [w].[OwnerFullName] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[FullName] <> N'Dom' AND EXISTS ( + SELECT 1 FROM [Weapons] AS [w] - LEFT JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] - FROM [Gears] AS [g0] - ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] -) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] -ORDER BY [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[Nickname] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit)) """); } - public override async Task Collection_navigation_ofType_filter_works(bool async) + public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( + bool async) { - await base.Collection_navigation_ofType_filter_works(async); + await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE [c].[Name] = [g].[CityOfBirthName] AND [o].[Nickname] IS NOT NULL AND [g].[Nickname] = N'Marcus') +SELECT [g].[Nickname], ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[IsAutomatic] = CAST(1 AS bit) + ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] +FROM [Gears] AS [g] +WHERE [g].[Nickname] <> N'Dom' """); } - public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) { - await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); AssertSql( """ -@prm_Inner_Nickname='Marcus' (Size = 450) - -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM ( - SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - WHERE [g].[Nickname] <> @prm_Inner_Nickname -) AS [s] -ORDER BY [s].[FullName] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE SUBSTRING([t].[Note], 0 + 1, [s].[SquadId]) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s].[SquadId] IS NULL) AND [t].[GearNickName] IS NULL) """); } - public override async Task Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(bool async) + public override async Task + Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) { - await base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async); + await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( + async); AssertSql( """ -@squadId='1' - -SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] -FROM ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] - LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] - INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] - WHERE [s].[Id] IN ( - SELECT [s0].[Id] - FROM [Squads] AS [s0] - WHERE [s0].[Id] = @squadId - ) - UNION ALL - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' - END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] - INNER JOIN [Squads] AS [s1] ON [g0].[SquadId] = [s1].[Id] - WHERE [s1].[Id] IN ( - SELECT [s2].[Id] - FROM [Squads] AS [s2] - WHERE [s2].[Id] = @squadId - ) -) AS [u] -ORDER BY [u].[FullName] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] +WHERE SUBSTRING([t].[Note], 0 + 1, CAST(LEN([s0].[Name]) AS int)) = [t].[GearNickName] OR (([t].[Note] IS NULL OR [s0].[Name] IS NULL) AND [t].[GearNickName] IS NULL) """); } - public override async Task Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(bool async) + public override async Task OfTypeNav1(bool async) { - await base.Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(async); + await base.OfTypeNav1(async); AssertSql( """ -@gearId='1' +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) +"""); + } -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE EXISTS ( - SELECT 1 - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[SquadId] = @gearId AND [g].[SquadId] = @gearId) + public override async Task OfTypeNav2(bool async) + { + await base.OfTypeNav2(async); + + AssertSql( + """ +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([c].[Location] <> 'Bar' OR [c].[Location] IS NULL) """); } - public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(bool async) + public override async Task OfTypeNav3(bool async) { - await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(async); + await base.OfTypeNav3(async); AssertSql( """ -@entity_equality_prm_Inner_Squad_Id='1' (Nullable = true) - -SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] -FROM ( - SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] - INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] - WHERE [s].[Id] = @entity_equality_prm_Inner_Squad_Id -) AS [s1] -INNER JOIN [Squads] AS [s0] ON [s1].[SquadId] = [s0].[Id] -WHERE [s0].[Id] = @entity_equality_prm_Inner_Squad_Id -ORDER BY [s1].[FullName] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] +LEFT JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] AND [g].[SquadId] = [t0].[GearSquadId] +WHERE ([t].[Note] <> N'Foo' OR [t].[Note] IS NULL) AND [o].[Nickname] IS NOT NULL AND ([t0].[Note] <> N'Bar' OR [t0].[Note] IS NULL) """); } - public override async Task Complex_GroupBy_after_set_operator(bool async) + public override async Task Nav_rewrite_Distinct_with_convert() { - await base.Complex_GroupBy_after_set_operator(async); + await base.Nav_rewrite_Distinct_with_convert(); - AssertSql( - """ -SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] -FROM ( - SELECT [c].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] - FROM [Gears] AS [g] - LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] - UNION ALL - SELECT [c0].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] -) AS [u] -GROUP BY [u].[Name], [u].[Count] -"""); + AssertSql(); } - public override async Task Complex_GroupBy_after_set_operator_using_result_selector(bool async) + public override async Task Nav_rewrite_Distinct_with_convert_anonymous() { - await base.Complex_GroupBy_after_set_operator_using_result_selector(async); + await base.Nav_rewrite_Distinct_with_convert_anonymous(); - AssertSql( - """ -SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] -FROM ( - SELECT [c].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w] - WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] - FROM [Gears] AS [g] - LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] - UNION ALL - SELECT [c0].[Name], ( - SELECT COUNT(*) - FROM [Weapons] AS [w0] - WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] -) AS [u] -GROUP BY [u].[Name], [u].[Count] -"""); + AssertSql(); } - public override async Task Left_join_with_GroupBy_with_composite_group_key(bool async) + public override async Task Nav_rewrite_with_convert1(bool async) { - await base.Left_join_with_GroupBy_with_composite_group_key(async); + await base.Nav_rewrite_with_convert1(async); AssertSql( """ -SELECT [g].[CityOfBirthName], [g].[HasSoulPatch] -FROM [Gears] AS [g] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] -GROUP BY [g].[CityOfBirthName], [g].[HasSoulPatch] +SELECT [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE [c].[Name] <> N'Foo' OR [c].[Name] IS NULL """); } - public override async Task GroupBy_with_boolean_grouping_key(bool async) + public override async Task Nav_rewrite_with_convert2(bool async) { - await base.GroupBy_with_boolean_grouping_key(async); + await base.Nav_rewrite_with_convert2(async); AssertSql( """ -SELECT [s].[CityOfBirthName], [s].[HasSoulPatch], [s].[IsMarcus], COUNT(*) AS [Count] -FROM ( - SELECT [g].[CityOfBirthName], [g].[HasSoulPatch], CASE - WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [IsMarcus] - FROM [Gears] AS [g] -) AS [s] -GROUP BY [s].[CityOfBirthName], [s].[HasSoulPatch], [s].[IsMarcus] +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] +LEFT JOIN ( + SELECT [l0].[Name] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([s].[Name] <> N'Bar' OR [s].[Name] IS NULL) """); } - public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) + public override async Task Nav_rewrite_with_convert3(bool async) { - await base.GroupBy_with_boolean_groupin_key_thru_navigation_access(async); + await base.Nav_rewrite_with_convert3(async); AssertSql( """ -SELECT [s].[HasSoulPatch], LOWER([s0].[Name]) AS [Name] -FROM [Tags] AS [t] +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] -GROUP BY [s].[HasSoulPatch], [s0].[Name] + SELECT [l0].[Name] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE ([c].[Name] <> N'Foo' OR [c].[Name] IS NULL) AND ([s].[Name] <> N'Bar' OR [s].[Name] IS NULL) """); } - public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) + public override async Task Where_contains_on_navigation_with_composite_keys(bool async) { - await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); + await base.Where_contains_on_navigation_with_composite_keys(async); AssertSql( """ -SELECT [c].[Name] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator] FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -GROUP BY [c].[Name] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE EXISTS ( + SELECT 1 + FROM [Cities] AS [c] + WHERE EXISTS ( + SELECT 1 + FROM [Gears] AS [g0] + WHERE [c].[Name] = [g0].[CityOfBirthName] AND [g0].[Nickname] = [g].[Nickname] AND [g0].[SquadId] = [g].[SquadId])) """); } - public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Include_with_complex_order_by(bool async) { - await base.Group_by_on_StartsWith_with_null_parameter_as_argument(async); + await base.Include_with_complex_order_by(async); AssertSql( """ -SELECT [s].[Key] -FROM ( - SELECT CAST(0 AS bit) AS [Key] - FROM [Gears] AS [g] -) AS [s] -GROUP BY [s].[Key] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] +ORDER BY ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName] AND [w].[Name] LIKE N'%Gnasher%'), [g].[Nickname], [g].[SquadId] """); } - public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(bool async) { - await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); + await base.Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -GROUP BY [g].[FullName] -HAVING 0 = 1 +@p='25' + +SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId] +FROM ( + SELECT TOP(@p) [g].[FullName] + FROM [Gears] AS [g] +) AS [s] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] + FROM [Weapons] AS [w] + ) AS [w0] + WHERE [w0].[row] <= 1 +) AS [w1] ON [s].[FullName] = [w1].[OwnerFullName] """); } - public override async Task Select_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Bool_projection_from_subquery_treated_appropriately_in_where(bool async) { - await base.Select_StartsWith_with_null_parameter_as_argument(async); + await base.Bool_projection_from_subquery_treated_appropriately_in_where(async); AssertSql( """ -SELECT CAST(0 AS bit) -FROM [Gears] AS [g] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE ( + SELECT TOP(1) [g].[HasSoulPatch] + FROM [Gears] AS [g] + ORDER BY [g].[Nickname], [g].[SquadId]) = CAST(1 AS bit) """); } - public override async Task Select_null_parameter_is_not_null(bool async) + public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) { - await base.Select_null_parameter_is_not_null(async); + await base.DateTimeOffset_Contains_Less_than_Greater_than(async); AssertSql( """ -@p='False' +@start='1902-01-01T10:00:00.1234567+01:30' +@end='1902-01-03T10:00:00.1234567+01:30' +@dates='["1902-01-02T10:00:00.1234567+01:30"]' (Size = 4000) -SELECT @p -FROM [Gears] AS [g] +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE @start <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset) AND [m].[Timeline] < @end AND [m].[Timeline] IN ( + SELECT [d].[value] + FROM OPENJSON(@dates) WITH ([value] datetimeoffset '$') AS [d] +) """); } - public override async Task Where_null_parameter_is_not_null(bool async) + public override Task DateTimeOffsetNow_minus_timespan(bool async) + => AssertTranslationFailed(() => base.DateTimeOffsetNow_minus_timespan(async)); + + public override async Task Navigation_inside_interpolated_string_expanded(bool async) { - await base.Where_null_parameter_is_not_null(async); + await base.Navigation_inside_interpolated_string_expanded(async); AssertSql( """ -@p='False' - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 @p = CAST(1 AS bit) +SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [w0].[OwnerFullName] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] """); } - public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bool async) + public override async Task Left_join_projection_using_coalesce_tracking(bool async) { - await base.OrderBy_StartsWith_with_null_parameter_as_argument(async); + await base.Left_join_projection_using_coalesce_tracking(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE 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] -ORDER BY [g].[Nickname] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] """); } - public override async Task OrderBy_Contains_empty_list(bool async) + public override async Task Left_join_projection_using_conditional_tracking(bool async) { - await base.OrderBy_Contains_empty_list(async); + await base.Left_join_projection_using_conditional_tracking(async); AssertSql( """ -@ids='[]' (Size = 4000) - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE +SELECT CASE + WHEN [s].[Nickname] IS NULL OR [s].[SquadId] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -ORDER BY CASE - WHEN [g].[SquadId] IN ( - SELECT [i].[value] - FROM OPENJSON(@ids) WITH ([value] int '$') AS [i] - ) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] ON [g].[LeaderNickname] = [s].[Nickname] """); } - public override async Task Where_with_enum_flags_parameter(bool async) + public override async Task Project_collection_navigation_nested_with_take_composite_key(bool async) { - await base.Where_with_enum_flags_parameter(async); + await base.Project_collection_navigation_nested_with_take_composite_key(async); AssertSql( """ -@rank='1' (Nullable = true) - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & @rank = @rank -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -""", - // - """ -@rank='2' (Nullable = true) - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] | @rank <> @rank -""", - // - """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 0 = 1 +SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], CASE + 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] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] + FROM ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator], ROW_NUMBER() OVER(PARTITION BY [g0].[LeaderNickname], [g0].[LeaderSquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) AS [row] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + ) AS [s0] + WHERE [s0].[row] <= 50 +) AS [s1] ON ([s].[Nickname] = [s1].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s1].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s1].[LeaderSquadId] +WHERE [s].[Discriminator] = N'Officer' +ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Nickname] """); } - public override async Task FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(bool async) + public override async Task Project_collection_navigation_nested_composite_key(bool async) { - await base.FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(async); + await base.Project_collection_navigation_nested_composite_key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] -WHERE [c].[Name] = ( - SELECT TOP(1) [c0].[Name] - FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] - ORDER BY [g0].[Nickname]) OR ([c].[Name] IS NULL AND ( - SELECT TOP(1) [c0].[Name] +SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Nickname], [s0].[SquadId], [s0].[AssignedCityName], [s0].[CityOfBirthName], [s0].[FullName], [s0].[HasSoulPatch], [s0].[LeaderNickname], [s0].[LeaderSquadId], [s0].[Rank], [s0].[Discriminator] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], CASE + 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] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] FROM [Gears] AS [g0] - INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] - ORDER BY [g0].[Nickname]) IS NULL) + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s0] ON ([s].[Nickname] = [s0].[LeaderNickname] OR ([s].[Nickname] IS NULL AND [s0].[LeaderNickname] IS NULL)) AND [s].[SquadId] = [s0].[LeaderSquadId] +WHERE [s].[Discriminator] = N'Officer' +ORDER BY [t].[Id], [s].[Nickname], [s].[SquadId], [s0].[Nickname] """); } - public override async Task Bitwise_operation_with_non_null_parameter_optimizes_null_checks(bool async) + public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) { - await base.Bitwise_operation_with_non_null_parameter_optimizes_null_checks(async); + await base.Null_checks_in_correlated_predicate_are_correctly_translated(async); AssertSql( """ -@ranks='134' +SELECT [t].[Id], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] AND [t].[Note] IS NOT NULL +ORDER BY [t].[Id], [s].[Nickname] +"""); + } -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [g].[Rank] & @ranks <> 0 -""", - // - """ -@ranks='134' + public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(bool async) + { + await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(async); -SELECT ~CAST(([g].[Rank] | @ranks) ^ @ranks AS bit) -FROM [Gears] AS [g] -""", - // + AssertSql( """ -@ranks='134' +@isAutomatic='True' -SELECT ~CAST(([g].[Rank] | [g].[Rank] | @ranks | [g].[Rank] | @ranks) ^ @ranks AS bit) +SELECT [g].[Nickname], [g].[FullName], CASE + WHEN [w0].[Id] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Collection] FROM [Gears] AS [g] +LEFT JOIN ( + SELECT [w].[Id], [w].[OwnerFullName] + FROM [Weapons] AS [w] + WHERE [w].[IsAutomatic] = @isAutomatic +) AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] """); } - public override async Task Bitwise_operation_with_null_arguments(bool async) + public override async Task Join_with_inner_being_a_subquery_projecting_single_property(bool async) { - await base.Bitwise_operation_with_null_arguments(async); + await base.Join_with_inner_being_a_subquery_projecting_single_property(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] IS NULL -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -""", - // - """ -@prm='2' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @prm <> 0 OR [w].[AmmunitionType] IS NULL -""", - // - """ -@prm='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -WHERE [w].[AmmunitionType] & @prm = @prm +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +INNER JOIN ( + SELECT [g0].[Nickname] + FROM [Gears] AS [g0] +) AS [s] ON [g].[Nickname] = [s].[Nickname] """); } - public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) + public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) { - await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); + await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); AssertSql( """ -@prm='True' - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE 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 [g].[HasSoulPatch] <> @prm -""", - // - """ -@prm='False' +INNER JOIN ( + SELECT [g0].[Nickname] + FROM [Gears] AS [g0] +) AS [s] ON [g].[Nickname] = [s].[Nickname] +"""); + } -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' + public override async Task Navigation_based_on_complex_expression1(bool async) + { + await base.Navigation_based_on_complex_expression1(async); + + AssertSql( + """ +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' END AS [Discriminator] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [g].[HasSoulPatch] <> @prm +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE CASE + WHEN [l].[Id] IS NOT NULL AND [s].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task Cast_OfType_works_correctly(bool async) + public override async Task Navigation_based_on_complex_expression2(bool async) { - await base.Cast_OfType_works_correctly(async); + await base.Navigation_based_on_complex_expression2(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE [o].[Nickname] IS NOT NULL +SELECT [f].[Id], [f].[CapitalName], [f].[Name], [f].[ServerAddress], [l].[CommanderName], [l].[Eradicated], CASE + WHEN [l].[Id] IS NOT NULL THEN N'LocustHorde' +END AS [Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE [l].[Id] IS NOT NULL AND [s].[Name] IS NOT NULL """); } - public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) + public override async Task Navigation_based_on_complex_expression3(bool async) { - await base.Join_inner_source_custom_projection_followed_by_filter(async); + await base.Navigation_based_on_complex_expression3(async); AssertSql( """ -SELECT CASE - WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) -END AS [IsEradicated], [s].[CommanderName], [s].[Name] -FROM [LocustLeaders] AS [l] -INNER JOIN ( - SELECT [f].[Name], [l0].[CommanderName] - FROM [Factions] AS [f] - LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] - WHERE [l0].[Id] IS NOT NULL -) AS [s] ON [l].[Name] = [s].[CommanderName] -WHERE CASE - WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) -END = CAST(0 AS bit) OR CASE - WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) -END IS NULL +SELECT [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +LEFT JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId] + FROM [LocustLeaders] AS [l0] + INNER JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] +) AS [s] ON [l].[CommanderName] = [s].[Name] +WHERE [l].[Id] IS NOT NULL """); } - public override async Task Byte_array_contains_literal(bool async) + public override async Task Navigation_based_on_complex_expression4(bool async) { - await base.Byte_array_contains_literal(async); + await base.Navigation_based_on_complex_expression4(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CHARINDEX(0x01, [s].[Banner]) > 0 +SELECT CASE + WHEN [l].[Id] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +CROSS JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE + WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator] + FROM [LocustLeaders] AS [l0] + LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] + WHERE [l1].[Name] IS NOT NULL +) AS [s] +LEFT JOIN ( + SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId] + FROM [LocustLeaders] AS [l2] + INNER JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] +) AS [s0] ON [l].[CommanderName] = [s0].[Name] """); } - public override async Task Byte_array_filter_by_length_literal(bool async) + public override async Task Navigation_based_on_complex_expression5(bool async) { - await base.Byte_array_filter_by_length_literal(async); + await base.Navigation_based_on_complex_expression5(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = 2 +SELECT [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +CROSS JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE + WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator] + FROM [LocustLeaders] AS [l0] + LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] + WHERE [l1].[Name] IS NOT NULL +) AS [s] +LEFT JOIN ( + SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId] + FROM [LocustLeaders] AS [l2] + INNER JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] +) AS [s0] ON [l].[CommanderName] = [s0].[Name] +WHERE [l].[Id] IS NOT NULL """); } - public override async Task Byte_array_filter_by_length_parameter(bool async) + public override async Task Navigation_based_on_complex_expression6(bool async) { - await base.Byte_array_filter_by_length_parameter(async); + await base.Navigation_based_on_complex_expression6(async); AssertSql( """ -@p='2' - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = @p +SELECT CASE + WHEN [s0].[Name] = N'Queen Myrrah' AND [s0].[Name] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s].[Name], [s].[LocustHordeId], [s].[ThreatLevel], [s].[ThreatLevelByte], [s].[ThreatLevelNullableByte], [s].[DefeatedByNickname], [s].[DefeatedBySquadId], [s].[HighCommandId], [s].[Discriminator] +FROM [Factions] AS [f] +LEFT JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] +CROSS JOIN ( + SELECT [l0].[Name], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l1].[DefeatedByNickname], [l1].[DefeatedBySquadId], [l1].[HighCommandId], CASE + WHEN [l1].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator] + FROM [LocustLeaders] AS [l0] + LEFT JOIN [LocustCommanders] AS [l1] ON [l0].[Name] = [l1].[Name] + WHERE [l1].[Name] IS NOT NULL +) AS [s] +LEFT JOIN ( + SELECT [l2].[Name], [l2].[LocustHordeId], [l2].[ThreatLevel], [l2].[ThreatLevelByte], [l2].[ThreatLevelNullableByte], [l3].[DefeatedByNickname], [l3].[DefeatedBySquadId], [l3].[HighCommandId] + FROM [LocustLeaders] AS [l2] + INNER JOIN [LocustCommanders] AS [l3] ON [l2].[Name] = [l3].[Name] +) AS [s0] ON [l].[CommanderName] = [s0].[Name] +WHERE [l].[Id] IS NOT NULL """); } - public override void Byte_array_filter_by_length_parameter_compiled() + public override async Task Select_as_operator(bool async) { - base.Byte_array_filter_by_length_parameter_compiled(); + await base.Select_as_operator(async); AssertSql( """ -@byteArrayParam='0x2A80' (Size = 8000) - -SELECT COUNT(*) -FROM [Squads] AS [s] -WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@byteArrayParam) AS int) +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] """); } - public override async Task Byte_array_contains_parameter(bool async) + public override async Task Select_datetimeoffset_comparison_in_projection(bool async) { - await base.Byte_array_contains_parameter(async); + await base.Select_datetimeoffset_comparison_in_projection(async); AssertSql( """ -@someByte='1' (Size = 1) - -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CHARINDEX(CAST(@someByte AS varbinary(max)), [s].[Banner]) > 0 +SELECT CASE + WHEN [m].[Timeline] > SYSDATETIMEOFFSET() THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Missions] AS [m] """); } - public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) + public override async Task OfType_in_subquery_works(bool async) { - await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); + await base.OfType_in_subquery_works(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE DATALENGTH([s].[Banner5]) = 5 +SELECT [s].[Name], [s].[Location], [s].[Nation] +FROM [Gears] AS [g] +INNER JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +INNER JOIN ( + SELECT [c].[Name], [c].[Location], [c].[Nation], [g0].[LeaderNickname], [g0].[LeaderSquadId] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] + WHERE [o0].[Nickname] IS NOT NULL +) AS [s] ON [g].[Nickname] = [s].[LeaderNickname] AND [g].[SquadId] = [s].[LeaderSquadId] """); } - public override async Task Conditional_expression_with_test_being_simplified_to_constant_simple(bool isAsync) + public override async Task Nullable_bool_comparison_is_translated_to_server(bool async) { - await base.Conditional_expression_with_test_being_simplified_to_constant_simple(isAsync); + await base.Nullable_bool_comparison_is_translated_to_server(async); AssertSql( """ -@prm='True' - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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].[HasSoulPatch] = @prm THEN CAST(1 AS bit) +SELECT CASE + WHEN [l].[Eradicated] = CAST(1 AS bit) AND [l].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +END AS [IsEradicated] +FROM [Factions] AS [f] +INNER JOIN [LocustHordes] AS [l] ON [f].[Id] = [l].[Id] """); } - public override async Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) + public override async Task Accessing_reference_navigation_collection_composition_generates_single_query(bool async) { - await base.Conditional_expression_with_test_being_simplified_to_constant_complex(isAsync); + await base.Accessing_reference_navigation_collection_composition_generates_single_query(async); AssertSql( """ -@prm='True' -@prm2='Marcus' Lancer' (Size = 4000) - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [s].[IsAutomatic], [s].[Name], [s].[Id0] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE CASE - WHEN [g].[HasSoulPatch] = @prm AND ( - SELECT TOP(1) [w].[Name] - FROM [Weapons] AS [w] - WHERE [w].[Id] = [g].[SquadId]) = @prm2 THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) +LEFT JOIN ( + SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +) AS [s] ON [g].[FullName] = [s].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id] """); } - public override async Task OrderBy_bool_coming_from_optional_navigation(bool async) + public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) { - await base.OrderBy_bool_coming_from_optional_navigation(async); + await base.Reference_include_chain_loads_correctly_when_middle_is_null(async); AssertSql( """ -SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -ORDER BY [w0].[IsAutomatic] +SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator], [s0].[Id], [s0].[Banner], [s0].[Banner5], [s0].[InternalNumber], [s0].[Name] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] +ORDER BY [t].[Note] """); } - public override async Task DateTimeOffset_Date_returns_datetime(bool async) + public override async Task Accessing_property_of_optional_navigation_in_child_projection_works(bool async) { - await base.DateTimeOffset_Date_returns_datetime(async); + await base.Accessing_property_of_optional_navigation_in_child_projection_works(async); AssertSql( """ -@dateTimeOffset_Date='0002-03-01T00:00:00.0000000' - -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CONVERT(date, [m].[Timeline]) >= @dateTimeOffset_Date +SELECT CASE + WHEN [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Nickname], [s1].[Id], [s1].[SquadId] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[FullName] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN ( + SELECT [s0].[Nickname], [w].[Id], [s0].[SquadId], [w].[OwnerFullName] + FROM [Weapons] AS [w] + LEFT JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] + FROM [Gears] AS [g0] + ) AS [s0] ON [w].[OwnerFullName] = [s0].[FullName] +) AS [s1] ON [s].[FullName] = [s1].[OwnerFullName] +ORDER BY [t].[Note], [t].[Id], [s].[Nickname], [s].[SquadId], [s1].[Id], [s1].[Nickname] """); } - public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async) + public override async Task Collection_navigation_ofType_filter_works(bool async) { - await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async); + await base.Collection_navigation_ofType_filter_works(async); AssertSql( """ -SELECT [g].[FullName] -FROM [Gears] AS [g] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE EXISTS ( + SELECT 1 + FROM [Gears] AS [g] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] + WHERE [c].[Name] = [g].[CityOfBirthName] AND [o].[Nickname] IS NOT NULL AND [g].[Nickname] = N'Marcus') """); } - public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async) + public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) { - await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async); + await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); AssertSql( """ -SELECT [g].[CityOfBirthName] -FROM [Gears] AS [g] +@prm_Inner_Nickname='Marcus' (Size = 450) + +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM ( + SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[Nickname] <> @prm_Inner_Nickname +) AS [s] +ORDER BY [s].[FullName] """); } - public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async) + public override async Task Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(bool async) { - await base.Projecting_required_string_column_compared_to_null_parameter(async); + await base.Query_reusing_parameter_with_inner_query_doesnt_declare_duplicate_parameter(async); AssertSql( """ -SELECT CAST(0 AS bit) -FROM [Gears] AS [g] +@squadId='1' + +SELECT [u].[Nickname], [u].[SquadId], [u].[AssignedCityName], [u].[CityOfBirthName], [u].[FullName], [u].[HasSoulPatch], [u].[LeaderNickname], [u].[LeaderSquadId], [u].[Rank], [u].[Discriminator] +FROM ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] + INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] + WHERE [s].[Id] IN ( + SELECT [s0].[Id] + FROM [Squads] AS [s0] + WHERE [s0].[Id] = @squadId + ) + UNION ALL + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + INNER JOIN [Squads] AS [s1] ON [g0].[SquadId] = [s1].[Id] + WHERE [s1].[Id] IN ( + SELECT [s2].[Id] + FROM [Squads] AS [s2] + WHERE [s2].[Id] = @squadId + ) +) AS [u] +ORDER BY [u].[FullName] """); } - public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) + public override async Task Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(bool async) { - await base.Byte_array_filter_by_SequenceEqual(isAsync); + await base.Query_reusing_parameter_with_inner_query_expression_doesnt_declare_duplicate_parameter(async); AssertSql( """ -@byteArrayParam='0x0405060708' (Size = 5) +@gearId='1' SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] -WHERE [s].[Banner5] = @byteArrayParam +WHERE EXISTS ( + SELECT 1 + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[SquadId] = @gearId AND [g].[SquadId] = @gearId) """); } - public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) + public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(bool async) { - await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); + await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(async); AssertSql( """ -SELECT [w0].[Key] -FROM ( - SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [Key] - FROM [Weapons] AS [w] -) AS [w0] -GROUP BY [w0].[Key] -"""); - } - - public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) - { - await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); +@entity_equality_prm_Inner_Squad_Id='1' (Nullable = true) - AssertSql( - """ -SELECT CASE - WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END -FROM [Weapons] AS [w] -GROUP BY [w].[SynergyWithId] +SELECT [s1].[Nickname], [s1].[SquadId], [s1].[AssignedCityName], [s1].[CityOfBirthName], [s1].[FullName], [s1].[HasSoulPatch], [s1].[LeaderNickname], [s1].[LeaderSquadId], [s1].[Rank], [s1].[Discriminator] +FROM ( + SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] + INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] + WHERE [s].[Id] = @entity_equality_prm_Inner_Squad_Id +) AS [s1] +INNER JOIN [Squads] AS [s0] ON [s1].[SquadId] = [s0].[Id] +WHERE [s0].[Id] = @entity_equality_prm_Inner_Squad_Id +ORDER BY [s1].[FullName] """); } - public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) + public override async Task Complex_GroupBy_after_set_operator(bool async) { - await base.Checked_context_with_cast_does_not_fail(isAsync); + await base.Complex_GroupBy_after_set_operator(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE CAST([l].[ThreatLevel] AS tinyint) >= CAST(5 AS tinyint) +SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] +FROM ( + SELECT [c].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g] + LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] + UNION ALL + SELECT [c0].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] +) AS [u] +GROUP BY [u].[Name], [u].[Count] """); } - public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) + public override async Task Complex_GroupBy_after_set_operator_using_result_selector(bool async) { - await base.Checked_context_with_addition_does_not_fail(isAsync); + await base.Complex_GroupBy_after_set_operator_using_result_selector(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE CAST([l].[ThreatLevel] AS bigint) <= CAST(5 AS bigint) + CAST([l].[ThreatLevel] AS bigint) +SELECT [u].[Name], [u].[Count], COALESCE(SUM([u].[Count]), 0) AS [Sum] +FROM ( + SELECT [c].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w] + WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g] + LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] + UNION ALL + SELECT [c0].[Name], ( + SELECT COUNT(*) + FROM [Weapons] AS [w0] + WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] +) AS [u] +GROUP BY [u].[Name], [u].[Count] """); } - public override async Task TimeSpan_Hours(bool async) + public override async Task Left_join_with_GroupBy_with_composite_group_key(bool async) { - await base.TimeSpan_Hours(async); + await base.Left_join_with_GroupBy_with_composite_group_key(async); AssertSql( """ -SELECT DATEPART(hour, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [g].[CityOfBirthName], [g].[HasSoulPatch] +FROM [Gears] AS [g] +INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] +GROUP BY [g].[CityOfBirthName], [g].[HasSoulPatch] """); } - public override async Task TimeSpan_Minutes(bool async) + public override async Task GroupBy_with_boolean_grouping_key(bool async) { - await base.TimeSpan_Minutes(async); + await base.GroupBy_with_boolean_grouping_key(async); AssertSql( """ -SELECT DATEPART(minute, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [s].[CityOfBirthName], [s].[HasSoulPatch], [s].[IsMarcus], COUNT(*) AS [Count] +FROM ( + SELECT [g].[CityOfBirthName], [g].[HasSoulPatch], CASE + WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [IsMarcus] + FROM [Gears] AS [g] +) AS [s] +GROUP BY [s].[CityOfBirthName], [s].[HasSoulPatch], [s].[IsMarcus] """); } - public override async Task TimeSpan_Seconds(bool async) + public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) { - await base.TimeSpan_Seconds(async); + await base.GroupBy_with_boolean_groupin_key_thru_navigation_access(async); AssertSql( """ -SELECT DATEPART(second, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [s].[HasSoulPatch], LOWER([s0].[Name]) AS [Name] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +LEFT JOIN [Squads] AS [s0] ON [s].[SquadId] = [s0].[Id] +GROUP BY [s].[HasSoulPatch], [s0].[Name] """); } - public override async Task TimeSpan_Milliseconds(bool async) + public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) { - await base.TimeSpan_Milliseconds(async); + await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); AssertSql( """ -SELECT DATEPART(millisecond, [m].[Duration]) -FROM [Missions] AS [m] +SELECT [c].[Name] +FROM [Gears] AS [g] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +GROUP BY [c].[Name] """); } - public override async Task Where_TimeSpan_Hours(bool async) + public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Where_TimeSpan_Hours(async); + await base.Group_by_on_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Duration]) = 1 +SELECT [s].[Key] +FROM ( + SELECT CAST(0 AS bit) AS [Key] + FROM [Gears] AS [g] +) AS [s] +GROUP BY [s].[Key] """); } - public override async Task Where_TimeSpan_Minutes(bool async) + public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Where_TimeSpan_Minutes(async); + await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Duration]) = 2 +SELECT [g].[FullName] +FROM [Gears] AS [g] +GROUP BY [g].[FullName] +HAVING 0 = 1 """); } - public override async Task Where_TimeSpan_Seconds(bool async) + public override async Task Select_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Where_TimeSpan_Seconds(async); + await base.Select_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Duration]) = 3 +SELECT CAST(0 AS bit) +FROM [Gears] AS [g] """); } - public override async Task Where_TimeSpan_Milliseconds(bool async) + public override async Task Select_null_parameter_is_not_null(bool async) { - await base.Where_TimeSpan_Milliseconds(async); + await base.Select_null_parameter_is_not_null(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Duration]) = 456 +@p='False' + +SELECT @p +FROM [Gears] AS [g] """); } - public override async Task Contains_on_collection_of_byte_subquery(bool async) + public override async Task Where_null_parameter_is_not_null(bool async) { - await base.Contains_on_collection_of_byte_subquery(async); + await base.Where_null_parameter_is_not_null(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +@p='False' + +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE [l].[ThreatLevelByte] IN ( - SELECT [l1].[ThreatLevelByte] - FROM [LocustLeaders] AS [l1] -) +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE @p = CAST(1 AS bit) """); } - public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) + public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bool async) { - await base.Contains_on_collection_of_nullable_byte_subquery(async); + await base.OrderBy_StartsWith_with_null_parameter_as_argument(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l1] - WHERE [l1].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l1].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +ORDER BY [g].[Nickname] """); } - public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) + public override async Task OrderBy_Contains_empty_list(bool async) { - await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); + await base.OrderBy_Contains_empty_list(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +@ids='[]' (Size = 4000) + +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l1] - WHERE [l1].[ThreatLevelNullableByte] IS NULL) +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +ORDER BY CASE + WHEN [g].[SquadId] IN ( + SELECT [i].[value] + FROM OPENJSON(@ids) WITH ([value] int '$') AS [i] + ) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END """); } - public override async Task Contains_on_collection_of_nullable_byte_subquery_null_parameter(bool async) + public override async Task Where_with_enum_flags_parameter(bool async) { - await base.Contains_on_collection_of_nullable_byte_subquery_null_parameter(async); + await base.Where_with_enum_flags_parameter(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l1] - WHERE [l1].[ThreatLevelNullableByte] IS NULL) -"""); - } +@rank='1' (Nullable = true) - public override async Task Contains_on_byte_array_property_using_byte_column(bool async) - { - await base.Contains_on_byte_array_property_using_byte_column(async); +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[Rank] & @rank = @rank +""", + // + """ +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +""", + // + """ +@rank='2' (Nullable = true) - AssertSql( +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[Rank] | @rank <> @rank +""", + // """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator] -FROM [Squads] AS [s] -CROSS JOIN ( - SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' - END AS [Discriminator] - FROM [LocustLeaders] AS [l] - LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -) AS [s0] -WHERE CHARINDEX(CAST([s0].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 0 = 1 """); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( - bool async) + public override async Task FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(bool async) { - await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); + await base.FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(async); AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -CROSS APPLY ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [l].[ThreatLevelByte] IN ( - SELECT [l0].[ThreatLevelByte] - FROM [LocustLeaders] AS [l0] - ) -) AS [s] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] +WHERE [c].[Name] = ( + SELECT TOP(1) [c0].[Name] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] + ORDER BY [g0].[Nickname]) OR ([c].[Name] IS NULL AND ( + SELECT TOP(1) [c0].[Name] + FROM [Gears] AS [g0] + INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] + ORDER BY [g0].[Nickname]) IS NULL) """); } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( - bool async) + public override async Task Bitwise_operation_with_non_null_parameter_optimizes_null_checks(bool async) { - await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); + await base.Bitwise_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -CROSS APPLY ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 [l].[ThreatLevelByte] NOT IN ( - SELECT [l0].[ThreatLevelByte] - FROM [LocustLeaders] AS [l0] - ) -) AS [s] -"""); - } +@ranks='134' - public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) - { - await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async); +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[Rank] & @ranks <> 0 +""", + // + """ +@ranks='134' - AssertSql( +SELECT ~CAST(([g].[Rank] | @ranks) ^ @ranks AS bit) +FROM [Gears] AS [g] +""", + // """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -CROSS APPLY ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) -) AS [s] +@ranks='134' + +SELECT ~CAST(([g].[Rank] | [g].[Rank] | @ranks | [g].[Rank] | @ranks) ^ @ranks AS bit) +FROM [Gears] AS [g] """); } - public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) + public override async Task Bitwise_operation_with_null_arguments(bool async) { - await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async); + await base.Bitwise_operation_with_null_arguments(async); AssertSql( """ -SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [LocustLeaders] AS [l] -CROSS APPLY ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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 NOT EXISTS ( - SELECT 1 - FROM [LocustLeaders] AS [l0] - WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) -) AS [s] -"""); - } - - public override async Task Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) - { - await base.Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(async); +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] IS NULL +""", + // + """ +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +""", + // + """ +@prm='2' (Nullable = true) - AssertSql( +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE [w].[AmmunitionType] & @prm <> 0 OR [w].[AmmunitionType] IS NULL +""", + // """ @prm='1' (Nullable = true) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] -WHERE @prm = [w].[AmmunitionType] +WHERE [w].[AmmunitionType] & @prm = @prm """); } - public override async Task Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) + public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) { - await base.Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(async); + await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( """ -@prm='133' +@prm='True' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE 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 @prm & [g].[Rank] = [g].[Rank] +WHERE [g].[HasSoulPatch] <> @prm +""", + // + """ +@prm='False' + +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [g].[HasSoulPatch] <> @prm """); } - public override async Task Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(bool async) + public override async Task Cast_OfType_works_correctly(bool async) { - await base.Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(async); + await base.Cast_OfType_works_correctly(async); AssertSql( """ -@prm='5' - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator] +SELECT [g].[FullName] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -WHERE @prm & CAST([g].[Rank] AS int) = CAST([g].[Rank] AS int) +WHERE [o].[Nickname] IS NOT NULL """); } - public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) + public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) { - await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); + await base.Join_inner_source_custom_projection_followed_by_filter(async); AssertSql( """ -@p='1' - -SELECT TOP(@p) [g].[Rank] & 1 -FROM [Gears] AS [g] -ORDER BY [g].[Nickname] +SELECT CASE + WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) +END AS [IsEradicated], [s].[CommanderName], [s].[Name] +FROM [LocustLeaders] AS [l] +INNER JOIN ( + SELECT [f].[Name], [l0].[CommanderName] + FROM [Factions] AS [f] + LEFT JOIN [LocustHordes] AS [l0] ON [f].[Id] = [l0].[Id] + WHERE [l0].[Id] IS NOT NULL +) AS [s] ON [l].[Name] = [s].[CommanderName] +WHERE CASE + WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) +END = CAST(0 AS bit) OR CASE + WHEN [s].[Name] = N'Locust' THEN CAST(1 AS bit) +END IS NULL """); } - public override async Task Enum_array_contains(bool async) + public override async Task Byte_array_contains_literal(bool async) { - await base.Enum_array_contains(async); + await base.Byte_array_contains_literal(async); AssertSql( """ -@types_without_nulls='[1]' (Size = 4000) +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CHARINDEX(0x01, [s].[Banner]) > 0 +"""); + } -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Weapons] AS [w] -LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -WHERE [w0].[Id] IS NOT NULL AND ([w0].[AmmunitionType] IN ( - SELECT [t].[value] - FROM OPENJSON(@types_without_nulls) AS [t] -) OR [w0].[AmmunitionType] IS NULL) + public override async Task Byte_array_filter_by_length_literal(bool async) + { + await base.Byte_array_filter_by_length_literal(async); + + AssertSql( + """ +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = 2 """); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public async Task DataLength_function_for_string_parameter(bool async) + public override async Task Byte_array_filter_by_length_parameter(bool async) { - await AssertQueryScalar( - async, - ss => ss.Set().Select(m => EF.Functions.DataLength(m.CodeName)), - ss => ss.Set().Select(m => (int?)(m.CodeName.Length * 2))); + await base.Byte_array_filter_by_length_parameter(async); AssertSql( """ -SELECT CAST(DATALENGTH([m].[CodeName]) AS int) -FROM [Missions] AS [m] +@p='2' + +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = @p """); } - public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) + public override void Byte_array_filter_by_length_parameter_compiled() { - await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); + base.Byte_array_filter_by_length_parameter_compiled(); AssertSql( """ -SELECT [c].[Name], [c].[Location], [c].[Nation] -FROM [Cities] AS [c] -WHERE [c].[Location] = 'Unknown' +@byteArrayParam='0x2A80' (Size = 8000) + +SELECT COUNT(*) +FROM [Squads] AS [s] +WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@byteArrayParam) AS int) """); } - public override async Task Coalesce_used_with_non_unicode_string_column_and_constant(bool async) + public override async Task Byte_array_contains_parameter(bool async) { - await base.Coalesce_used_with_non_unicode_string_column_and_constant(async); + await base.Byte_array_contains_parameter(async); AssertSql( """ -SELECT COALESCE([c].[Location], 'Unknown') -FROM [Cities] AS [c] +@someByte='1' (Size = 1) + +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE CHARINDEX(CAST(@someByte AS varbinary(max)), [s].[Banner]) > 0 """); } - public override async Task Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(bool async) + public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) { - await base.Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(async); + await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); AssertSql( """ -SELECT [c].[Name], [c].[Location], COUNT(*) AS [Count] -FROM [Weapons] AS [w] -LEFT JOIN ( - SELECT [g].[CityOfBirthName], [g].[FullName] - FROM [Gears] AS [g] -) AS [s] ON [w].[OwnerFullName] = [s].[FullName] -LEFT JOIN [Cities] AS [c] ON [s].[CityOfBirthName] = [c].[Name] -GROUP BY [c].[Name], [c].[Location] -ORDER BY [c].[Location] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE DATALENGTH([s].[Banner5]) = 5 """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(bool async) + public override async Task Conditional_expression_with_test_being_simplified_to_constant_simple(bool isAsync) { - await base.SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(async); + await base.Conditional_expression_with_test_being_simplified_to_constant_simple(isAsync); AssertSql( """ +@prm='True' + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL -ORDER BY [g].[Nickname], [w].[Id] +WHERE CASE + WHEN [g].[HasSoulPatch] = @prm THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) + public override async Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) { - await base.SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); + await base.Conditional_expression_with_test_being_simplified_to_constant_complex(isAsync); AssertSql( """ +@prm='True' +@prm2='Marcus' Lancer' (Size = 4000) + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +END AS [Discriminator] FROM [Gears] AS [g] LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL -ORDER BY [g].[Nickname], [w].[Id] +WHERE CASE + WHEN [g].[HasSoulPatch] = @prm AND ( + SELECT TOP(1) [w].[Name] + FROM [Weapons] AS [w] + WHERE [w].[Id] = [g].[SquadId]) = @prm2 THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) """); } - public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( - bool async) + public override async Task OrderBy_bool_coming_from_optional_navigation(bool async) { - await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); + await base.OrderBy_bool_coming_from_optional_navigation(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] +SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +ORDER BY [w0].[IsAutomatic] +"""); + } + + public override async Task DateTimeOffset_Date_returns_datetime(bool async) + { + await base.DateTimeOffset_Date_returns_datetime(async); + + AssertSql( + """ +@dateTimeOffset_Date='0002-03-01T00:00:00.0000000' + +SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] +FROM [Missions] AS [m] +WHERE CONVERT(date, [m].[Timeline]) >= @dateTimeOffset_Date +"""); + } + + public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async) + { + await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async); + + AssertSql( + """ +SELECT [g].[FullName] FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM [Weapons] AS [w] - LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] -) AS [s] ON [g].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL -ORDER BY [g].[Nickname], [s].[Id] """); } - public override async Task SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(bool async) + public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async) { - await base.SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(async); + await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async); AssertSql( """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT [g].[CityOfBirthName] FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(bool async) + public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(async); + await base.Projecting_required_string_column_compared_to_null_parameter(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +SELECT CAST(0 AS bit) FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] < [w].[Id] -ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(bool async) + public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(async); + await base.Byte_array_filter_by_SequenceEqual(isAsync); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] <= [w].[Id] -ORDER BY [g].[Nickname], [g].[SquadId] +@byteArrayParam='0x0405060708' (Size = 5) + +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Banner5] = @byteArrayParam """); } - public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(bool async) + public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) { - await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(async); + await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] >= [w].[Id] -ORDER BY [g].[Nickname], [g].[SquadId] +SELECT [w0].[Key] +FROM ( + SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [Key] + FROM [Weapons] AS [w] +) AS [w0] +GROUP BY [w0].[Key] """); } - public override async Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) + public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) { - await base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async); + await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -CROSS APPLY ( - SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] - FROM [Weapons] AS [w] - WHERE [w].[OwnerFullName] <> [g].[FullName] OR [w].[OwnerFullName] IS NULL - ORDER BY [w].[Id] -) AS [w0] -ORDER BY [g].[Nickname], [w0].[Id] +SELECT CASE + WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [Weapons] AS [w] +GROUP BY [w].[SynergyWithId] """); } - public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) + public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) { - await base.FirstOrDefault_over_int_compared_to_zero(async); + await base.Checked_context_with_cast_does_not_fail(isAsync); AssertSql( """ -SELECT [s].[Name] -FROM [Squads] AS [s] -WHERE [s].[Name] = N'Delta' AND COALESCE(( - SELECT TOP(1) [g].[SquadId] - FROM [Gears] AS [g] - WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit) - ORDER BY [g].[FullName]), 0) <> 0 +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +WHERE CAST([l].[ThreatLevel] AS tinyint) >= CAST(5 AS tinyint) """); } - public override async Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async) + public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) { - await base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async); + await base.Checked_context_with_addition_does_not_fail(isAsync); AssertSql( """ -SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[ReportName], [s].[OfficerName], [s].[Nickname], [s].[SquadId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -OUTER APPLY ( - SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] - FROM [Gears] AS [g0] - WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] -) AS [s] -WHERE [o].[Nickname] IS NOT NULL -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +WHERE CAST([l].[ThreatLevel] AS bigint) <= CAST(5 AS bigint) + CAST([l].[ThreatLevel] AS bigint) """); } - public override async Task Accessing_derived_property_using_hard_and_soft_cast(bool async) + public override async Task Contains_on_collection_of_byte_subquery(bool async) { - await base.Accessing_derived_property_using_hard_and_soft_cast(async); + await base.Contains_on_collection_of_byte_subquery(async); AssertSql( """ @@ -9448,728 +8207,879 @@ WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' END AS [Discriminator] FROM [LocustLeaders] AS [l] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL AND ([l0].[HighCommandId] <> 0 OR [l0].[HighCommandId] IS NULL) -""", - // +WHERE [l].[ThreatLevelByte] IN ( + SELECT [l1].[ThreatLevelByte] + FROM [LocustLeaders] AS [l1] +) +"""); + } + + public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) + { + await base.Contains_on_collection_of_nullable_byte_subquery(async); + + AssertSql( """ SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' END AS [Discriminator] FROM [LocustLeaders] AS [l] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -WHERE [l0].[Name] IS NOT NULL AND ([l0].[HighCommandId] <> 0 OR [l0].[HighCommandId] IS NULL) +WHERE EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l1] + WHERE [l1].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l1].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) """); } - public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) { - await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); + await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); AssertSql( """ -SELECT TOP(1) [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +END AS [Discriminator] FROM [LocustLeaders] AS [l] LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - 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] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] -WHERE [l].[Name] LIKE N'%Queen%' +WHERE EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l1] + WHERE [l1].[ThreatLevelNullableByte] IS NULL) """); } - public override async Task Correlated_collection_take(bool async) + public override async Task Contains_on_collection_of_nullable_byte_subquery_null_parameter(bool async) { - await base.Correlated_collection_take(async); + await base.Contains_on_collection_of_nullable_byte_subquery_null_parameter(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [c].[Location], [c].[Nation] -FROM [Gears] AS [g] -INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] -LEFT JOIN ( - SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] - FROM ( - SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] - FROM [Weapons] AS [w] - ) AS [w0] - WHERE [w0].[row] <= 10 -) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] -ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +WHERE EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l1] + WHERE [l1].[ThreatLevelNullableByte] IS NULL) """); } - public override async Task First_on_byte_array(bool async) + public override async Task Contains_on_byte_array_property_using_byte_column(bool async) { - await base.First_on_byte_array(async); + await base.Contains_on_byte_array_property_using_byte_column(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] +SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[Name], [s0].[LocustHordeId], [s0].[ThreatLevel], [s0].[ThreatLevelByte], [s0].[ThreatLevelNullableByte], [s0].[DefeatedByNickname], [s0].[DefeatedBySquadId], [s0].[HighCommandId], [s0].[Discriminator] FROM [Squads] AS [s] -WHERE CAST(SUBSTRING([s].[Banner], 1, 1) AS tinyint) = CAST(2 AS tinyint) +CROSS JOIN ( + SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' + END AS [Discriminator] + FROM [LocustLeaders] AS [l] + LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +) AS [s0] +WHERE CHARINDEX(CAST([s0].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0 """); } - public override async Task Array_access_on_byte_array(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( + bool async) { - await base.Array_access_on_byte_array(async); + await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); AssertSql( """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] -FROM [Squads] AS [s] -WHERE CAST(SUBSTRING([s].[Banner5], 2 + 1, 1) AS tinyint) = CAST(6 AS tinyint) +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +CROSS APPLY ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [l].[ThreatLevelByte] IN ( + SELECT [l0].[ThreatLevelByte] + FROM [LocustLeaders] AS [l0] + ) +) AS [s] """); } - public override async Task Project_shadow_properties(bool async) + public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( + bool async) { - await base.Project_shadow_properties(async); + await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); AssertSql( """ -SELECT [g].[Nickname], [g].[AssignedCityName] -FROM [Gears] AS [g] +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +CROSS APPLY ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 [l].[ThreatLevelByte] NOT IN ( + SELECT [l0].[ThreatLevelByte] + FROM [LocustLeaders] AS [l0] + ) +) AS [s] """); } - public override async Task Composite_key_entity_equal(bool async) + public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) { - await base.Composite_key_entity_equal(async); + await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +CROSS APPLY ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + FROM [Gears] AS [g] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] + WHERE EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l0] + WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [s] -WHERE [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] """); } - public override async Task Composite_key_entity_not_equal(bool async) + public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) { - await base.Composite_key_entity_not_equal(async); + await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async); AssertSql( """ -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -CROSS JOIN ( - SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE - WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' +SELECT [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +CROSS APPLY ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] - FROM [Gears] AS [g0] - LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] + FROM [Gears] AS [g] + LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] + WHERE NOT EXISTS ( + SELECT 1 + FROM [LocustLeaders] AS [l0] + WHERE [l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte] OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [s] -WHERE [g].[Nickname] <> [s].[Nickname] OR [g].[SquadId] <> [s].[SquadId] """); } - public override async Task Composite_key_entity_equal_null(bool async) + public override async Task Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) { - await base.Composite_key_entity_equal_null(async); + await base.Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' -END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] -WHERE [l0].[Name] IS NOT NULL AND ([s].[Nickname] IS NULL OR [s].[SquadId] IS NULL) +@prm='1' (Nullable = true) + +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +WHERE @prm = [w].[AmmunitionType] """); } - public override async Task Composite_key_entity_not_equal_null(bool async) + public override async Task Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) { - await base.Composite_key_entity_not_equal_null(async); + await base.Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE - WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +@prm='133' + +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' END AS [Discriminator] -FROM [LocustLeaders] AS [l] -LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] -WHERE [l0].[Name] IS NOT NULL AND [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +WHERE @prm & [g].[Rank] = [g].[Rank] """); } - public override async Task Projecting_property_converted_to_nullable_with_comparison(bool async) + public override async Task Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(bool async) { - await base.Projecting_property_converted_to_nullable_with_comparison(async); + await base.Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [s].[Nickname], [s].[SquadId], [s].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END = 1 +@prm='5' + +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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 @prm & CAST([g].[Rank] AS int) = CAST([g].[Rank] AS int) """); } - public override async Task Projecting_property_converted_to_nullable_with_addition(bool async) + public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) { - await base.Projecting_property_converted_to_nullable_with_addition(async); + await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [s].[Nickname], [s].[SquadId], [s].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END + 1 = 2 +@p='1' + +SELECT TOP(@p) [g].[Rank] & 1 +FROM [Gears] AS [g] +ORDER BY [g].[Nickname] """); } - public override async Task Projecting_property_converted_to_nullable_with_addition_and_final_projection(bool async) + public override async Task Enum_array_contains(bool async) { - await base.Projecting_property_converted_to_nullable_with_addition_and_final_projection(async); + await base.Enum_array_contains(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END + 1 AS [Value] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END IS NOT NULL +@types_without_nulls='[1]' (Size = 4000) + +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Weapons] AS [w] +LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +WHERE [w0].[Id] IS NOT NULL AND ([w0].[AmmunitionType] IN ( + SELECT [t].[value] + FROM OPENJSON(@types_without_nulls) AS [t] +) OR [w0].[AmmunitionType] IS NULL) """); } - public override async Task Projecting_property_converted_to_nullable_with_conditional(bool async) + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public async Task DataLength_function_for_string_parameter(bool async) { - await base.Projecting_property_converted_to_nullable_with_conditional(async); + await AssertQueryScalar( + async, + ss => ss.Set().Select(m => EF.Functions.DataLength(m.CodeName)), + ss => ss.Set().Select(m => (int?)(m.CodeName.Length * 2))); AssertSql( """ -SELECT CASE - WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] - END - ELSE -1 -END -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +SELECT CAST(DATALENGTH([m].[CodeName]) AS int) +FROM [Missions] AS [m] """); } - public override async Task Projecting_property_converted_to_nullable_with_function_call(bool async) + public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) { - await base.Projecting_property_converted_to_nullable_with_function_call(async); + await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); AssertSql( """ -SELECT SUBSTRING(CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END, 0 + 1, 3) -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +SELECT [c].[Name], [c].[Location], [c].[Nation] +FROM [Cities] AS [c] +WHERE [c].[Location] = 'Unknown' """); } - public override async Task Projecting_property_converted_to_nullable_with_function_call2(bool async) + public override async Task Coalesce_used_with_non_unicode_string_column_and_constant(bool async) { - await base.Projecting_property_converted_to_nullable_with_function_call2(async); + await base.Coalesce_used_with_non_unicode_string_column_and_constant(async); AssertSql( """ -SELECT [t].[Note], SUBSTRING([t].[Note], 0 + 1, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END) AS [Function] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END IS NOT NULL +SELECT COALESCE([c].[Location], 'Unknown') +FROM [Cities] AS [c] """); } - public override async Task Projecting_property_converted_to_nullable_into_element_init(bool async) + public override async Task Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(bool async) { - await base.Projecting_property_converted_to_nullable_into_element_init(async); + await base.Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([s].[Nickname]) AS int) -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END + 1 -FROM [Tags] AS [t] +SELECT [c].[Name], [c].[Location], COUNT(*) AS [Count] +FROM [Weapons] AS [w] LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] + SELECT [g].[CityOfBirthName], [g].[FullName] FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +) AS [s] ON [w].[OwnerFullName] = [s].[FullName] +LEFT JOIN [Cities] AS [c] ON [s].[CityOfBirthName] = [c].[Name] +GROUP BY [c].[Name], [c].[Location] +ORDER BY [c].[Location] """); } - public override async Task Projecting_property_converted_to_nullable_into_member_assignment(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(bool async) { - await base.Projecting_property_converted_to_nullable_into_member_assignment(async); + await base.SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END AS [Id] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +INNER JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +ORDER BY [g].[Nickname], [w].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_into_new_array(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) { - await base.Projecting_property_converted_to_nullable_into_new_array(async); + await base.SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( """ -SELECT CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([s].[Nickname]) AS int) -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END, CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END + 1 -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END IS NOT NULL -ORDER BY [t].[Note] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL +ORDER BY [g].[Nickname], [w].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) + public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( + bool async) { - await base.Projecting_property_converted_to_nullable_into_unary(async); + await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( """ -SELECT [t].[Note] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END IS NOT NULL AND CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[HasSoulPatch] -END = CAST(0 AS bit) -ORDER BY [t].[Note] +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Id], [s].[AmmunitionType], [s].[IsAutomatic], [s].[Name], [s].[OwnerFullName], [s].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM [Weapons] AS [w] + LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] +) AS [s] ON [g].[FullName] <> [s].[OwnerFullName] OR [s].[OwnerFullName] IS NULL +ORDER BY [g].[Nickname], [s].[Id] """); } - public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) + public override async Task SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(bool async) { - await base.Projecting_property_converted_to_nullable_into_member_access(async); + await base.SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(async); AssertSql( """ -SELECT [g].[Nickname] +SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] -LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] -WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL -ORDER BY [g].[Nickname] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] <> [w].[OwnerFullName] OR [w].[OwnerFullName] IS NULL """); } - public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(bool async) { - await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(async); AssertSql( """ -SELECT [t].[Note], CASE - WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END, [s].[Nickname], [s].[SquadId], [s].[HasSoulPatch] -FROM [Tags] AS [t] -LEFT JOIN ( - SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] - FROM [Gears] AS [g] -) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] -END IS NOT NULL -ORDER BY CASE - WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] -END, [t].[Note] +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] < [w].[Id] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Where_DateOnly_Year(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(bool async) { - await base.Where_DateOnly_Year(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(year, [m].[Date]) = 1990 +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] <= [w].[Id] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Where_DateOnly_Month(bool async) + public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(bool async) { - await base.Where_DateOnly_Month(async); + await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(month, [m].[Date]) = 11 +SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] AND [g].[SquadId] >= [w].[Id] +ORDER BY [g].[Nickname], [g].[SquadId] """); } - public override async Task Where_DateOnly_Day(bool async) + public override async Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) { - await base.Where_DateOnly_Day(async); + await base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(day, [m].[Date]) = 10 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +CROSS APPLY ( + SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] + FROM [Weapons] AS [w] + WHERE [w].[OwnerFullName] <> [g].[FullName] OR [w].[OwnerFullName] IS NULL + ORDER BY [w].[Id] +) AS [w0] +ORDER BY [g].[Nickname], [w0].[Id] """); } - public override async Task Where_DateOnly_DayOfYear(bool async) + public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) { - await base.Where_DateOnly_DayOfYear(async); + await base.FirstOrDefault_over_int_compared_to_zero(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(dayofyear, [m].[Date]) = 314 +SELECT [s].[Name] +FROM [Squads] AS [s] +WHERE [s].[Name] = N'Delta' AND COALESCE(( + SELECT TOP(1) [g].[SquadId] + FROM [Gears] AS [g] + WHERE [s].[Id] = [g].[SquadId] AND [g].[HasSoulPatch] = CAST(1 AS bit) + ORDER BY [g].[FullName]), 0) <> 0 """); } - public override async Task Where_DateOnly_DayOfWeek(bool async) + public override async Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async) { - await AssertTranslationFailed(() => base.Where_DateOnly_DayOfWeek(async)); + await base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async); - AssertSql(); + AssertSql( + """ +SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[ReportName], [s].[OfficerName], [s].[Nickname], [s].[SquadId] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +OUTER APPLY ( + SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] + FROM [Gears] AS [g0] + WHERE [g].[Nickname] = [g0].[LeaderNickname] AND [g].[SquadId] = [g0].[LeaderSquadId] +) AS [s] +WHERE [o].[Nickname] IS NOT NULL +ORDER BY [g].[Nickname], [g].[SquadId], [s].[Nickname] +"""); } - public override async Task Where_DateOnly_AddYears(bool async) + public override async Task Accessing_derived_property_using_hard_and_soft_cast(bool async) { - await base.Where_DateOnly_AddYears(async); + await base.Accessing_derived_property_using_hard_and_soft_cast(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +WHERE [l0].[Name] IS NOT NULL AND ([l0].[HighCommandId] <> 0 OR [l0].[HighCommandId] IS NULL) +""", + // + """ +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +WHERE [l0].[Name] IS NOT NULL AND ([l0].[HighCommandId] <> 0 OR [l0].[HighCommandId] IS NULL) """); } - public override async Task Where_DateOnly_AddMonths(bool async) + public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) { - await base.Where_DateOnly_AddMonths(async); + await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' +SELECT TOP(1) [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + 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] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] +WHERE [l].[Name] LIKE N'%Queen%' """); } - public override async Task Where_DateOnly_AddDays(bool async) + public override async Task Correlated_collection_take(bool async) { - await base.Where_DateOnly_AddDays(async); + await base.Correlated_collection_take(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' +SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [c].[Location], [c].[Nation] +FROM [Gears] AS [g] +INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] +LEFT JOIN ( + SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] + FROM ( + SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] + FROM [Weapons] AS [w] + ) AS [w0] + WHERE [w0].[row] <= 10 +) AS [w1] ON [g].[FullName] = [w1].[OwnerFullName] +ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name] """); } - public override async Task Where_TimeOnly_Hour(bool async) + public override async Task Project_shadow_properties(bool async) { - await base.Where_TimeOnly_Hour(async); + await base.Project_shadow_properties(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(hour, [m].[Time]) = 10 +SELECT [g].[Nickname], [g].[AssignedCityName] +FROM [Gears] AS [g] """); } - public override async Task Where_TimeOnly_Minute(bool async) + public override async Task Composite_key_entity_equal(bool async) { - await base.Where_TimeOnly_Minute(async); + await base.Composite_key_entity_equal(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(minute, [m].[Time]) = 15 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] +WHERE [g].[Nickname] = [s].[Nickname] AND [g].[SquadId] = [s].[SquadId] """); } - public override async Task Where_TimeOnly_Second(bool async) + public override async Task Composite_key_entity_not_equal(bool async) { - await base.Where_TimeOnly_Second(async); + await base.Composite_key_entity_not_equal(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(second, [m].[Time]) = 50 +SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE + WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' +END AS [Discriminator], [s].[Nickname], [s].[SquadId], [s].[AssignedCityName], [s].[CityOfBirthName], [s].[FullName], [s].[HasSoulPatch], [s].[LeaderNickname], [s].[LeaderSquadId], [s].[Rank], [s].[Discriminator] +FROM [Gears] AS [g] +LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] +CROSS JOIN ( + SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], CASE + WHEN [o0].[Nickname] IS NOT NULL THEN N'Officer' + END AS [Discriminator] + FROM [Gears] AS [g0] + LEFT JOIN [Officers] AS [o0] ON [g0].[Nickname] = [o0].[Nickname] AND [g0].[SquadId] = [o0].[SquadId] +) AS [s] +WHERE [g].[Nickname] <> [s].[Nickname] OR [g].[SquadId] <> [s].[SquadId] """); } - public override async Task Where_TimeOnly_Millisecond(bool async) + public override async Task Composite_key_entity_equal_null(bool async) { - await base.Where_TimeOnly_Millisecond(async); + await base.Composite_key_entity_equal_null(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(millisecond, [m].[Time]) = 500 +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] +WHERE [l0].[Name] IS NOT NULL AND ([s].[Nickname] IS NULL OR [s].[SquadId] IS NULL) """); } - public override async Task Where_TimeOnly_AddHours(bool async) + public override async Task Composite_key_entity_not_equal_null(bool async) { - await base.Where_TimeOnly_AddHours(async); + await base.Composite_key_entity_not_equal_null(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' +SELECT [l].[Name], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId], CASE + WHEN [l0].[Name] IS NOT NULL THEN N'LocustCommander' +END AS [Discriminator] +FROM [LocustLeaders] AS [l] +LEFT JOIN [LocustCommanders] AS [l0] ON [l].[Name] = [l0].[Name] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [l0].[DefeatedByNickname] = [s].[Nickname] AND [l0].[DefeatedBySquadId] = [s].[SquadId] +WHERE [l0].[Name] IS NOT NULL AND [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL """); } - public override async Task Where_TimeOnly_AddMinutes(bool async) + public override async Task Projecting_property_converted_to_nullable_with_comparison(bool async) { - await base.Where_TimeOnly_AddMinutes(async); + await base.Projecting_property_converted_to_nullable_with_comparison(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [s].[Nickname], [s].[SquadId], [s].[HasSoulPatch] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END = 1 """); } - public override async Task Where_TimeOnly_Add_TimeSpan(bool async) + public override async Task Projecting_property_converted_to_nullable_with_addition(bool async) { - await AssertTranslationFailed(() => base.Where_TimeOnly_Add_TimeSpan(async)); + await base.Projecting_property_converted_to_nullable_with_addition(async); - AssertSql(); + AssertSql( + """ +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [s].[Nickname], [s].[SquadId], [s].[HasSoulPatch] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END + 1 = 2 +"""); } - public override async Task Where_TimeOnly_IsBetween(bool async) + public override async Task Projecting_property_converted_to_nullable_with_addition_and_final_projection(bool async) { - await base.Where_TimeOnly_IsBetween(async); + await base.Projecting_property_converted_to_nullable_with_addition_and_final_projection(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END + 1 AS [Value] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] WHERE CASE - WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END & CASE - WHEN [m].[Time] < '11:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END IS NOT NULL """); } - public override async Task Where_TimeOnly_subtract_TimeOnly(bool async) + public override async Task Projecting_property_converted_to_nullable_with_conditional(bool async) { - await AssertTranslationFailed(() => base.Where_TimeOnly_subtract_TimeOnly(async)); + await base.Projecting_property_converted_to_nullable_with_conditional(async); - AssertSql(); + AssertSql( + """ +SELECT CASE + WHEN [t].[Note] <> N'K.I.A.' OR [t].[Note] IS NULL THEN CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] + END + ELSE -1 +END +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +"""); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) + public override async Task Projecting_property_converted_to_nullable_with_function_call(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_property(async); + await base.Projecting_property_converted_to_nullable_with_function_call(async); AssertSql( """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] +SELECT SUBSTRING(CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END, 0 + 1, 3) FROM [Tags] AS [t] -CROSS JOIN [Missions] AS [m] -WHERE CAST([t].[IssueDate] AS time) = [m].[Time] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] """); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) + public override async Task Projecting_property_converted_to_nullable_with_function_call2(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); + await base.Projecting_property_converted_to_nullable_with_function_call2(async); AssertSql( """ -@time='02:00' (DbType = Time) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT [t].[Note], SUBSTRING([t].[Note], 0 + 1, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END) AS [Function] FROM [Tags] AS [t] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] ) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] -WHERE [s].[Nickname] IS NOT NULL AND [s].[SquadId] IS NOT NULL AND CAST(DATEADD(hour, CAST(CAST([s].[SquadId] AS float) AS int), [t].[IssueDate]) AS time) = @time +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END IS NOT NULL """); } - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) + public override async Task Projecting_property_converted_to_nullable_into_element_init(bool async) { - await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); + await base.Projecting_property_converted_to_nullable_into_element_init(async); AssertSql( """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([s].[Nickname]) AS int) +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END + 1 FROM [Tags] AS [t] -WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) + public override async Task Projecting_property_converted_to_nullable_into_member_assignment(bool async) { - await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); + await base.Projecting_property_converted_to_nullable_into_member_assignment(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CAST([m].[Duration] AS time) < [m].[Time] +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END AS [Id] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + public override async Task Projecting_property_converted_to_nullable_into_new_array(bool async) { - await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); + await base.Projecting_property_converted_to_nullable_into_new_array(async); AssertSql( """ -@time='01:02' (DbType = Time) - -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE CAST([m].[Duration] AS time) = @time +SELECT CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(LEN([s].[Nickname]) AS int) +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END, CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END + 1 +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END IS NOT NULL +ORDER BY [t].[Note] """); } - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) + public override async Task Projecting_property_converted_to_nullable_into_unary(bool async) { - await base.Order_by_TimeOnly_FromTimeSpan(async); + await base.Projecting_property_converted_to_nullable_into_unary(async); AssertSql( """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -ORDER BY CAST([m].[Duration] AS time) +SELECT [t].[Note] +FROM [Tags] AS [t] +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END IS NOT NULL AND CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[HasSoulPatch] +END = CAST(0 AS bit) +ORDER BY [t].[Note] """); } - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) + public override async Task Projecting_property_converted_to_nullable_into_member_access(bool async) { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); + await base.Projecting_property_converted_to_nullable_into_member_access(async); AssertSql( """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] -FROM [Tags] AS [t] -CROSS JOIN [Missions] AS [m] -WHERE CAST([t].[IssueDate] AS date) > [m].[Date] +SELECT [g].[Nickname] +FROM [Gears] AS [g] +LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] AND [g].[SquadId] = [t].[GearSquadId] +WHERE DATEPART(month, [t].[IssueDate]) <> 5 OR [t].[IssueDate] IS NULL +ORDER BY [g].[Nickname] """); } - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); + await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); AssertSql( """ -@prm='10/11/0002' (DbType = Date) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] +SELECT [t].[Note], CASE + WHEN [t].[GearNickName] IS NOT NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END, [s].[Nickname], [s].[SquadId], [s].[HasSoulPatch] FROM [Tags] AS [t] -WHERE CAST([t].[IssueDate] AS date) IN (@prm, '0015-03-07') +LEFT JOIN ( + SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] + FROM [Gears] AS [g] +) AS [s] ON [t].[GearNickName] = [s].[Nickname] AND [t].[GearSquadId] = [s].[SquadId] +WHERE CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[Nickname] +END IS NOT NULL +ORDER BY CASE + WHEN [t].[GearNickName] IS NOT NULL THEN [s].[SquadId] +END, [t].[Note] """); } @@ -10380,17 +9290,6 @@ FROM [Weapons] AS [w0] """); } - public override async Task DateTimeOffset_DateAdd_AddYears(bool async) - { - await base.DateTimeOffset_DateAdd_AddYears(async); - - AssertSql( - """ -SELECT DATEADD(year, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] AS [m] -"""); - } - public override async Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async) { await base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async); @@ -10601,17 +9500,6 @@ FROM [Missions] AS [m] """); } - public override async Task ToString_guid_property_projection(bool async) - { - await base.ToString_guid_property_projection(async); - - AssertSql( - """ -SELECT [t].[GearNickName] AS [A], CONVERT(varchar(36), [t].[Id]) AS [B] -FROM [Tags] AS [t] -"""); - } - public override async Task Correlated_collection_with_distinct_not_projecting_identifier_column(bool async) { await base.Correlated_collection_with_distinct_not_projecting_identifier_column(async); @@ -11453,54 +10341,6 @@ FROM [Squads] AS [s] """); } - public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - await base.DateTimeOffset_to_unix_time_milliseconds(async); - - AssertSql( - """ -@unixEpochMilliseconds='0' - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochMilliseconds = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - - public override async Task DateTimeOffset_to_unix_time_seconds(bool async) - { - await base.DateTimeOffset_to_unix_time_seconds(async); - - AssertSql( - """ -@unixEpochSeconds='0' - -SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], CASE - WHEN [o].[Nickname] IS NOT NULL THEN N'Officer' -END AS [Discriminator], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s1].[SquadId], [s1].[MissionId] -FROM [Gears] AS [g] -LEFT JOIN [Officers] AS [o] ON [g].[Nickname] = [o].[Nickname] AND [g].[SquadId] = [o].[SquadId] -INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] AS [s0] - INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochSeconds = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - public override async Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) { await base.Set_operator_with_navigation_in_projection_groupby_aggregate(async); @@ -11866,78 +10706,6 @@ FROM OPENJSON(@keys) WITH ([value] uniqueidentifier '$') AS [k] """); } - public override async Task Where_datetimeoffset_microsecond_component(bool async) - { - await base.Where_datetimeoffset_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Timeline]) % 1000 = 200 -"""); - } - - public override async Task Where_datetimeoffset_nanosecond_component(bool async) - { - await base.Where_datetimeoffset_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Timeline]) % 1000 = 400 -"""); - } - - public override async Task Where_timespan_microsecond_component(bool async) - { - await base.Where_timespan_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Duration]) % 1000 = 200 -"""); - } - - public override async Task Where_timespan_nanosecond_component(bool async) - { - await base.Where_timespan_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Duration]) % 1000 = 400 -"""); - } - - public override async Task Where_timeonly_microsecond_component(bool async) - { - await base.Where_timeonly_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(microsecond, [m].[Time]) % 1000 = 200 -"""); - } - - public override async Task Where_timeonly_nanosecond_component(bool async) - { - await base.Where_timeonly_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] AS [m] -WHERE DATEPART(nanosecond, [m].[Time]) % 1000 = 400 -"""); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs index 0b81af75369..727f120e502 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TemporalGearsOfWarQuerySqlServerTest.cs @@ -236,306 +236,6 @@ WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@byteArrayParam) A """); } - public override async Task Where_DateOnly_Year(bool async) - { - await base.Where_DateOnly_Year(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(year, [m].[Date]) = 1990 -"""); - } - - public override async Task Where_DateOnly_Month(bool async) - { - await base.Where_DateOnly_Month(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(month, [m].[Date]) = 11 -"""); - } - - public override async Task Where_DateOnly_Day(bool async) - { - await base.Where_DateOnly_Day(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(day, [m].[Date]) = 10 -"""); - } - - public override async Task Where_DateOnly_DayOfYear(bool async) - { - await base.Where_DateOnly_DayOfYear(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(dayofyear, [m].[Date]) = 314 -"""); - } - - public override async Task Where_DateOnly_DayOfWeek(bool async) - { - await AssertTranslationFailed(() => base.Where_DateOnly_DayOfWeek(async)); - - AssertSql(); - } - - public override async Task Where_DateOnly_AddYears(bool async) - { - await base.Where_DateOnly_AddYears(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEADD(year, CAST(3 AS int), [m].[Date]) = '1993-11-10' -"""); - } - - public override async Task Where_DateOnly_AddMonths(bool async) - { - await base.Where_DateOnly_AddMonths(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEADD(month, CAST(3 AS int), [m].[Date]) = '1991-02-10' -"""); - } - - public override async Task Where_DateOnly_AddDays(bool async) - { - await base.Where_DateOnly_AddDays(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEADD(day, CAST(3 AS int), [m].[Date]) = '1990-11-13' -"""); - } - - public override async Task Where_TimeOnly_Hour(bool async) - { - await base.Where_TimeOnly_Hour(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(hour, [m].[Time]) = 10 -"""); - } - - public override async Task Where_TimeOnly_Minute(bool async) - { - await base.Where_TimeOnly_Minute(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(minute, [m].[Time]) = 15 -"""); - } - - public override async Task Where_TimeOnly_Second(bool async) - { - await base.Where_TimeOnly_Second(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(second, [m].[Time]) = 50 -"""); - } - - public override async Task Where_TimeOnly_Millisecond(bool async) - { - await base.Where_TimeOnly_Millisecond(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(millisecond, [m].[Time]) = 500 -"""); - } - - public override async Task Where_TimeOnly_AddHours(bool async) - { - await base.Where_TimeOnly_AddHours(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEADD(hour, CAST(3.0E0 AS int), [m].[Time]) = '13:15:50.5' -"""); - } - - public override async Task Where_TimeOnly_AddMinutes(bool async) - { - await base.Where_TimeOnly_AddMinutes(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEADD(minute, CAST(3.0E0 AS int), [m].[Time]) = '10:18:50.5' -"""); - } - - public override async Task Where_TimeOnly_Add_TimeSpan(bool async) - { - await AssertTranslationFailed(() => base.Where_TimeOnly_Add_TimeSpan(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_IsBetween(bool async) - { - await base.Where_TimeOnly_IsBetween(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE CASE - WHEN [m].[Time] >= '10:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END & CASE - WHEN [m].[Time] < '11:00:00' THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END = CAST(1 AS bit) -"""); - } - - public override async Task Where_TimeOnly_subtract_TimeOnly(bool async) - { - await AssertTranslationFailed(() => base.Where_TimeOnly_subtract_TimeOnly(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) - { - await base.Where_TimeOnly_FromDateTime_compared_to_property(async); - - AssertSql( - """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] -FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] -CROSS JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE CAST([t].[IssueDate] AS time) = [m].[Time] -"""); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) - { - await base.Where_TimeOnly_FromDateTime_compared_to_parameter(async); - - AssertSql( - """ -@time='02:00' (DbType = Time) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] -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] -WHERE [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL AND CAST(DATEADD(hour, CAST(CAST([g].[SquadId] AS float) AS int), [t].[IssueDate]) AS time) = @time -"""); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) - { - await base.Where_TimeOnly_FromDateTime_compared_to_constant(async); - - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] -FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] -WHERE CAST(DATEADD(hour, CAST(CAST(CAST(LEN([t].[Note]) AS int) AS float) AS int), [t].[IssueDate]) AS time) > '09:00:00' -"""); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) - { - await base.Where_TimeOnly_FromTimeSpan_compared_to_property(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE CAST([m].[Duration] AS time) < [m].[Time] -"""); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) - { - await base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async); - - AssertSql( - """ -@time='01:02' (DbType = Time) - -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE CAST([m].[Duration] AS time) = @time -"""); - } - - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) - { - await base.Order_by_TimeOnly_FromTimeSpan(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -ORDER BY CAST([m].[Duration] AS time) -"""); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); - - AssertSql( - """ -SELECT [t].[Id] AS [TagId], [m].[Id] AS [MissionId] -FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] -CROSS JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE CAST([t].[IssueDate] AS date) > [m].[Date] -"""); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); - - AssertSql( - """ -@prm='10/11/0002' (DbType = Date) - -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] -FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] -WHERE CAST([t].[IssueDate] AS date) IN (@prm, '0015-03-07') -"""); - } - public override async Task Basic_query_gears(bool async) { await base.Basic_query_gears(async); @@ -886,30 +586,6 @@ ELSE CAST(0 AS bit) """); } - public override async Task Where_datetimeoffset_month_component(bool async) - { - await base.Where_datetimeoffset_month_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(month, [m].[Timeline]) = 1 -"""); - } - - public override async Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) - { - await base.Where_datetimeoffset_milliseconds_parameter_and_constant(async); - - AssertSql( - """ -SELECT COUNT(*) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE [m].[Timeline] = '1902-01-02T10:00:00.1234567+01:30' -"""); - } - public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) { await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); @@ -1071,18 +747,6 @@ ELSE CAST(0 AS bit) """); } - public override async Task Where_bitwise_and_nullable_enum_with_constant(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_constant(async); - - AssertSql( - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] & 1 > 0 -"""); - } - public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) { await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); @@ -1186,29 +850,6 @@ public override async Task Null_propagation_optimization1(bool async) """); } - public override async Task DateTimeOffset_DateAdd_AddMonths(bool async) - { - await base.DateTimeOffset_DateAdd_AddMonths(async); - - AssertSql( - """ -SELECT DATEADD(month, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - - public override async Task Where_datetimeoffset_minute_component(bool async) - { - await base.Where_datetimeoffset_minute_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(minute, [m].[Timeline]) = 0 -"""); - } - public override async Task Projecting_property_converted_to_nullable_with_conditional(bool async) { await base.Projecting_property_converted_to_nullable_with_conditional(async); @@ -1244,17 +885,6 @@ SELECT TOP(1) [w].[IsAutomatic] """); } - public override async Task ToString_guid_property_projection(bool async) - { - await base.ToString_guid_property_projection(async); - - AssertSql( - """ -SELECT [t].[GearNickName] AS [A], CONVERT(varchar(36), [t].[Id]) AS [B] -FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] -"""); - } - public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) { await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); @@ -1476,17 +1106,6 @@ SELECT [l].[Name] """); } - public override async Task DateTimeOffset_DateAdd_AddHours(bool async) - { - await base.DateTimeOffset_DateAdd_AddHours(async); - - AssertSql( - """ -SELECT DATEADD(hour, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task String_concat_with_null_conditional_argument2(bool async) { await base.String_concat_with_null_conditional_argument2(async); @@ -2224,18 +1843,6 @@ public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_prop """); } - public override async Task Where_datetimeoffset_second_component(bool async) - { - await base.Where_datetimeoffset_second_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(second, [m].[Timeline]) = 0 -"""); - } - public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) { await base.Optional_navigation_type_compensation_works_with_binary_expression(async); @@ -2403,17 +2010,6 @@ SELECT TOP(1) [w].[IsAutomatic] """); } - public override async Task DateTimeOffset_DateAdd_AddYears(bool async) - { - await base.DateTimeOffset_DateAdd_AddYears(async); - - AssertSql( - """ -SELECT DATEADD(year, CAST(1 AS int), [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) { await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); @@ -2585,17 +2181,6 @@ SELECT 1 """); } - public override async Task DateTimeOffset_DateAdd_AddMinutes(bool async) - { - await base.DateTimeOffset_DateAdd_AddMinutes(async); - - AssertSql( - """ -SELECT DATEADD(minute, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Where_with_enum_flags_parameter(bool async) { await base.Where_with_enum_flags_parameter(async); @@ -2875,32 +2460,6 @@ GROUP BY [g].[Rank] """); } - public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool async) - { - await base.Where_enum_has_flag_with_non_nullable_parameter(async); - - AssertSql( - """ -@parameter='2' - -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 [g].[Rank] & @parameter = @parameter -"""); - } - - public override async Task Where_TimeSpan_Seconds(bool async) - { - await base.Where_TimeSpan_Seconds(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(second, [m].[Duration]) = 3 -"""); - } - public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) { await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); @@ -2999,18 +2558,6 @@ public override async Task Select_inverted_nullable_boolean(bool async) """); } - public override async Task Where_datetimeoffset_millisecond_component(bool async) - { - await base.Where_datetimeoffset_millisecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(millisecond, [m].[Timeline]) = 0 -"""); - } - public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( bool async) { @@ -3461,21 +3008,9 @@ public override async Task GroupBy_Property_Include_Select_Count(bool async) AssertSql( """ -SELECT COUNT(*) -FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -GROUP BY [g].[Rank] -"""); - } - - public override async Task Where_TimeSpan_Hours(bool async) - { - await base.Where_TimeSpan_Hours(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(hour, [m].[Duration]) = 1 +SELECT COUNT(*) +FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] +GROUP BY [g].[Rank] """); } @@ -4020,18 +3555,6 @@ ORDER BY [f].[Name] """); } - public override async Task First_on_byte_array(bool async) - { - await base.First_on_byte_array(async); - - AssertSql( - """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s].[PeriodEnd], [s].[PeriodStart] -FROM [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] -WHERE CAST(SUBSTRING([s].[Banner], 1, 1) AS tinyint) = CAST(2 AS tinyint) -"""); - } - public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) { @@ -4081,18 +3604,6 @@ ORDER BY [w].[Id] """); } - public override async Task Where_datetimeoffset_utcnow(bool async) - { - await base.Where_datetimeoffset_utcnow(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset) -"""); - } - public override async Task Nav_rewrite_with_convert3(bool async) { await base.Nav_rewrite_with_convert3(async); @@ -4164,18 +3675,6 @@ SELECT 1 """); } - public override async Task Where_datetimeoffset_now(bool async) - { - await base.Where_datetimeoffset_now(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE [m].[Timeline] <> SYSDATETIMEOFFSET() -"""); - } - public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) { await base.Select_subquery_int_with_inside_cast_and_coalesce(async); @@ -4239,17 +3738,6 @@ ORDER BY [g].[FullName] """); } - public override async Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) - { - await base.DateTimeOffset_DateAdd_AddMilliseconds(async); - - AssertSql( - """ -SELECT DATEADD(millisecond, CAST(300.0E0 AS int), [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) { await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); @@ -4461,29 +3949,6 @@ ORDER BY [g].[FullName] """); } - public override async Task Where_datetimeoffset_dayofyear_component(bool async) - { - await base.Where_datetimeoffset_dayofyear_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(dayofyear, [m].[Timeline]) = 2 -"""); - } - - public override async Task DateTimeOffset_DateAdd_AddDays(bool async) - { - await base.DateTimeOffset_DateAdd_AddDays(async); - - AssertSql( - """ -SELECT DATEADD(day, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) { await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); @@ -4535,18 +4000,6 @@ public override async Task Select_Where_Navigation_Equals_Navigation(bool async) """); } - public override async Task Array_access_on_byte_array(bool async) - { - await base.Array_access_on_byte_array(async); - - AssertSql( - """ -SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s].[PeriodEnd], [s].[PeriodStart] -FROM [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] -WHERE CAST(SUBSTRING([s].[Banner5], 2 + 1, 1) AS tinyint) = CAST(6 AS tinyint) -"""); - } - public override async Task Where_contains_on_navigation_with_composite_keys(bool async) { await base.Where_contains_on_navigation_with_composite_keys(async); @@ -4706,56 +4159,6 @@ END AS [IsEradicated] """); } - public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 -"""); - } - - public override async Task Where_enum_has_flag(bool async) - { - await base.Where_enum_has_flag(async); - - AssertSql( - """ -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 [g].[Rank] & 2 = 2 -""", - // - """ -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 [g].[Rank] & 18 = 18 -""", - // - """ -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 [g].[Rank] & 1 = 1 -""", - // - """ -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 [g].[Rank] & 1 = 1 -""", - // - """ -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 2 & [g].[Rank] = [g].[Rank] -"""); - } - public override async Task ToString_enum_property_projection(bool async) { await base.ToString_enum_property_projection(async); @@ -4893,36 +4296,6 @@ ORDER BY [t].[Note] """); } - public override async Task Where_enum_has_flag_subquery(bool async) - { - await base.Where_enum_has_flag_subquery(async); - - AssertSql( - """ -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 [g].[Rank] & COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) -""", - // - """ -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 2 & COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) = COALESCE(( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]), 0) -"""); - } - public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) { await base.Select_required_navigation_on_the_same_type_with_cast(async); @@ -5036,17 +4409,6 @@ public override async Task Include_reference_on_derived_type_using_lambda_with_t """); } - public override async Task DateTimeOffset_DateAdd_AddSeconds(bool async) - { - await base.DateTimeOffset_DateAdd_AddSeconds(async); - - AssertSql( - """ -SELECT DATEADD(second, CAST(1.0E0 AS int), [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) { await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); @@ -5074,42 +4436,6 @@ public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scal """); } - public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async) - { - await base.Where_enum_has_flag_subquery_with_pushdown(async); - - AssertSql( - """ -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 [g].[Rank] & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL -""", - // - """ -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 2 & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL -"""); - } - public override async Task Select_null_parameter_is_not_null(bool async) { await base.Select_null_parameter_is_not_null(async); @@ -5213,18 +4539,6 @@ public override async Task Project_shadow_properties(bool async) """); } - public override async Task Where_nullable_enum_with_constant(bool async) - { - await base.Where_nullable_enum_with_constant(async); - - AssertSql( - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] = 1 -"""); - } - public override async Task Projecting_property_converted_to_nullable_and_use_it_in_order_by(bool async) { await base.Projecting_property_converted_to_nullable_and_use_it_in_order_by(async); @@ -5378,17 +4692,6 @@ LEFT JOIN ( """); } - public override async Task TimeSpan_Minutes(bool async) - { - await base.TimeSpan_Minutes(async); - - AssertSql( - """ -SELECT DATEPART(minute, [m].[Duration]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) { await base.Select_subquery_distinct_singleordefault_boolean1(async); @@ -5486,18 +4789,6 @@ ORDER BY [g0].[Rank] """); } - public override async Task Where_nullable_enum_with_null_constant(bool async) - { - await base.Where_nullable_enum_with_null_constant(async); - - AssertSql( - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] IS NULL -"""); - } - public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) { await base.ThenInclude_collection_on_derived_after_derived_reference(async); @@ -5639,18 +4930,6 @@ WHERE [g].[Nickname] <> N'Marcus' """); } - public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_null_constant(async); - - AssertSql( - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 -"""); - } - public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) { await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); @@ -5710,18 +4989,6 @@ WHERE [t].[Note] <> N'Foo' OR [t].[Note] IS NULL """); } - public override async Task Where_TimeSpan_Milliseconds(bool async) - { - await base.Where_TimeSpan_Milliseconds(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(millisecond, [m].[Duration]) = 456 -"""); - } - public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) { await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); @@ -6204,17 +5471,6 @@ WHERE [s0].[MissionId] < 3 """); } - public override async Task Time_of_day_datetimeoffset(bool async) - { - await base.Time_of_day_datetimeoffset(async); - - AssertSql( - """ -SELECT CONVERT(time, [m].[Timeline]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Join_predicate_value(bool async) { await base.Join_predicate_value(async); @@ -6239,20 +5495,6 @@ ORDER BY [g].[Nickname] """); } - public override async Task Where_datetimeoffset_date_component(bool async) - { - await base.Where_datetimeoffset_date_component(async); - - AssertSql( - """ -@Date='0001-01-01T00:00:00.0000000' - -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE CONVERT(date, [m].[Timeline]) > @Date -"""); - } - public override async Task OrderBy_Contains_empty_list(bool async) { await base.OrderBy_Contains_empty_list(async); @@ -6307,18 +5549,6 @@ WHERE COALESCE([g].[HasSoulPatch], CAST(0 AS bit)) = CAST(1 AS bit) """); } - public override async Task Filter_with_new_Guid(bool async) - { - await base.Filter_with_new_Guid(async); - - AssertSql( - """ -SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t].[PeriodEnd], [t].[PeriodStart] -FROM [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] -WHERE [t].[Id] = 'df36f493-463f-4123-83f9-6b135deeb7ba' -"""); - } - public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) { await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); @@ -6614,17 +5844,6 @@ ORDER BY [g].[Nickname] """); } - public override async Task TimeSpan_Seconds(bool async) - { - await base.TimeSpan_Seconds(async); - - AssertSql( - """ -SELECT DATEPART(second, [m].[Duration]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Navigation_inside_interpolated_string_expanded(bool async) { await base.Navigation_inside_interpolated_string_expanded(async); @@ -6670,18 +5889,6 @@ WHERE [l0].[Name] IS NOT NULL """); } - public override async Task Where_datetimeoffset_year_component(bool async) - { - await base.Where_datetimeoffset_year_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(year, [m].[Timeline]) = 2 -"""); - } - public override async Task Select_ternary_operation_with_inverted_boolean(bool async) { await base.Select_ternary_operation_with_inverted_boolean(async); @@ -6786,24 +5993,12 @@ public override async Task Include_on_derived_type_with_order_by_and_paging(bool FROM ( SELECT TOP(@p) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[PeriodEnd], [l].[PeriodStart], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[PeriodEnd] AS [PeriodEnd0], [g].[PeriodStart] AS [PeriodStart0], [g].[Rank], [t].[Id], [t].[Note] FROM [LocustLeaders] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [l] - LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] - LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON ([g].[Nickname] = [t].[GearNickName] OR ([g].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([g].[SquadId] = [t].[GearSquadId] OR ([g].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) - ORDER BY [t].[Note] -) AS [s] -LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [s].[FullName] = [w].[OwnerFullName] -ORDER BY [s].[Note], [s].[Name], [s].[Nickname], [s].[SquadId], [s].[Id] -"""); - } - - public override async Task Where_datetimeoffset_day_component(bool async) - { - await base.Where_datetimeoffset_day_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(day, [m].[Timeline]) = 2 + LEFT JOIN [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] ON [l].[DefeatedByNickname] = [g].[Nickname] AND [l].[DefeatedBySquadId] = [g].[SquadId] + LEFT JOIN [Tags] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [t] ON ([g].[Nickname] = [t].[GearNickName] OR ([g].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND ([g].[SquadId] = [t].[GearSquadId] OR ([g].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) + ORDER BY [t].[Note] +) AS [s] +LEFT JOIN [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] ON [s].[FullName] = [w].[OwnerFullName] +ORDER BY [s].[Note], [s].[Name], [s].[Nickname], [s].[SquadId], [s].[Id] """); } @@ -6913,18 +6108,6 @@ public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_c """); } - public override async Task Where_datetimeoffset_hour_component(bool async) - { - await base.Where_datetimeoffset_hour_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(hour, [m].[Timeline]) = 10 -"""); - } - public override async Task Property_access_on_derived_entity_using_cast(bool async) { await base.Property_access_on_derived_entity_using_cast(async); @@ -6975,18 +6158,6 @@ ORDER BY [g].[Nickname] """); } - public override async Task Bitwise_projects_values_in_select(bool async) - { - await base.Bitwise_projects_values_in_select(async); - - AssertSql( - """ -SELECT TOP(1) ~CAST(([g].[Rank] & 2) ^ 2 AS bit) AS [BitwiseTrue], ~CAST(([g].[Rank] & 2) ^ 4 AS bit) AS [BitwiseFalse], [g].[Rank] & 2 AS [BitwiseValue] -FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -WHERE [g].[Rank] & 2 = 2 -"""); - } - public override async Task Comparison_with_value_converted_subclass(bool async) { await base.Comparison_with_value_converted_subclass(async); @@ -7584,26 +6755,6 @@ INNER JOIN ( """); } - public override async Task Where_nullable_enum_with_nullable_parameter(bool async) - { - await base.Where_nullable_enum_with_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] IS NULL -"""); - } - public override async Task Concat_with_scalar_projection(bool async) { await base.Concat_with_scalar_projection(async); @@ -7921,27 +7072,6 @@ ORDER BY [g].[Nickname] """); } - public override async Task Where_enum_has_flag_subquery_client_eval(bool async) - { - await base.Where_enum_has_flag_subquery_client_eval(async); - - AssertSql( - """ -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 [g].[Rank] & ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) = ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) OR ( - SELECT TOP(1) [g0].[Rank] - FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g0] - ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL -"""); - } - public override async Task Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(bool async) { await base.Correlated_collection_via_SelectMany_with_Distinct_missing_indentifying_columns_in_projection(async); @@ -8009,17 +7139,6 @@ public override async Task Include_collection_on_derived_type_using_lambda_with_ """); } - public override async Task TimeSpan_Milliseconds(bool async) - { - await base.TimeSpan_Milliseconds(async); - - AssertSql( - """ -SELECT DATEPART(millisecond, [m].[Duration]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) { await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); @@ -8123,17 +7242,6 @@ public override async Task Include_multiple_circular_with_filter(bool async) """); } - public override async Task TimeSpan_Hours(bool async) - { - await base.TimeSpan_Hours(async); - - AssertSql( - """ -SELECT DATEPART(hour, [m].[Duration]) -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -"""); - } - public override async Task Singleton_Navigation_With_Member_Access(bool async) { await base.Singleton_Navigation_With_Member_Access(async); @@ -8186,20 +7294,6 @@ END AS [Prop] """); } - public override async Task Where_nullable_enum_with_non_nullable_parameter(bool async) - { - await base.Where_nullable_enum_with_non_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] = @ammunitionType -"""); - } - public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) { await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); @@ -8215,24 +7309,6 @@ SELECT 1 """); } - public override async Task Where_bitwise_and_enum(bool async) - { - await base.Where_bitwise_and_enum(async); - - AssertSql( - """ -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 [g].[Rank] & 2 > 0 -""", - // - """ -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 [g].[Rank] & 2 = 2 -"""); - } - public override async Task Left_join_projection_using_coalesce_tracking(bool async) { await base.Left_join_projection_using_coalesce_tracking(async); @@ -8535,30 +7611,6 @@ WHERE [g].[Nickname] <> N'Marcus' """); } - public override async Task Where_bitwise_and_integral(bool async) - { - await base.Where_bitwise_and_integral(async); - - AssertSql( - """ -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 [g].[Rank] & 1 = 1 -""", - // - """ -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 CAST([g].[Rank] AS bigint) & CAST(1 AS bigint) = CAST(1 AS bigint) -""", - // - """ -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 CAST([g].[Rank] AS smallint) & CAST(1 AS smallint) = CAST(1 AS smallint) -"""); - } - public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) { await base.Coalesce_operator_in_projection_with_other_conditions(async); @@ -8717,18 +7769,6 @@ SELECT 1 AS empty """); } - public override async Task Where_TimeSpan_Minutes(bool async) - { - await base.Where_TimeSpan_Minutes(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(minute, [m].[Duration]) = 2 -"""); - } - public override async Task Where_conditional_equality_1(bool async) { await base.Where_conditional_equality_1(async); @@ -8772,18 +7812,6 @@ public override async Task Null_checks_in_correlated_predicate_are_correctly_tra """); } - public override async Task Where_enum(bool async) - { - await base.Where_enum(async); - - AssertSql( - """ -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 [g].[Rank] = 4 -"""); - } - public override async Task Order_by_entity_qsre_with_inheritance(bool async) { await base.Order_by_entity_qsre_with_inheritance(async); @@ -8798,20 +7826,6 @@ SELECT [l].[Name] """); } - public override async Task Where_has_flag_with_nullable_parameter(bool async) - { - await base.Where_has_flag_with_nullable_parameter(async); - - AssertSql( - """ -@parameter='2' (Nullable = true) - -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 [g].[Rank] & @parameter = @parameter -"""); - } - public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) { await base.Select_subquery_boolean_empty_with_pushdown(async); @@ -9259,18 +8273,6 @@ INNER JOIN ( """); } - public override async Task Select_enum_has_flag(bool async) - { - await base.Select_enum_has_flag(async); - - AssertSql( - """ -SELECT TOP(1) ~CAST(([g].[Rank] & 2) ^ 2 AS bit) AS [hasFlagTrue], ~CAST(([g].[Rank] & 4) ^ 4 AS bit) AS [hasFlagFalse] -FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -WHERE [g].[Rank] & 2 = 2 -"""); - } - public override async Task Include_multiple_one_to_one_optional_and_one_to_one_required(bool async) { await base.Include_multiple_one_to_one_optional_and_one_to_one_required(async); @@ -9320,18 +8322,6 @@ LEFT JOIN ( """); } - public override async Task Where_bitwise_or_enum(bool async) - { - await base.Where_bitwise_or_enum(async); - - AssertSql( - """ -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 [g].[Rank] | 2 > 0 -"""); - } - public override async Task Correlated_collection_with_very_complex_order_by(bool async) { await base.Correlated_collection_with_very_complex_order_by(async); @@ -9430,26 +8420,6 @@ public override async Task Double_order_by_on_nullable_bool_coming_from_optional """); } - public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' (Nullable = true) - -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] & @ammunitionType > 0 -""", - // - """ -SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[PeriodEnd], [w].[PeriodStart], [w].[SynergyWithId] -FROM [Weapons] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [w] -WHERE [w].[AmmunitionType] & NULL > 0 -"""); - } - public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) { await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); @@ -10087,48 +9057,6 @@ public override async Task Using_indexer_on_byte_array_and_string_in_projection( """); } - public override async Task DateTimeOffset_to_unix_time_milliseconds(bool async) - { - await base.DateTimeOffset_to_unix_time_milliseconds(async); - - AssertSql( - """ -@unixEpochMilliseconds='0' - -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], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s].[PeriodEnd], [s].[PeriodStart], [s1].[SquadId], [s1].[MissionId], [s1].[PeriodEnd], [s1].[PeriodStart] -FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -INNER JOIN [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s0] - INNER JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochMilliseconds = DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - - public override async Task DateTimeOffset_to_unix_time_seconds(bool async) - { - await base.DateTimeOffset_to_unix_time_seconds(async); - - AssertSql( - """ -@unixEpochSeconds='0' - -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], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s].[PeriodEnd], [s].[PeriodStart], [s1].[SquadId], [s1].[MissionId], [s1].[PeriodEnd], [s1].[PeriodStart] -FROM [Gears] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [g] -INNER JOIN [Squads] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s] ON [g].[SquadId] = [s].[Id] -LEFT JOIN [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s1] ON [s].[Id] = [s1].[SquadId] -WHERE NOT EXISTS ( - SELECT 1 - FROM [SquadMissions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [s0] - INNER JOIN [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] ON [s0].[MissionId] = [m].[Id] - WHERE [s].[Id] = [s0].[SquadId] AND @unixEpochSeconds = DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [m].[Timeline])) -ORDER BY [g].[Nickname], [g].[SquadId], [s].[Id], [s1].[SquadId] -"""); - } - public override async Task Set_operator_with_navigation_in_projection_groupby_aggregate(bool async) { await base.Set_operator_with_navigation_in_projection_groupby_aggregate(async); @@ -10424,78 +9352,6 @@ FROM OPENJSON(@keys) WITH ([value] uniqueidentifier '$') AS [k] """); } - public override async Task Where_datetimeoffset_microsecond_component(bool async) - { - await base.Where_datetimeoffset_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(microsecond, [m].[Timeline]) % 1000 = 200 -"""); - } - - public override async Task Where_datetimeoffset_nanosecond_component(bool async) - { - await base.Where_datetimeoffset_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(nanosecond, [m].[Timeline]) % 1000 = 400 -"""); - } - - public override async Task Where_timespan_microsecond_component(bool async) - { - await base.Where_timespan_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(microsecond, [m].[Duration]) % 1000 = 200 -"""); - } - - public override async Task Where_timespan_nanosecond_component(bool async) - { - await base.Where_timespan_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(nanosecond, [m].[Duration]) % 1000 = 400 -"""); - } - - public override async Task Where_timeonly_microsecond_component(bool async) - { - await base.Where_timeonly_microsecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(microsecond, [m].[Time]) % 1000 = 200 -"""); - } - - public override async Task Where_timeonly_nanosecond_component(bool async) - { - await base.Where_timeonly_nanosecond_component(async); - - AssertSql( - """ -SELECT [m].[Id], [m].[BriefingDocument], [m].[BriefingDocumentFileExtension], [m].[CodeName], [m].[Date], [m].[Difficulty], [m].[Duration], [m].[PeriodEnd], [m].[PeriodStart], [m].[Rating], [m].[Time], [m].[Timeline] -FROM [Missions] FOR SYSTEM_TIME AS OF '2010-01-01T00:00:00.0000000' AS [m] -WHERE DATEPART(nanosecond, [m].[Time]) % 1000 = 400 -"""); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/BasicTypesQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/BasicTypesQuerySqlServerFixture.cs new file mode 100644 index 00000000000..f02c4804a9f --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/BasicTypesQuerySqlServerFixture.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class BasicTypesQuerySqlServerFixture : BasicTypesQueryFixtureBase, ITestSqlLoggerFactory +{ + protected override ITestStoreFactory TestStoreFactory + => SqlServerTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; + + protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) + { + base.OnModelCreating(modelBuilder, context); + + modelBuilder.Entity().Property(b => b.Decimal).HasColumnType("decimal(18,2)"); + modelBuilder.Entity().Property(b => b.Decimal).HasColumnType("decimal(18,2)"); + } +} + +public class BasicTypesQuerySqlServer160Fixture : BasicTypesQuerySqlServerFixture +{ + public override DbContextOptionsBuilder AddOptions(DbContextOptionsBuilder builder) + => base.AddOptions(builder).UseSqlServer(b => b.UseCompatibilityLevel(160)); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/EnumTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/EnumTranslationsSqlServerTest.cs new file mode 100644 index 00000000000..2f79fb04805 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/EnumTranslationsSqlServerTest.cs @@ -0,0 +1,309 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class EnumTranslationsSqlServerTest : EnumTranslationsTestBase +{ + public EnumTranslationsSqlServerTest(BasicTypesQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equality + + public override async Task Equality_to_constant(bool async) + { + await base.Equality_to_constant(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Enum] = 0 +"""); + } + + public override async Task Equality_to_parameter(bool async) + { + await base.Equality_to_parameter(async); + + AssertSql( + """ +@basicEnum='0' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Enum] = @basicEnum +"""); + } + + public override async Task Equality_nullable_enum_to_constant(bool async) + { + await base.Equality_nullable_enum_to_constant(async); + + AssertSql( + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[Enum] = 0 +"""); + } + + public override async Task Equality_nullable_enum_to_parameter(bool async) + { + await base.Equality_nullable_enum_to_parameter(async); + + AssertSql( + """ +@basicEnum='0' + +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[Enum] = @basicEnum +"""); + } + + public override async Task Equality_nullable_enum_to_null_constant(bool async) + { + await base.Equality_nullable_enum_to_null_constant(async); + + AssertSql( + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[Enum] IS NULL +"""); + } + + public override async Task Equality_nullable_enum_to_null_parameter(bool async) + { + await base.Equality_nullable_enum_to_null_parameter(async); + + AssertSql( + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[Enum] IS NULL +"""); + } + + public override async Task Equality_nullable_enum_to_nullable_parameter(bool async) + { + await base.Equality_nullable_enum_to_nullable_parameter(async); + + AssertSql( + """ +@basicEnum='0' (Nullable = true) + +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[Enum] = @basicEnum +"""); + } + + #endregion Equality + + public override async Task Bitwise_and_enum_constant(bool async) + { + await base.Bitwise_and_enum_constant(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 1 > 0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 1 = 1 +"""); + } + + public override async Task Bitwise_and_integral_constant(bool async) + { + await base.Bitwise_and_integral_constant(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 8 = 8 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[FlagsEnum] AS bigint) & CAST(8 AS bigint) = CAST(8 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[FlagsEnum] AS smallint) & CAST(8 AS smallint) = CAST(8 AS smallint) +"""); + } + + public override async Task Bitwise_and_nullable_enum_with_constant(bool async) + { + await base.Bitwise_and_nullable_enum_with_constant(async); + + AssertSql( + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[FlagsEnum] & 8 > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) + { + await base.Where_bitwise_and_nullable_enum_with_null_constant(async); + + AssertSql( + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[FlagsEnum] & NULL > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) + { + await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' + +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[FlagsEnum] & @flagsEnum > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) + { + await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' (Nullable = true) + +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[FlagsEnum] & @flagsEnum > 0 +""", + // + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[FlagsEnum] & NULL > 0 +"""); + } + + public override async Task Bitwise_or(bool async) + { + await base.Bitwise_or(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] | 8 > 0 +"""); + } + + public override async Task Bitwise_projects_values_in_select(bool async) + { + await base.Bitwise_projects_values_in_select(async); + + AssertSql( + """ +SELECT TOP(1) ~CAST(([b].[FlagsEnum] & 8) ^ 8 AS bit) AS [BitwiseTrue], ~CAST(([b].[FlagsEnum] & 8) ^ 4 AS bit) AS [BitwiseFalse], [b].[FlagsEnum] & 8 AS [BitwiseValue] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 8 = 8 +"""); + } + + public override async Task HasFlag(bool async) + { + await base.HasFlag(async); + +AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 8 = 8 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 12 = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 8 = 8 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 8 = 8 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE 8 & [b].[FlagsEnum] = [b].[FlagsEnum] +""", + // + """ +SELECT TOP(1) ~CAST(([b].[FlagsEnum] & 8) ^ 8 AS bit) AS [hasFlagTrue], ~CAST(([b].[FlagsEnum] & 4) ^ 4 AS bit) AS [hasFlagFalse] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & 8 = 8 +"""); + } + + public override async Task HasFlag_with_non_nullable_parameter(bool async) + { + await base.HasFlag_with_non_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & @flagsEnum = @flagsEnum +"""); + } + + public override async Task HasFlag_with_nullable_parameter(bool async) + { + await base.HasFlag_with_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' (Nullable = true) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[FlagsEnum] & @flagsEnum = @flagsEnum +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServer160Test.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServer160Test.cs new file mode 100644 index 00000000000..734578820f2 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServer160Test.cs @@ -0,0 +1,135 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +[SqlServerCondition(SqlServerCondition.SupportsFunctions2022)] +public class MathTranslationsSqlServer160Test : MathTranslationsTestBase +{ + public MathTranslationsSqlServer160Test(BasicTypesQuerySqlServer160Fixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Max(bool async) + { + await base.Max(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE GREATEST([b].[Int], [b].[Short] - CAST(3 AS smallint)) = [b].[Int] +"""); + } + + public override async Task Max_nested(bool async) + { + await base.Max_nested(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE GREATEST([b].[Short] - CAST(3 AS smallint), [b].[Int], 1) = [b].[Int] +"""); + } + + public override async Task Max_nested_twice(bool async) + { + await base.Max_nested_twice(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE GREATEST(1, [b].[Int], 2, [b].[Short] - CAST(3 AS smallint)) = [b].[Int] +"""); + } + + public override async Task Min(bool async) + { + await base.Min(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LEAST([b].[Int], [b].[Short] + CAST(3 AS smallint)) = [b].[Int] +"""); + } + + public override async Task Min_nested(bool async) + { + await base.Min_nested(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LEAST([b].[Short] + CAST(3 AS smallint), [b].[Int], 99999) = [b].[Int] +"""); + } + + public override async Task Min_nested_twice(bool async) + { + await base.Min_nested_twice(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LEAST(99999, [b].[Int], 99998, [b].[Short] + CAST(3 AS smallint)) = [b].[Int] +"""); + } + + public override async Task Log2(bool async) + => await AssertTranslationFailed(() => base.Log2(async)); + + public override async Task Acosh(bool async) + => await AssertTranslationFailed(() => base.Acosh(async)); + + public override async Task Asinh(bool async) + => await AssertTranslationFailed(() => base.Asinh(async)); + + public override async Task Atanh(bool async) + => await AssertTranslationFailed(() => base.Atanh(async)); + + public override async Task Cosh(bool async) + => await AssertTranslationFailed(() => base.Cosh(async)); + + public override async Task Sinh(bool async) + => await AssertTranslationFailed(() => base.Sinh(async)); + + public override async Task Tan(bool async) + { + await base.Tan(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE TAN([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Tan_float(bool async) + { + await base.Tan_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE TAN([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Tanh(bool async) + => await AssertTranslationFailed(() => base.Tanh(async)); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServerTest.cs new file mode 100644 index 00000000000..706ad7dfea2 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MathTranslationsSqlServerTest.cs @@ -0,0 +1,742 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MathTranslationsSqlServerTest : MathTranslationsTestBase +{ + public MathTranslationsSqlServerTest(BasicTypesQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Abs_decimal(bool async) + { + await base.Abs_decimal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ABS([b].[Decimal]) = 9.5 +"""); + } + + public override async Task Abs_int(bool async) + { + await base.Abs_int(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ABS([b].[Int]) = 9 +"""); + } + + public override async Task Abs_double(bool async) + { + await base.Abs_double(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ABS([b].[Double]) = 9.5E0 +"""); + } + + public override async Task Abs_float(bool async) + { + await base.Abs_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(ABS([b].[Float]) AS float) = 9.5E0 +"""); + } + + public override async Task Ceiling(bool async) + { + await base.Ceiling(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CEILING([b].[Double]) = 9.0E0 +"""); + } + + public override async Task Ceiling_float(bool async) + { + await base.Ceiling_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CEILING([b].[Float]) = CAST(9 AS real) +"""); + } + + public override async Task Floor_decimal(bool async) + { + await base.Floor_decimal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE FLOOR([b].[Decimal]) = 8.0 +"""); + } + + public override async Task Floor_double(bool async) + { + await base.Floor_double(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE FLOOR([b].[Double]) = 8.0E0 +"""); + } + + public override async Task Floor_float(bool async) + { + await base.Floor_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE FLOOR([b].[Float]) = CAST(8 AS real) +"""); + } + + public override async Task Power(bool async) + { + await base.Power(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE POWER(CAST([b].[Int] AS float), 2.0E0) = 64.0E0 +"""); + } + + public override async Task Power_float(bool async) + { + await base.Power_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE POWER([b].[Float], CAST(2 AS real)) > CAST(73 AS real) AND POWER([b].[Float], CAST(2 AS real)) < CAST(74 AS real) +"""); + } + + public override async Task Round_decimal(bool async) + { + await base.Round_decimal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ROUND([b].[Decimal], 0) = 9.0 +""", + // + """ +SELECT ROUND([b].[Decimal], 0) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Round_double(bool async) + { + await base.Round_double(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ROUND([b].[Double], 0) = 9.0E0 +""", + // + """ +SELECT ROUND([b].[Double], 0) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Round_float(bool async) + { + await base.Round_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(ROUND([b].[Float], 0) AS real) = CAST(9 AS real) +""", + // + """ +SELECT CAST(ROUND([b].[Float], 0) AS real) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Round_with_digits_decimal(bool async) + { + await base.Round_with_digits_decimal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ROUND([b].[Decimal], 1) = 255.1 +"""); + } + + public override async Task Round_with_digits_double(bool async) + { + await base.Round_with_digits_double(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ROUND([b].[Double], 1) = 255.09999999999999E0 +"""); + } + + public override async Task Round_with_digits_float(bool async) + { + await base.Round_with_digits_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ROUND(CAST([b].[Float] AS float), 1) = 255.09999999999999E0 +"""); + } + + public override async Task Truncate_decimal(bool async) + { + await base.Truncate_decimal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ROUND([b].[Decimal], 0, 1) = 8.0 +""", + // + """ +SELECT ROUND([b].[Decimal], 0, 1) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Truncate_double(bool async) + { + await base.Truncate_double(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ROUND([b].[Double], 0, 1) = 8.0E0 +""", + // + """ +SELECT ROUND([b].[Double], 0, 1) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Truncate_float(bool async) + { + await base.Truncate_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(ROUND([b].[Float], 0, 1) AS real) = CAST(8 AS real) +""", + // + """ +SELECT CAST(ROUND([b].[Float], 0, 1) AS real) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Truncate_project_and_order_by_it_twice(bool async) + { + await base.Truncate_project_and_order_by_it_twice(async); + + AssertSql( + """ +SELECT ROUND([b].[Double], 0, 1) AS [A] +FROM [BasicTypesEntities] AS [b] +ORDER BY ROUND([b].[Double], 0, 1) +"""); + } + + // issue #16038 + // AssertSql( + // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] + //FROM [Orders] AS [o] + //WHERE [o].[OrderID] < 10250 + //ORDER BY [A]"); + public override async Task Truncate_project_and_order_by_it_twice2(bool async) + { + await base.Truncate_project_and_order_by_it_twice2(async); + + AssertSql( + """ +SELECT ROUND([b].[Double], 0, 1) AS [A] +FROM [BasicTypesEntities] AS [b] +ORDER BY ROUND([b].[Double], 0, 1) DESC +"""); + } + + // issue #16038 + // AssertSql( + // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] + //FROM [Orders] AS [o] + //WHERE [o].[OrderID] < 10250 + //ORDER BY [A] DESC"); + public override async Task Truncate_project_and_order_by_it_twice3(bool async) + { + await base.Truncate_project_and_order_by_it_twice3(async); + + AssertSql( + """ +SELECT ROUND([b].[Double], 0, 1) AS [A] +FROM [BasicTypesEntities] AS [b] +ORDER BY ROUND([b].[Double], 0, 1) DESC +"""); + } + + public override async Task Exp(bool async) + { + await base.Exp(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE EXP([b].[Double]) > 1.0E0 +"""); + } + + public override async Task Exp_float(bool async) + { + await base.Exp_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE EXP([b].[Float]) > CAST(1 AS real) +"""); + } + + public override async Task Log(bool async) + { + await base.Log(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Double] > 0.0E0 AND LOG([b].[Double]) <> 0.0E0 +"""); + } + + public override async Task Log_float(bool async) + { + await base.Log_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Float] > CAST(0 AS real) AND LOG([b].[Float]) <> CAST(0 AS real) +"""); + } + + public override async Task Log_with_newBase(bool async) + { + await base.Log_with_newBase(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Double] > 0.0E0 AND LOG([b].[Double], 7.0E0) <> 0.0E0 +"""); + } + + public override async Task Log_with_newBase_float(bool async) + { + await base.Log_with_newBase_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Float] > CAST(0 AS real) AND LOG([b].[Float], CAST(7 AS real)) <> CAST(0 AS real) +"""); + } + + public override async Task Log10(bool async) + { + await base.Log10(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Double] > 0.0E0 AND LOG10([b].[Double]) <> 0.0E0 +"""); + } + + public override async Task Log10_float(bool async) + { + await base.Log10_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Float] > CAST(0 AS real) AND LOG10([b].[Float]) <> CAST(0 AS real) +"""); + } + + public override async Task Log2(bool async) + => await AssertTranslationFailed(() => base.Log2(async)); + + public override async Task Sqrt(bool async) + { + await base.Sqrt(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Double] > 0.0E0 AND SQRT([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Sqrt_float(bool async) + { + await base.Sqrt_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Float] > CAST(0 AS real) AND SQRT([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Sign(bool async) + { + await base.Sign(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE SIGN([b].[Double]) > 0 +"""); + } + + public override async Task Sign_float(bool async) + { + await base.Sign_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE SIGN([b].[Float]) > 0 +"""); + } + + public override Task Max(bool async) + => AssertTranslationFailed(() => base.Max(async)); + + public override Task Max_nested(bool async) + => AssertTranslationFailed(() => base.Max_nested(async)); + + public override Task Max_nested_twice(bool async) + => AssertTranslationFailed(() => base.Max_nested_twice(async)); + + public override Task Min(bool async) + => AssertTranslationFailed(() => base.Min(async)); + + public override Task Min_nested(bool async) + => AssertTranslationFailed(() => base.Min_nested(async)); + + public override Task Min_nested_twice(bool async) + => AssertTranslationFailed(() => base.Min_nested_twice(async)); + + public override async Task Degrees(bool async) + { + await base.Degrees(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DEGREES([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Degrees_float(bool async) + { + await base.Degrees_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DEGREES([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Radians(bool async) + { + await base.Radians(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE RADIANS([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Radians_float(bool async) + { + await base.Radians_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE RADIANS([b].[Float]) > CAST(0 AS real) +"""); + } + + #region Trigonometry + + public override async Task Acos(bool async) + { + await base.Acos(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Double] >= -1.0E0 AND [b].[Double] <= 1.0E0 AND ACOS([b].[Double]) > 1.0E0 +"""); + } + + public override async Task Acos_float(bool async) + { + await base.Acos_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Float] >= CAST(-1 AS real) AND [b].[Float] <= CAST(1 AS real) AND ACOS([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Acosh(bool async) + => await AssertTranslationFailed(() => base.Acosh(async)); + + public override async Task Asin(bool async) + { + await base.Asin(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Double] >= -1.0E0 AND [b].[Double] <= 1.0E0 AND ASIN([b].[Double]) > -1.7976931348623157E+308 +"""); + } + + public override async Task Asin_float(bool async) + { + await base.Asin_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Float] >= CAST(-1 AS real) AND [b].[Float] <= CAST(1 AS real) AND CAST(ASIN([b].[Float]) AS float) > -1.7976931348623157E+308 +"""); + } + + public override async Task Asinh(bool async) + => await AssertTranslationFailed(() => base.Asinh(async)); + + public override async Task Atan(bool async) + { + await base.Atan(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ATAN([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Atan_float(bool async) + { + await base.Atan_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ATAN([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Atanh(bool async) + => await AssertTranslationFailed(() => base.Atanh(async)); + + public override async Task Atan2(bool async) + { + await base.Atan2(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ATN2([b].[Double], 1.0E0) > 0.0E0 +"""); + } + + public override async Task Atan2_float(bool async) + { + await base.Atan2_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE ATN2([b].[Float], CAST(1 AS real)) > CAST(0 AS real) +"""); + } + + public override async Task Cos(bool async) + { + await base.Cos(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE COS([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Cos_float(bool async) + { + await base.Cos_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE COS([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Cosh(bool async) + => await AssertTranslationFailed(() => base.Cosh(async)); + + public override async Task Sin(bool async) + { + await base.Sin(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE SIN([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Sin_float(bool async) + { + await base.Sin_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE SIN([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Sinh(bool async) + => await AssertTranslationFailed(() => base.Sinh(async)); + + public override async Task Tan(bool async) + { + await base.Tan(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE TAN([b].[Double]) > 0.0E0 +"""); + } + + public override async Task Tan_float(bool async) + { + await base.Tan_float(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE TAN([b].[Float]) > CAST(0 AS real) +"""); + } + + public override async Task Tanh(bool async) + => await AssertTranslationFailed(() => base.Tanh(async)); + + #endregion Trigonometry + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs new file mode 100644 index 00000000000..aff4ff2712d --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqlServerTest.cs @@ -0,0 +1,812 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MiscellaneousTranslationsSqlServerTest : MiscellaneousTranslationsTestBase +{ + public MiscellaneousTranslationsSqlServerTest(BasicTypesQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Guid + + public override async Task Guid_new_with_constant(bool async) + { + await base.Guid_new_with_constant(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Guid] = 'df36f493-463f-4123-83f9-6b135deeb7ba' +"""); + } + + public override async Task Guid_new_with_parameter(bool async) + { + await base.Guid_new_with_parameter(async); + + AssertSql( + """ +@p='df36f493-463f-4123-83f9-6b135deeb7ba' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Guid] = @p +"""); + } + + public override async Task Guid_ToString_projection(bool async) + { + await base.Guid_ToString_projection(async); + + AssertSql( + """ +SELECT CONVERT(varchar(36), [b].[Guid]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Guid_NewGuid(bool async) + { + await base.Guid_NewGuid(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE NEWID() <> '00000000-0000-0000-0000-000000000000' +"""); + } + + #endregion Guid + + #region Byte array + + public override async Task Byte_array_Length(bool async) + { + await base.Byte_array_Length(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(DATALENGTH([b].[ByteArray]) AS int) = 4 +"""); + } + + public override async Task Byte_array_array_index(bool async) + { + await base.Byte_array_array_index(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(DATALENGTH([b].[ByteArray]) AS int) >= 3 AND CAST(SUBSTRING([b].[ByteArray], 2 + 1, 1) AS tinyint) = CAST(190 AS tinyint) +"""); + } + + public override async Task Byte_array_First(bool async) + { + await base.Byte_array_First(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(DATALENGTH([b].[ByteArray]) AS int) >= 1 AND CAST(SUBSTRING([b].[ByteArray], 1, 1) AS tinyint) = CAST(222 AS tinyint) +"""); + } + + #endregion Byte array + + #region Convert + + public override async Task Convert_ToBoolean(bool async) + { + await base.Convert_ToBoolean(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Bool]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Byte]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Decimal]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Double]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Float]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Short]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Int]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Long]) = CAST(1 AS bit) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bit, [b].[Int]) = CAST(1 AS bit) +"""); + } + + public override async Task Convert_ToByte(bool async) + { + await base.Convert_ToByte(async); + +AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(tinyint, [b].[Bool]) = CAST(1 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(tinyint, [b].[Byte]) = CAST(8 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Decimal] >= 0.0 AND [b].[Decimal] <= 255.0 AND CONVERT(tinyint, [b].[Decimal]) = CAST(12 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Double] >= 0.0E0 AND [b].[Double] <= 255.0E0 AND CONVERT(tinyint, [b].[Double]) = CAST(12 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Float] >= CAST(0 AS real) AND [b].[Float] <= CAST(255 AS real) AND CONVERT(tinyint, [b].[Float]) = CAST(12 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Short] >= CAST(0 AS smallint) AND [b].[Short] <= CAST(255 AS smallint) AND CONVERT(tinyint, [b].[Short]) = CAST(12 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] >= 0 AND [b].[Int] <= 255 AND CONVERT(tinyint, [b].[Int]) = CAST(12 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Long] >= CAST(0 AS bigint) AND [b].[Long] <= CAST(255 AS bigint) AND CONVERT(tinyint, [b].[Long]) = CAST(12 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] >= 0 AND [b].[Int] <= 255 AND CONVERT(tinyint, CONVERT(nvarchar(max), [b].[Int])) = CAST(12 AS tinyint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] >= 0 AND [b].[Int] <= 255 AND CONVERT(tinyint, [b].[Int]) = CAST(12 AS tinyint) +"""); + } + + public override async Task Convert_ToDecimal(bool async) + { + await base.Convert_ToDecimal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Bool]) = 1.0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Byte]) = 8.0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Decimal]) = 8.6 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Double]) = 8.6 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Float]) = 8.6 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Short]) = 8.0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Int]) = 8.0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Long]) = 8.0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), CONVERT(nvarchar(max), [b].[Int])) = 8.0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(decimal(18, 2), [b].[Int]) = 8.0 +"""); + } + + public override async Task Convert_ToDouble(bool async) + { + await base.Convert_ToDouble(async); + +AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Bool]) = 1.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Byte]) = 8.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Decimal]) = 8.5999999999999996E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Double]) > 8.0E0 AND CONVERT(float, [b].[Double]) < 9.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Float]) > 8.0E0 AND CONVERT(float, [b].[Float]) < 9.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Short]) = 8.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Int]) = 8.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Long]) = 8.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, CONVERT(nvarchar(max), [b].[Int])) = 8.0E0 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(float, [b].[Int]) = 8.0E0 +"""); + } + + public override async Task Convert_ToInt16(bool async) + { + await base.Convert_ToInt16(async); + +AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Bool]) = CAST(1 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Byte]) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Decimal]) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Double]) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Float]) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Short]) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Int]) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Long]) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, CONVERT(nvarchar(max), [b].[Int])) = CAST(12 AS smallint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(smallint, [b].[Int]) = CAST(12 AS smallint) +"""); + } + + public override async Task Convert_ToInt32(bool async) + { + await base.Convert_ToInt32(async); + +AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Bool]) = 1 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Byte]) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Decimal]) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Double]) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Float]) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Short]) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Int]) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Long]) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, CONVERT(nvarchar(max), [b].[Int])) = 12 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(int, [b].[Int]) = 12 +"""); + } + + public override async Task Convert_ToInt64(bool async) + { + await base.Convert_ToInt64(async); + +AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Bool]) = CAST(1 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Byte]) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Decimal]) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Double]) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Float]) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Short]) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Int]) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Long]) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, CONVERT(nvarchar(max), [b].[Int])) = CAST(12 AS bigint) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(bigint, [b].[Int]) = CAST(12 AS bigint) +"""); + } + + public override async Task Convert_ToString(bool async) + { + await base.Convert_ToString(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Bool]) <> N'' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Byte]) = N'8' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Decimal]) <> N'' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Double]) <> N'' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Float]) <> N'' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Short]) = N'8' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Int]) = N'8' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[Long]) = N'8' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[String]) = N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[String]) = N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(nvarchar(max), [b].[DateTime]) LIKE N'%1998%' +"""); + } + + #endregion Convert + + #region Compare + + public override async Task Int_Compare_to_simple_zero(bool async) + { + await base.Int_Compare_to_simple_zero(async); + +AssertSql( +""" +@orderId='8' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] = @orderId +""", + // + """ +@orderId='8' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] <> @orderId +""", + // + """ +@orderId='8' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] > @orderId +""", + // + """ +@orderId='8' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] <= @orderId +""", + // + """ +@orderId='8' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] > @orderId +""", + // + """ +@orderId='8' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[Int] <= @orderId +"""); + } + + public override async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) + { + await base.DateTime_Compare_to_simple_zero(async, compareTo); + + AssertSql( +""" +@dateTime='1998-05-04T15:30:10.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] = @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] <> @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] > @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] <= @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] > @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] <= @dateTime +"""); + } + + public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) + { + await base.TimeSpan_Compare_to_simple_zero(async, compareTo); + + AssertSql( +""" +@timeSpan='01:02:03' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[TimeSpan] = @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[TimeSpan] <> @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[TimeSpan] > @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[TimeSpan] <= @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[TimeSpan] > @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[TimeSpan] <= @timeSpan +"""); + } + + #endregion Compare + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServer160Test.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServer160Test.cs new file mode 100644 index 00000000000..233027cd807 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServer160Test.cs @@ -0,0 +1,109 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +[SqlServerCondition(SqlServerCondition.SupportsFunctions2022)] +public class StringTranslationsSqlServer160Test : StringTranslationsRelationalTestBase +{ + public StringTranslationsSqlServer160Test(BasicTypesQuerySqlServer160Fixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task TrimStart_with_char_argument(bool async) + { + await base.TrimStart_with_char_argument(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LTRIM([b].[String], N'S') = N'eattle' +"""); + } + + public override async Task TrimStart_with_char_array_argument(bool async) + { + await base.TrimStart_with_char_array_argument(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LTRIM([b].[String], N'Se') = N'attle' +"""); + } + + public override async Task TrimEnd_with_char_argument(bool async) + { + await base.TrimEnd_with_char_argument(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE RTRIM([b].[String], N'e') = N'Seattl' +"""); + } + + public override async Task TrimEnd_with_char_array_argument(bool async) + { + await base.TrimEnd_with_char_array_argument(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE RTRIM([b].[String], N'le') = N'Seatt' +"""); + } + + public override async Task EndsWith_Column(bool async) + { + // SQL Server trims trailing whitespace for length calculations, making our EndsWith() column translation not work reliably in that + // case + await AssertQuery( + async, + ss => ss.Set().Where(b => b.String == "Seattle" && b.String.EndsWith(b.String))); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'Seattle' AND RIGHT([b].[String], LEN([b].[String])) = [b].[String] +"""); + } + + public override async Task Trim_with_char_argument_in_predicate(bool async) + { + // String.Trim with parameters. Issue #22927. + await AssertTranslationFailed(() => base.Trim_with_char_argument_in_predicate(async)); + + AssertSql(); + } + + public override async Task Trim_with_char_array_argument_in_predicate(bool async) + { + // String.Trim with parameters. Issue #22927. + await AssertTranslationFailed(() => base.Trim_with_char_array_argument_in_predicate(async)); + + AssertSql(); + } + + public override Task Regex_IsMatch(bool async) + => AssertTranslationFailed(() => base.Regex_IsMatch(async)); + + public override Task Regex_IsMatch_constant_input(bool async) + => AssertTranslationFailed(() => base.Regex_IsMatch_constant_input(async)); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServerTest.cs new file mode 100644 index 00000000000..7c46cc11b7d --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/StringTranslationsSqlServerTest.cs @@ -0,0 +1,1487 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class StringTranslationsSqlServerTest : StringTranslationsRelationalTestBase +{ + public StringTranslationsSqlServerTest(BasicTypesQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equals + + public override async Task Equals(bool async) + { + await base.Equals(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'Seattle' +"""); + } + + public override async Task Equals_with_OrdinalIgnoreCase(bool async) + { + await base.Equals_with_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task Equals_with_Ordinal(bool async) + { + await base.Equals_with_Ordinal(async); + + AssertSql(); + } + + public override async Task Static_Equals(bool async) + { + await base.Static_Equals(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'Seattle' +"""); + } + + public override async Task Static_Equals_with_OrdinalIgnoreCase(bool async) + { + await base.Static_Equals_with_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task Static_Equals_with_Ordinal(bool async) + { + await base.Static_Equals_with_Ordinal(async); + + AssertSql(); + } + + #endregion Equals + + #region Miscellaneous + + public override async Task Length(bool async) + { + await base.Length(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) = 7 +"""); + } + + public override async Task ToUpper(bool async) + { + await base.ToUpper(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE UPPER([b].[String]) = N'SEATTLE' +"""); + } + + public override async Task ToLower(bool async) + { + await base.ToLower(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LOWER([b].[String]) = N'seattle' +"""); + } + + #endregion Miscellaneous + + #region IndexOf + + public override async Task IndexOf(bool async) + { + await base.IndexOf(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(CHARINDEX(N'eattl', [b].[String]) AS int) - 1 <> -1 +"""); + } + + public override async Task IndexOf_with_empty_string(bool async) + { + await base.IndexOf_with_empty_string(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task IndexOf_with_one_parameter_arg(bool async) + { + await base.IndexOf_with_one_parameter_arg(async); + + AssertSql( + """ +@pattern='eattl' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(CHARINDEX(@pattern, [b].[String]) AS int) - CASE + WHEN @pattern = N'' THEN 0 + ELSE 1 +END = 1 +"""); + + } + + public override async Task IndexOf_with_constant_starting_position(bool async) + { + await base.IndexOf_with_constant_starting_position(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) > 2 AND CAST(CHARINDEX(N'e', [b].[String], 3) AS int) - 1 = 6 +"""); + } + + public override async Task IndexOf_with_parameter_starting_position(bool async) + { + await base.IndexOf_with_parameter_starting_position(async); + + AssertSql( + """ +@start='2' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) > 2 AND CAST(CHARINDEX(N'e', [b].[String], @start + 1) AS int) - 1 = 6 +"""); + } + + public override async Task IndexOf_after_ToString(bool async) + { + await base.IndexOf_after_ToString(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CHARINDEX('55', CONVERT(varchar(11), [b].[Int])) - 1 = 1 +"""); + } + + public override async Task IndexOf_over_ToString(bool async) + { + await base.IndexOf_over_ToString(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CHARINDEX(CONVERT(varchar(11), [b].[Int]), '12559') - CASE + WHEN CONVERT(varchar(11), [b].[Int]) = '' THEN 0 + ELSE 1 +END = 1 +"""); + } + + #endregion IndexOf + + #region Replace + + public override async Task Replace(bool async) + { + await base.Replace(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE REPLACE([b].[String], N'Sea', N'Rea') = N'Reattle' +"""); + } + + public override async Task Replace_with_empty_string(bool async) + { + await base.Replace_with_empty_string(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <> N'' AND REPLACE([b].[String], [b].[String], N'') = N'' +"""); + } + + public override async Task Replace_using_property_arguments(bool async) + { + await base.Replace_using_property_arguments(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <> N'' AND REPLACE([b].[String], [b].[String], CONVERT(varchar(11), [b].[Int])) = CONVERT(varchar(11), [b].[Int]) +"""); + } + + #endregion Replace + + #region Substring + + public override async Task Substring(bool async) + { + await base.Substring(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) >= 3 AND SUBSTRING([b].[String], 1 + 1, 2) = N'ea' +"""); + } + + public override async Task Substring_with_one_arg_with_zero_startIndex(bool async) + { + await base.Substring_with_one_arg_with_zero_startIndex(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE SUBSTRING([b].[String], 0 + 1, LEN([b].[String])) = N'Seattle' +"""); + } + + public override async Task Substring_with_one_arg_with_constant(bool async) + { + await base.Substring_with_one_arg_with_constant(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) >= 1 AND SUBSTRING([b].[String], 1 + 1, LEN([b].[String])) = N'eattle' +"""); + } + + public override async Task Substring_with_one_arg_with_parameter(bool async) + { + await base.Substring_with_one_arg_with_parameter(async); + + AssertSql( + """ +@start='2' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) >= 2 AND SUBSTRING([b].[String], @start + 1, LEN([b].[String])) = N'attle' +"""); + } + + public override async Task Substring_with_two_args_with_zero_startIndex(bool async) + { + await base.Substring_with_two_args_with_zero_startIndex(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) >= 3 AND SUBSTRING([b].[String], 0 + 1, 3) = N'Sea' +"""); + } + + public override async Task Substring_with_two_args_with_zero_length(bool async) + { + await base.Substring_with_two_args_with_zero_length(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) >= 2 AND SUBSTRING([b].[String], 2 + 1, 0) = N'' +"""); + } + + public override async Task Substring_with_two_args_with_parameter(bool async) + { + await base.Substring_with_two_args_with_parameter(async); + + AssertSql( + """ +@start='2' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(LEN([b].[String]) AS int) >= 5 AND SUBSTRING([b].[String], @start + 1, 3) = N'att' +"""); + } + + public override async Task Substring_with_two_args_with_IndexOf(bool async) + { + await base.Substring_with_two_args_with_IndexOf(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE N'%a%' AND SUBSTRING([b].[String], (CAST(CHARINDEX(N'a', [b].[String]) AS int) - 1) + 1, 3) = N'att' +"""); + } + + #endregion Substring + + #region IsNullOrEmpty/Whitespace + + public override async Task IsNullOrEmpty(bool async) + { + await base.IsNullOrEmpty(async); + + AssertSql( + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[String] IS NULL OR [n].[String] LIKE N'' +""", + // + """ +SELECT CASE + WHEN [n].[String] IS NULL OR [n].[String] LIKE N'' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [NullableBasicTypesEntities] AS [n] +"""); + } + + public override async Task IsNullOrEmpty_negated(bool async) + { + await base.IsNullOrEmpty_negated(async); + + AssertSql( + """ +SELECT [n].[Id], [n].[Bool], [n].[Byte], [n].[ByteArray], [n].[DateOnly], [n].[DateTime], [n].[DateTimeOffset], [n].[Decimal], [n].[Double], [n].[Enum], [n].[FlagsEnum], [n].[Float], [n].[Guid], [n].[Int], [n].[Long], [n].[Short], [n].[String], [n].[TimeOnly], [n].[TimeSpan] +FROM [NullableBasicTypesEntities] AS [n] +WHERE [n].[String] IS NOT NULL AND [n].[String] NOT LIKE N'' +""", + // + """ +SELECT CASE + WHEN [n].[String] IS NOT NULL AND [n].[String] NOT LIKE N'' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [NullableBasicTypesEntities] AS [n] +"""); + } + + public override async Task IsNullOrWhiteSpace(bool async) + { + await base.IsNullOrWhiteSpace(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'' +"""); + } + + #endregion IsNullOrEmpty/Whitespace + + #region StartsWith + + public override async Task StartsWith_Literal(bool async) + { + await base.StartsWith_Literal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE N'Se%' +"""); + } + + public override async Task StartsWith_Parameter(bool async) + { + await base.StartsWith_Parameter(async); + + AssertSql( + """ +@pattern_startswith='Se%' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE @pattern_startswith ESCAPE N'\' +"""); + } + + public override async Task StartsWith_Column(bool async) + { + await base.StartsWith_Column(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LEFT([b].[String], LEN([b].[String])) = [b].[String] +"""); + } + + public override async Task StartsWith_with_StringComparison_Ordinal(bool async) + { + await base.StartsWith_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.StartsWith_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task StartsWith_with_StringComparison_unsupported(bool async) + { + await base.StartsWith_with_StringComparison_unsupported(async); + + AssertSql(); + } + + #endregion StartsWith + + #region EndsWith + + public override async Task EndsWith_Literal(bool async) + { + await base.EndsWith_Literal(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE N'%le' +"""); + } + + public override async Task EndsWith_Parameter(bool async) + { + await base.EndsWith_Parameter(async); + + AssertSql( + """ +@pattern_endswith='%le' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE @pattern_endswith ESCAPE N'\' +"""); + } + + public override async Task EndsWith_Column(bool async) + { + // SQL Server trims trailing whitespace for length calculations, making our EndsWith() column translation not work reliably in that + // case + await AssertQuery( + async, + ss => ss.Set().Where(b => b.String == "Seattle" && b.String.EndsWith(b.String))); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'Seattle' AND RIGHT([b].[String], LEN([b].[String])) = [b].[String] +"""); + } + + public override async Task EndsWith_with_StringComparison_Ordinal(bool async) + { + await base.EndsWith_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.EndsWith_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task EndsWith_with_StringComparison_unsupported(bool async) + { + await base.EndsWith_with_StringComparison_unsupported(async); + + AssertSql(); + } + + #endregion EndsWith + + #region Contains + + public override async Task Contains_Literal(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(c => c.String.Contains("eattl")), // SQL Server is case-insensitive by default + ss => ss.Set().Where(c => c.String.Contains("eattl", StringComparison.OrdinalIgnoreCase))); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE N'%eattl%' +"""); + } + + public override async Task Contains_Column(bool async) + { + await base.Contains_Column(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CHARINDEX([b].[String], [b].[String]) > 0 OR [b].[String] LIKE N'' +""", + // + """ +SELECT CASE + WHEN CHARINDEX([b].[String], [b].[String]) > 0 OR [b].[String] LIKE N'' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Contains_negated(bool async) + { + await base.Contains_negated(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] NOT LIKE N'%eattle%' +""", + // + """ +SELECT CASE + WHEN [b].[String] NOT LIKE N'%eattle%' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task Contains_with_StringComparison_Ordinal(bool async) + { + await base.Contains_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task Contains_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.Contains_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task Contains_with_StringComparison_unsupported(bool async) + { + await base.Contains_with_StringComparison_unsupported(async); + + AssertSql(); + } + + public override async Task Contains_constant_with_whitespace(bool async) + { + await base.Contains_constant_with_whitespace(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE N'% %' +"""); + } + + public override async Task Contains_parameter_with_whitespace(bool async) + { + await base.Contains_parameter_with_whitespace(async); + + AssertSql( + """ +@pattern_contains='% %' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE @pattern_contains ESCAPE N'\' +"""); + } + + #endregion Contains + + #region TrimStart + + public override async Task TrimStart_without_arguments(bool async) + { + await base.TrimStart_without_arguments(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LTRIM([b].[String]) = N'Boston ' +"""); + } + + public override Task TrimStart_with_char_argument(bool async) + => AssertTranslationFailed(() => base.TrimStart_with_char_argument(async)); + + public override Task TrimStart_with_char_array_argument(bool async) + => AssertTranslationFailed(() => base.TrimStart_with_char_array_argument(async)); + + #endregion TrimStart + + #region TrimEnd + + public override async Task TrimEnd_without_arguments(bool async) + { + await base.TrimEnd_without_arguments(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE RTRIM([b].[String]) = N' Boston' +"""); + } + + public override Task TrimEnd_with_char_argument(bool async) + => AssertTranslationFailed(() => base.TrimEnd_with_char_argument(async)); + + public override Task TrimEnd_with_char_array_argument(bool async) + => AssertTranslationFailed(() => base.TrimEnd_with_char_array_argument(async)); + + #endregion TrimEnd + + #region Trim + + public override async Task Trim_without_argument_in_predicate(bool async) + { + await base.Trim_without_argument_in_predicate(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE LTRIM(RTRIM([b].[String])) = N'Boston' +"""); + } + + public override async Task Trim_with_char_argument_in_predicate(bool async) + { + // String.Trim with parameters. Issue #22927. + await AssertTranslationFailed(() => base.Trim_with_char_argument_in_predicate(async)); + + AssertSql(); + } + + public override async Task Trim_with_char_array_argument_in_predicate(bool async) + { + // String.Trim with parameters. Issue #22927. + await AssertTranslationFailed(() => base.Trim_with_char_array_argument_in_predicate(async)); + + AssertSql(); + } + + #endregion Trim + + #region Compare + + public override async Task Compare_simple_zero(bool async) + { + await base.Compare_simple_zero(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <> N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +"""); + } + + public override async Task Compare_simple_one(bool async) + { + await base.Compare_simple_one(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] < N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= N'Seattle' +"""); + } + + public override async Task Compare_with_parameter(bool async) + { + await base.Compare_with_parameter(async); + + AssertSql( + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] < @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= @basicTypeEntity_String +"""); + } + + public override async Task Compare_simple_more_than_one(bool async) + { + await base.Compare_simple_more_than_one(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CASE + WHEN [b].[String] = N'Seattle' THEN 0 + WHEN [b].[String] > N'Seattle' THEN 1 + WHEN [b].[String] < N'Seattle' THEN -1 +END = 42 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CASE + WHEN [b].[String] = N'Seattle' THEN 0 + WHEN [b].[String] > N'Seattle' THEN 1 + WHEN [b].[String] < N'Seattle' THEN -1 +END > 42 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE 42 > CASE + WHEN [b].[String] = N'Seattle' THEN 0 + WHEN [b].[String] > N'Seattle' THEN 1 + WHEN [b].[String] < N'Seattle' THEN -1 +END +"""); + } + + public override async Task Compare_nested(bool async) + { + await base.Compare_nested(async); + + AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'M' + [b].[String] +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <> SUBSTRING([b].[String], 0 + 1, 0) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > REPLACE(N'Seattle', N'Sea', [b].[String]) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'M' + [b].[String] +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > SUBSTRING([b].[String], 0 + 1, 0) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] < REPLACE(N'Seattle', N'Sea', [b].[String]) +"""); + } + + public override async Task Compare_multi_predicate(bool async) + { + await base.Compare_multi_predicate(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= N'Seattle' AND [b].[String] < N'Toronto' +"""); + } + + public override async Task CompareTo_simple_zero(bool async) + { + await base.CompareTo_simple_zero(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <> N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +"""); + } + + public override async Task CompareTo_simple_one(bool async) + { + await base.CompareTo_simple_one(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] < N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= N'Seattle' +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= N'Seattle' +"""); + } + + public override async Task CompareTo_with_parameter(bool async) + { + await base.CompareTo_with_parameter(async); + + AssertSql( + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] < @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= @basicTypesEntity_String +"""); + } + + public override async Task CompareTo_simple_more_than_one(bool async) + { + await base.CompareTo_simple_more_than_one(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CASE + WHEN [b].[String] = N'Seattle' THEN 0 + WHEN [b].[String] > N'Seattle' THEN 1 + WHEN [b].[String] < N'Seattle' THEN -1 +END = 42 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CASE + WHEN [b].[String] = N'Seattle' THEN 0 + WHEN [b].[String] > N'Seattle' THEN 1 + WHEN [b].[String] < N'Seattle' THEN -1 +END > 42 +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE 42 > CASE + WHEN [b].[String] = N'Seattle' THEN 0 + WHEN [b].[String] > N'Seattle' THEN 1 + WHEN [b].[String] < N'Seattle' THEN -1 +END +"""); + } + + public override async Task CompareTo_nested(bool async) + { + await base.CompareTo_nested(async); + + AssertSql( +""" +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] = N'M' + [b].[String] +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <> SUBSTRING([b].[String], 0 + 1, 0) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > REPLACE(N'Seattle', N'Sea', [b].[String]) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] <= N'M' + [b].[String] +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] > SUBSTRING([b].[String], 0 + 1, 0) +""", + // + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] < REPLACE(N'Seattle', N'Sea', [b].[String]) +"""); + } + + public override async Task Compare_to_multi_predicate(bool async) + { + await base.Compare_to_multi_predicate(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] >= N'Seattle' AND [b].[String] < N'Toronto' +"""); + } + + #endregion Compare + + #region Join + + [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] + public override async Task Join_over_non_nullable_column(bool async) + { + await base.Join_over_non_nullable_column(async); + + AssertSql( + """ +SELECT [b].[Int] AS [Key], COALESCE(STRING_AGG([b].[String], N'|'), N'') AS [Strings] +FROM [BasicTypesEntities] AS [b] +GROUP BY [b].[Int] +"""); + } + + [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] + public override async Task Join_over_nullable_column(bool async) + { + await base.Join_over_nullable_column(async); + + AssertSql( + """ +SELECT [n0].[Key], COALESCE(STRING_AGG(COALESCE([n0].[String], N''), N'|'), N'') AS [Regions] +FROM ( + SELECT [n].[String], COALESCE([n].[Int], 0) AS [Key] + FROM [NullableBasicTypesEntities] AS [n] +) AS [n0] +GROUP BY [n0].[Key] +"""); + } + + [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] + public override async Task Join_with_predicate(bool async) + { + await base.Join_with_predicate(async); + + AssertSql( + """ +SELECT [b].[Int] AS [Key], COALESCE(STRING_AGG(CASE + WHEN CAST(LEN([b].[String]) AS int) > 6 THEN [b].[String] +END, N'|'), N'') AS [Strings] +FROM [BasicTypesEntities] AS [b] +GROUP BY [b].[Int] +"""); + } + + [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] + public override async Task Join_with_ordering(bool async) + { + await base.Join_with_ordering(async); + + AssertSql( + """ +SELECT [b].[Int] AS [Key], COALESCE(STRING_AGG([b].[String], N'|') WITHIN GROUP (ORDER BY [b].[Id] DESC), N'') AS [Strings] +FROM [BasicTypesEntities] AS [b] +GROUP BY [b].[Int] +"""); + } + + [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] + public override async Task Join_non_aggregate(bool async) + { + await base.Join_non_aggregate(async); + + AssertSql( + """ +@foo='foo' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONCAT_WS(N'|', [b].[String], @foo, N'', N'bar') = N'Seattle|foo||bar' +"""); + } + + #endregion Join + + #region Concatenation + + [SqlServerCondition(SqlServerCondition.SupportsFunctions2017)] + public override async Task Concat_aggregate(bool async) + { + await base.Concat_aggregate(async); + + AssertSql( + """ +SELECT [b].[Int] AS [Key], COALESCE(STRING_AGG([b].[String], N''), N'') AS [BasicTypesEntitys] +FROM [BasicTypesEntities] AS [b] +GROUP BY [b].[Int] +"""); + } + + public override async Task Concat_string_int_comparison1(bool async) + { + await base.Concat_string_int_comparison1(async); + + AssertSql( + """ +@i='10' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] + CAST(@i AS nvarchar(max)) = N'Seattle10' +"""); + } + + public override async Task Concat_string_int_comparison2(bool async) + { + await base.Concat_string_int_comparison2(async); + + AssertSql( + """ +@i='10' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(@i AS nvarchar(max)) + [b].[String] = N'10Seattle' +"""); + } + + public override async Task Concat_string_int_comparison3(bool async) + { + await base.Concat_string_int_comparison3(async); + + AssertSql( + """ +@p='30' +@j='21' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST(@p AS nvarchar(max)) + [b].[String] + CAST(@j AS nvarchar(max)) + CAST(42 AS nvarchar(max)) = N'30Seattle2142' +"""); + } + + public override async Task Concat_string_int_comparison4(bool async) + { + await base.Concat_string_int_comparison4(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[Int] AS nvarchar(max)) + [b].[String] = N'8Seattle' +"""); + } + + public override async Task Concat_string_string_comparison(bool async) + { + await base.Concat_string_string_comparison(async); + + AssertSql( + """ +@i='A' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE @i + [b].[String] = N'ASeattle' +"""); + } + + public override async Task Concat_method_comparison(bool async) + { + await base.Concat_method_comparison(async); + + AssertSql( + """ +@i='A' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE @i + [b].[String] = N'ASeattle' +"""); + } + + public override async Task Concat_method_comparison_2(bool async) + { + await base.Concat_method_comparison_2(async); + + AssertSql( + """ +@i='A' (Size = 4000) +@j='B' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE @i + @j + [b].[String] = N'ABSeattle' +"""); + } + + public override async Task Concat_method_comparison_3(bool async) + { + await base.Concat_method_comparison_3(async); + + AssertSql( + """ +@i='A' (Size = 4000) +@j='B' (Size = 4000) +@k='C' (Size = 4000) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE @i + @j + @k + [b].[String] = N'ABCSeattle' +"""); + } + + #endregion Concatenation + + #region LINQ Operators + + public override async Task FirstOrDefault(bool async) + { + await base.FirstOrDefault(async); + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE SUBSTRING([b].[String], 1, 1) = N'S' +"""); + } + + public override async Task LastOrDefault(bool async) + { + await base.LastOrDefault(async); + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE SUBSTRING([b].[String], LEN([b].[String]), 1) = N'e' +"""); + } + + #endregion LINQ Operators + + #region Like + + public override async Task Where_Like_and_comparison(bool async) + { + await base.Where_Like_and_comparison(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE N'S%' AND [b].[Int] = 8 +"""); + } + + public override async Task Where_Like_or_comparison(bool async) + { + await base.Where_Like_or_comparison(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[String] LIKE N'S%' OR [b].[Int] = 2147483647 +"""); + } + + public override async Task Like_with_non_string_column_using_ToString(bool async) + { + await base.Like_with_non_string_column_using_ToString(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(varchar(11), [b].[Int]) LIKE '%5%' +"""); + } + + public override async Task Like_with_non_string_column_using_double_cast(bool async) + { + await base.Like_with_non_string_column_using_double_cast(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[Int] AS nvarchar(max)) LIKE N'%5%' +"""); + } + + #endregion Like + + #region Regex + + public override Task Regex_IsMatch(bool async) + => AssertTranslationFailed(() => base.Regex_IsMatch(async)); + + public override Task Regex_IsMatch_constant_input(bool async) + => AssertTranslationFailed(() => base.Regex_IsMatch_constant_input(async)); + + #endregion Regex + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + + protected override void ClearLog() + => Fixture.TestSqlLoggerFactory.Clear(); +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs new file mode 100644 index 00000000000..93a4689ca6a --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Translations/TemporalTranslationsSqlServerTest.cs @@ -0,0 +1,909 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class TemporalTranslationsSqlServerTest : TemporalTranslationsTestBase +{ + public TemporalTranslationsSqlServerTest(BasicTypesQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region DateTime + + public override async Task DateTime_Now(bool async) + { + await base.DateTime_Now(async); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE GETDATE() <> @myDatetime +"""); + } + + public override async Task DateTime_UtcNow(bool async) + { + await base.DateTime_UtcNow(async); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE GETUTCDATE() <> @myDatetime +"""); + } + + public override async Task DateTime_Today(bool async) + { + await base.DateTime_Today(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTime] = CONVERT(date, GETDATE()) +"""); + } + + public override async Task DateTime_Date(bool async) + { + await base.DateTime_Date(async); + + AssertSql( + """ +@myDatetime='1998-05-04T00:00:00.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(date, [b].[DateTime]) = @myDatetime +"""); + } + + public override async Task DateTime_AddYear(bool async) + { + await base.DateTime_AddYear(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(year, DATEADD(year, CAST(1 AS int), [b].[DateTime])) = 1999 +"""); + } + + public override async Task DateTime_Year(bool async) + { + await base.DateTime_Year(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(year, [b].[DateTime]) = 1998 +"""); + } + + public override async Task DateTime_Month(bool async) + { + await base.DateTime_Month(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(month, [b].[DateTime]) = 5 +"""); + } + + public override async Task DateTime_DayOfYear(bool async) + { + await base.DateTime_DayOfYear(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(dayofyear, [b].[DateTime]) = 124 +"""); + } + + public override async Task DateTime_Day(bool async) + { + await base.DateTime_Day(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(day, [b].[DateTime]) = 4 +"""); + } + + public override async Task DateTime_Hour(bool async) + { + await base.DateTime_Hour(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(hour, [b].[DateTime]) = 15 +"""); + } + + public override async Task DateTime_Minute(bool async) + { + await base.DateTime_Minute(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(minute, [b].[DateTime]) = 30 +"""); + } + + public override async Task DateTime_Second(bool async) + { + await base.DateTime_Second(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(second, [b].[DateTime]) = 10 +"""); + } + + public override async Task DateTime_Millisecond(bool async) + { + await base.DateTime_Millisecond(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(millisecond, [b].[DateTime]) = 123 +"""); + } + + public override async Task DateTime_TimeOfDay(bool async) + { + await base.DateTime_TimeOfDay(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(time, [b].[DateTime]) = '00:00:00' +"""); + } + + public override Task DateTime_subtract_and_TotalDays(bool async) + => AssertTranslationFailed(() => base.DateTime_subtract_and_TotalDays(async)); + + #endregion DateTime + + #region DateOnly + + public override async Task DateOnly_Year(bool async) + { + await base.DateOnly_Year(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(year, [b].[DateOnly]) = 1990 +"""); + } + + public override async Task DateOnly_Month(bool async) + { + await base.DateOnly_Month(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(month, [b].[DateOnly]) = 11 +"""); + } + + public override async Task DateOnly_Day(bool async) + { + await base.DateOnly_Day(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(day, [b].[DateOnly]) = 10 +"""); + } + + public override async Task DateOnly_DayOfYear(bool async) + { + await base.DateOnly_DayOfYear(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(dayofyear, [b].[DateOnly]) = 314 +"""); + } + + public override async Task DateOnly_DayOfWeek(bool async) + { + await AssertTranslationFailed(() => base.DateOnly_DayOfWeek(async)); + + AssertSql(); + } + + public override async Task DateOnly_AddYears(bool async) + { + await base.DateOnly_AddYears(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEADD(year, CAST(3 AS int), [b].[DateOnly]) = '1993-11-10' +"""); + } + + public override async Task DateOnly_AddMonths(bool async) + { + await base.DateOnly_AddMonths(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEADD(month, CAST(3 AS int), [b].[DateOnly]) = '1991-02-10' +"""); + } + + public override async Task DateOnly_AddDays(bool async) + { + await base.DateOnly_AddDays(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEADD(day, CAST(3 AS int), [b].[DateOnly]) = '1990-11-13' +"""); + } + + public override async Task DateOnly_FromDateTime(bool async) + { + await base.DateOnly_FromDateTime(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[DateTime] AS date) = '1998-05-04' +"""); + } + + public override async Task DateOnly_FromDateTime_compared_to_property(bool async) + { + await base.DateOnly_FromDateTime_compared_to_property(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[DateTime] AS date) = [b].[DateOnly] +"""); + } + + public override async Task DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + { + await base.DateOnly_FromDateTime_compared_to_constant_and_parameter(async); + + AssertSql( + """ +@dateOnly='10/11/0002' (DbType = Date) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[DateTime] AS date) IN (@dateOnly, '1998-05-04') +"""); + } + + #endregion DateOnly + + #region TimeOnly + + public override async Task TimeOnly_Hour(bool async) + { + await base.TimeOnly_Hour(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(hour, [b].[TimeOnly]) = 15 +"""); + } + + public override async Task TimeOnly_Minute(bool async) + { + await base.TimeOnly_Minute(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(minute, [b].[TimeOnly]) = 30 +"""); + } + + public override async Task TimeOnly_Second(bool async) + { + await base.TimeOnly_Second(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(second, [b].[TimeOnly]) = 10 +"""); + } + + public override async Task TimeOnly_Millisecond(bool async) + { + await base.TimeOnly_Millisecond(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(millisecond, [b].[TimeOnly]) = 123 +"""); + } + + public override async Task TimeOnly_Microsecond(bool async) + { + await base.TimeOnly_Microsecond(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(microsecond, [b].[TimeOnly]) % 1000 = 456 +"""); + } + + public override async Task TimeOnly_Nanosecond(bool async) + { + await base.TimeOnly_Nanosecond(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(nanosecond, [b].[TimeOnly]) % 1000 = 400 +"""); + } + + public override async Task TimeOnly_AddHours(bool async) + { + await base.TimeOnly_AddHours(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEADD(hour, CAST(3.0E0 AS int), [b].[TimeOnly]) = '18:30:10' +"""); + } + + public override async Task TimeOnly_AddMinutes(bool async) + { + await base.TimeOnly_AddMinutes(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEADD(minute, CAST(3.0E0 AS int), [b].[TimeOnly]) = '15:33:10' +"""); + } + + public override async Task TimeOnly_Add_TimeSpan(bool async) + { + await AssertTranslationFailed(() => base.TimeOnly_Add_TimeSpan(async)); + + AssertSql(); + } + + public override async Task TimeOnly_IsBetween(bool async) + { + await base.TimeOnly_IsBetween(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CASE + WHEN [b].[TimeOnly] >= '14:00:00' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END & CASE + WHEN [b].[TimeOnly] < '16:00:00' THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END = CAST(1 AS bit) +"""); + } + + public override async Task TimeOnly_subtract_TimeOnly(bool async) + { + await AssertTranslationFailed(() => base.TimeOnly_subtract_TimeOnly(async)); + + AssertSql(); + } + + public override async Task TimeOnly_FromDateTime_compared_to_property(bool async) + { + await base.TimeOnly_FromDateTime_compared_to_property(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[DateTime] AS time) = [b].[TimeOnly] +"""); + } + + public override async Task TimeOnly_FromDateTime_compared_to_parameter(bool async) + { + await base.TimeOnly_FromDateTime_compared_to_parameter(async); + + AssertSql( + """ +@time='15:30' (DbType = Time) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[DateTime] AS time) = @time +"""); + } + + public override async Task TimeOnly_FromDateTime_compared_to_constant(bool async) + { + await base.TimeOnly_FromDateTime_compared_to_constant(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[DateTime] AS time) = '15:30:10' +"""); + } + + public override async Task TimeOnly_FromTimeSpan_compared_to_property(bool async) + { + await base.TimeOnly_FromTimeSpan_compared_to_property(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[TimeSpan] AS time) < [b].[TimeOnly] +"""); + } + + public override async Task TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + { + await base.TimeOnly_FromTimeSpan_compared_to_parameter(async); + + AssertSql( + """ +@time='01:02' (DbType = Time) + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CAST([b].[TimeSpan] AS time) = @time +"""); + } + + public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) + { + await base.Order_by_TimeOnly_FromTimeSpan(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +ORDER BY CAST([b].[TimeSpan] AS time) +"""); + } + + #endregion TimeOnly + + #region DateTimeOffset + + public override async Task DateTimeOffset_Now(bool async) + { + await base.DateTimeOffset_Now(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTimeOffset] <> SYSDATETIMEOFFSET() +"""); + } + + public override async Task DateTimeOffset_UtcNow(bool async) + { + await base.DateTimeOffset_UtcNow(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTimeOffset] <> CAST(SYSUTCDATETIME() AS datetimeoffset) +"""); + } + + public override async Task DateTimeOffset_Date(bool async) + { + await base.DateTimeOffset_Date(async); + + AssertSql( + """ +@Date='0001-01-01T00:00:00.0000000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE CONVERT(date, [b].[DateTimeOffset]) > @Date +"""); + } + + public override async Task DateTimeOffset_Year(bool async) + { + await base.DateTimeOffset_Year(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(year, [b].[DateTimeOffset]) = 1998 +"""); + } + + public override async Task DateTimeOffset_Month(bool async) + { + await base.DateTimeOffset_Month(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(month, [b].[DateTimeOffset]) = 5 +"""); + } + + public override async Task DateTimeOffset_DayOfYear(bool async) + { + await base.DateTimeOffset_DayOfYear(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(dayofyear, [b].[DateTimeOffset]) = 124 +"""); + } + + public override async Task DateTimeOffset_Day(bool async) + { + await base.DateTimeOffset_Day(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(day, [b].[DateTimeOffset]) = 4 +"""); + } + + public override async Task DateTimeOffset_Hour(bool async) + { + await base.DateTimeOffset_Hour(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(hour, [b].[DateTimeOffset]) = 15 +"""); + } + + public override async Task DateTimeOffset_Minute(bool async) + { + await base.DateTimeOffset_Minute(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(minute, [b].[DateTimeOffset]) = 30 +"""); + } + + public override async Task DateTimeOffset_Second(bool async) + { + await base.DateTimeOffset_Second(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(second, [b].[DateTimeOffset]) = 10 +"""); + } + + public override async Task DateTimeOffset_Millisecond(bool async) + { + await base.DateTimeOffset_Millisecond(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(millisecond, [b].[DateTimeOffset]) = 123 +"""); + } + + public override async Task DateTimeOffset_Microsecond(bool async) + { + await base.DateTimeOffset_Microsecond(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(microsecond, [b].[DateTimeOffset]) % 1000 = 456 +"""); + } + + public override async Task DateTimeOffset_Nanosecond(bool async) + { + await base.DateTimeOffset_Nanosecond(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(nanosecond, [b].[DateTimeOffset]) % 1000 = 400 +"""); + } + + public override async Task DateTimeOffset_TimeOfDay(bool async) + { + await base.DateTimeOffset_TimeOfDay(async); + + AssertSql( + """ +SELECT CONVERT(time, [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_AddYears(bool async) + { + await base.DateTimeOffset_AddYears(async); + + AssertSql( + """ +SELECT DATEADD(year, CAST(1 AS int), [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_AddMonths(bool async) + { + await base.DateTimeOffset_AddMonths(async); + + AssertSql( + """ +SELECT DATEADD(month, CAST(1 AS int), [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_AddDays(bool async) + { + await base.DateTimeOffset_AddDays(async); + + AssertSql( + """ +SELECT DATEADD(day, CAST(1.0E0 AS int), [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_AddHours(bool async) + { + await base.DateTimeOffset_AddHours(async); + + AssertSql( + """ +SELECT DATEADD(hour, CAST(1.0E0 AS int), [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_AddMinutes(bool async) + { + await base.DateTimeOffset_AddMinutes(async); + + AssertSql( + """ +SELECT DATEADD(minute, CAST(1.0E0 AS int), [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_AddSeconds(bool async) + { + await base.DateTimeOffset_AddSeconds(async); + + AssertSql( + """ +SELECT DATEADD(second, CAST(1.0E0 AS int), [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_AddMilliseconds(bool async) + { + await base.DateTimeOffset_AddMilliseconds(async); + + AssertSql( + """ +SELECT DATEADD(millisecond, CAST(300.0E0 AS int), [b].[DateTimeOffset]) +FROM [BasicTypesEntities] AS [b] +"""); + } + + public override async Task DateTimeOffset_ToUnixTimeMilliseconds(bool async) + { + await base.DateTimeOffset_ToUnixTimeMilliseconds(async); + + AssertSql( + """ +@unixEpochMilliseconds='894295810000' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEDIFF_BIG(millisecond, '1970-01-01T00:00:00.0000000+00:00', [b].[DateTimeOffset]) = @unixEpochMilliseconds +"""); + } + + public override async Task DateTimeOffset_ToUnixTimeSecond(bool async) + { + await base.DateTimeOffset_ToUnixTimeSecond(async); + + AssertSql( + """ +@unixEpochSeconds='894295810' + +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEDIFF_BIG(second, '1970-01-01T00:00:00.0000000+00:00', [b].[DateTimeOffset]) = @unixEpochSeconds +"""); + } + + public override async Task DateTimeOffset_milliseconds_parameter_and_constant(bool async) + { + await base.DateTimeOffset_milliseconds_parameter_and_constant(async); + + AssertSql( + """ +SELECT COUNT(*) +FROM [BasicTypesEntities] AS [b] +WHERE [b].[DateTimeOffset] = '1902-01-02T10:00:00.1234567+01:30' +"""); + } + + #endregion DateTimeOffset + + #region TimeSpan + + public override async Task TimeSpan_Hours(bool async) + { + await base.TimeSpan_Hours(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(hour, [b].[TimeSpan]) = 3 +"""); + } + + public override async Task TimeSpan_Minutes(bool async) + { + await base.TimeSpan_Minutes(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(minute, [b].[TimeSpan]) = 4 +"""); + } + + public override async Task TimeSpan_Seconds(bool async) + { + await base.TimeSpan_Seconds(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(second, [b].[TimeSpan]) = 5 +"""); + } + + public override async Task TimeSpan_Milliseconds(bool async) + { + await base.TimeSpan_Milliseconds(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(millisecond, [b].[TimeSpan]) = 678 +"""); + } + + public override async Task TimeSpan_Microseconds(bool async) + { + await base.TimeSpan_Microseconds(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(microsecond, [b].[TimeSpan]) % 1000 = 912 +"""); + } + + public override async Task TimeSpan_Nanoseconds(bool async) + { + await base.TimeSpan_Nanoseconds(async); + + AssertSql( + """ +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] +FROM [BasicTypesEntities] AS [b] +WHERE DATEPART(nanosecond, [b].[TimeSpan]) % 1000 = 400 +"""); + } + + #endregion TimeSpan + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs index 875bb0fc385..6038f2f2c53 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/GearsOfWarQuerySqliteTest.cs @@ -33,83 +33,6 @@ public override async Task Non_string_concat_uses_appropriate_type_mapping(bool """); } - public override async Task Where_datetimeoffset_date_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_day_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_dayofyear_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_dayofyear_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_hour_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_hour_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_millisecond_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_millisecond_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_minute_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_minute_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_month_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_month_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_now(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_now(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_second_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_second_component(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_utcnow(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow(async)); - - AssertSql(); - } - - public override async Task Where_datetimeoffset_year_component(bool async) - { - await AssertTranslationFailed(() => base.Where_datetimeoffset_year_component(async)); - - AssertSql(); - } - public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) { await AssertTranslationFailed(() => base.DateTimeOffset_Contains_Less_than_Greater_than(async)); @@ -450,329 +373,6 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async) """); } - public override async Task Where_TimeSpan_Hours(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeSpan_Hours(async)); - - AssertSql(); - } - - public override async Task Where_TimeSpan_Minutes(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeSpan_Minutes(async)); - - AssertSql(); - } - - public override async Task Where_TimeSpan_Seconds(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeSpan_Seconds(async)); - - AssertSql(); - } - - public override async Task Where_TimeSpan_Milliseconds(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeSpan_Milliseconds(async)); - - AssertSql(); - } - - public override async Task First_on_byte_array(bool async) - { - // Array access. Issue #16428. - await AssertTranslationFailed(() => base.First_on_byte_array(async)); - - AssertSql(); - } - - public override async Task Array_access_on_byte_array(bool async) - { - // Array access. Issue #16428. - await AssertTranslationFailed(() => base.Array_access_on_byte_array(async)); - - AssertSql(); - } - - public override async Task Where_DateOnly_Year(bool async) - { - await base.Where_DateOnly_Year(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE CAST(strftime('%Y', "m"."Date") AS INTEGER) = 1990 -"""); - } - - public override async Task Where_DateOnly_Month(bool async) - { - await base.Where_DateOnly_Month(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE CAST(strftime('%m', "m"."Date") AS INTEGER) = 11 -"""); - } - - public override async Task Where_DateOnly_Day(bool async) - { - await base.Where_DateOnly_Day(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE CAST(strftime('%d', "m"."Date") AS INTEGER) = 10 -"""); - } - - public override async Task Where_DateOnly_DayOfYear(bool async) - { - await base.Where_DateOnly_DayOfYear(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE CAST(strftime('%j', "m"."Date") AS INTEGER) = 314 -"""); - } - - public override async Task Where_DateOnly_DayOfWeek(bool async) - { - await base.Where_DateOnly_DayOfWeek(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE CAST(strftime('%w', "m"."Date") AS INTEGER) = 6 -"""); - } - - public override async Task Where_DateOnly_AddYears(bool async) - { - await base.Where_DateOnly_AddYears(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE date("m"."Date", CAST(3 AS TEXT) || ' years') = '1993-11-10' -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_DateOnly_AddYears_Year(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.AddYears(3).Year == 1993).AsTracking()); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE CAST(strftime('%Y', "m"."Date", CAST(3 AS TEXT) || ' years') AS INTEGER) = 1993 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_DateOnly_AddYears_AddMonths(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(m => m.Date.AddYears(3).AddMonths(3) == new DateOnly(1994, 2, 10)).AsTracking()); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE date("m"."Date", CAST(3 AS TEXT) || ' years', CAST(3 AS TEXT) || ' months') = '1994-02-10' -"""); - } - - public override async Task Where_DateOnly_AddMonths(bool async) - { - await base.Where_DateOnly_AddMonths(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE date("m"."Date", CAST(3 AS TEXT) || ' months') = '1991-02-10' -"""); - } - - public override async Task Where_DateOnly_AddDays(bool async) - { - await base.Where_DateOnly_AddDays(async); - - AssertSql( - """ -SELECT "m"."Id", "m"."CodeName", "m"."Date", "m"."Difficulty", "m"."Duration", "m"."Rating", "m"."Time", "m"."Timeline" -FROM "Missions" AS "m" -WHERE date("m"."Date", CAST(3 AS TEXT) || ' days') = '1990-11-13' -"""); - } - - public override async Task Where_TimeOnly_Hour(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_Hour(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_Minute(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_Minute(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_Second(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_Second(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_Millisecond(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_Millisecond(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_AddHours(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_AddHours(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_AddMinutes(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_AddMinutes(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_Add_TimeSpan(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_Add_TimeSpan(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_IsBetween(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_IsBetween(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_subtract_TimeOnly(bool async) - { - // TimeSpan. Issue #18844. - await AssertTranslationFailed(() => base.Where_TimeOnly_subtract_TimeOnly(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_property(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_parameter(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_constant(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromTimeSpan_compared_to_property(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async)); - - AssertSql(); - } - - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Order_by_TimeOnly_FromTimeSpan(async)); - - AssertSql(); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); - - AssertSql( - """ -SELECT "t"."Id" AS "TagId", "m"."Id" AS "MissionId" -FROM "Tags" AS "t" -CROSS JOIN "Missions" AS "m" -WHERE date("t"."IssueDate") > "m"."Date" -"""); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); - - AssertSql( - """ -@prm='10/11/0002' (DbType = Date) - -SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" -FROM "Tags" AS "t" -WHERE date("t"."IssueDate") IN (@prm, '0015-03-07') -"""); - } - public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) { await base.Optional_navigation_type_compensation_works_with_DTOs(async); @@ -804,17 +404,6 @@ INNER JOIN ( """); } - public override async Task DateTimeOffset_DateAdd_AddMonths(bool async) - { - await base.DateTimeOffset_DateAdd_AddMonths(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) { await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); @@ -995,17 +584,6 @@ SELECT 1 """); } - public override async Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) - { - await base.DateTimeOffset_DateAdd_AddMilliseconds(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - public override async Task Project_discriminator_columns(bool async) { await base.Project_discriminator_columns(async); @@ -1387,17 +965,6 @@ public override async Task OfTypeNav3(bool async) """); } - public override async Task ToString_guid_property_projection(bool async) - { - await base.ToString_guid_property_projection(async); - - AssertSql( - """ -SELECT "t"."GearNickName" AS "A", CAST("t"."Id" AS TEXT) AS "B" -FROM "Tags" AS "t" -"""); - } - public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) { await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); @@ -1437,26 +1004,6 @@ ORDER BY "l"."Name" """); } - public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' (Nullable = true) - -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" & @ammunitionType > 0 -""", - // - """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" & NULL > 0 -"""); - } - public override async Task Correlated_collections_on_left_join_with_null_value(bool async) { await base.Correlated_collections_on_left_join_with_null_value(async); @@ -1680,17 +1227,6 @@ public override async Task Cast_OfType_works_correctly(bool async) """); } - public override async Task DateTimeOffset_DateAdd_AddMinutes(bool async) - { - await base.DateTimeOffset_DateAdd_AddMinutes(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) { await base.Select_Singleton_Navigation_With_Member_Access(async); @@ -1947,32 +1483,6 @@ LEFT JOIN ( """); } - public override async Task Where_enum(bool async) - { - await base.Where_enum(async); - - AssertSql( - """ -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 "g"."Rank" = 4 -"""); - } - - public override async Task Where_has_flag_with_nullable_parameter(bool async) - { - await base.Where_has_flag_with_nullable_parameter(async); - - AssertSql( - """ -@parameter='2' (Nullable = true) - -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 "g"."Rank" & @parameter = @parameter -"""); - } - public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) { await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); @@ -2110,30 +1620,6 @@ ORDER BY "g"."Nickname" """); } - public override async Task Where_bitwise_and_integral(bool async) - { - await base.Where_bitwise_and_integral(async); - - AssertSql( - """ -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 "g"."Rank" & 1 = 1 -""", - // - """ -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 CAST("g"."Rank" AS INTEGER) & 1 = 1 -""", - // - """ -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 CAST("g"."Rank" AS INTEGER) & 1 = 1 -"""); - } - public override async Task Select_multiple_conditions(bool async) { await base.Select_multiple_conditions(async); @@ -2273,30 +1759,6 @@ ORDER BY "t"."Note" """); } - public override async Task Where_enum_has_flag_subquery_client_eval(bool async) - { - await base.Where_enum_has_flag_subquery_client_eval(async); - - AssertSql( - """ -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 "g"."Rank" & ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) = ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) OR ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) IS NULL -"""); - } - public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) { await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); @@ -2453,17 +1915,6 @@ public override async Task Non_unicode_parameter_is_used_for_non_unicode_column( """); } - public override async Task TimeSpan_Seconds(bool async) - { - await base.TimeSpan_Seconds(async); - - AssertSql( - """ -SELECT "m"."Duration" -FROM "Missions" AS "m" -"""); - } - public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) { await base.Optional_navigation_type_compensation_works_with_contains(async); @@ -2850,17 +2301,6 @@ WHERE NOT (CASE """); } - public override async Task DateTimeOffset_DateAdd_AddHours(bool async) - { - await base.DateTimeOffset_DateAdd_AddHours(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) { await base.Join_inner_source_custom_projection_followed_by_filter(async); @@ -2919,30 +2359,6 @@ ORDER BY "g"."Nickname" """); } - public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_null_constant(async); - - AssertSql( - """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" & NULL > 0 -"""); - } - - public override async Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) - { - await base.Where_datetimeoffset_milliseconds_parameter_and_constant(async); - - AssertSql( - """ -SELECT COUNT(*) -FROM "Missions" AS "m" -WHERE "m"."Timeline" = '1902-01-02 10:00:00.1234567+01:30' -"""); - } - public override async Task Parameter_used_multiple_times_take_appropriate_inferred_type_mapping(bool async) { await base.Parameter_used_multiple_times_take_appropriate_inferred_type_mapping(async); @@ -3888,19 +3304,6 @@ ORDER BY "c"."Location" """); } - public override async Task Bitwise_projects_values_in_select(bool async) - { - await base.Bitwise_projects_values_in_select(async); - - AssertSql( - """ -SELECT "g"."Rank" & 2 = 2 AS "BitwiseTrue", "g"."Rank" & 2 = 4 AS "BitwiseFalse", "g"."Rank" & 2 AS "BitwiseValue" -FROM "Gears" AS "g" -WHERE "g"."Rank" & 2 = 2 -LIMIT 1 -"""); - } - public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) { await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); @@ -4210,30 +3613,10 @@ public override async Task Include_collection_on_derived_type_using_lambda_with_ AssertSql( """ -SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank" -FROM "Gears" AS "g" -LEFT JOIN "Gears" AS "g0" ON "g"."Nickname" = "g0"."LeaderNickname" AND "g"."SquadId" = "g0"."LeaderSquadId" -ORDER BY "g"."Nickname", "g"."SquadId", "g0"."Nickname" -"""); - } - - public override async Task Where_nullable_enum_with_nullable_parameter(bool async) - { - await base.Where_nullable_enum_with_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' (Nullable = true) - -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" = @ammunitionType -""", - // - """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" IS NULL +SELECT "g"."Nickname", "g"."SquadId", "g"."AssignedCityName", "g"."CityOfBirthName", "g"."Discriminator", "g"."FullName", "g"."HasSoulPatch", "g"."LeaderNickname", "g"."LeaderSquadId", "g"."Rank", "g0"."Nickname", "g0"."SquadId", "g0"."AssignedCityName", "g0"."CityOfBirthName", "g0"."Discriminator", "g0"."FullName", "g0"."HasSoulPatch", "g0"."LeaderNickname", "g0"."LeaderSquadId", "g0"."Rank" +FROM "Gears" AS "g" +LEFT JOIN "Gears" AS "g0" ON "g"."Nickname" = "g0"."LeaderNickname" AND "g"."SquadId" = "g0"."LeaderSquadId" +ORDER BY "g"."Nickname", "g"."SquadId", "g0"."Nickname" """); } @@ -4450,54 +3833,6 @@ INNER JOIN ( """); } - public override async Task Where_enum_has_flag(bool async) - { - await base.Where_enum_has_flag(async); - - AssertSql( - """ -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 "g"."Rank" & 2 = 2 -""", - // - """ -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 "g"."Rank" & 18 = 18 -""", - // - """ -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 "g"."Rank" & 1 = 1 -""", - // - """ -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 "g"."Rank" & 1 = 1 -""", - // - """ -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 2 & "g"."Rank" = "g"."Rank" -"""); - } - - public override async Task Where_bitwise_and_nullable_enum_with_constant(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_constant(async); - - AssertSql( - """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" & 1 > 0 -"""); - } - public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) { await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); @@ -4612,17 +3947,6 @@ WHERE CASE """); } - public override async Task TimeSpan_Hours(bool async) - { - await base.TimeSpan_Hours(async); - - AssertSql( - """ -SELECT "m"."Duration" -FROM "Missions" AS "m" -"""); - } - public override async Task Where_bool_column_or_Contains(bool async) { await base.Where_bool_column_or_Contains(async); @@ -4993,18 +4317,6 @@ ORDER BY "t"."Note" """); } - public override async Task Where_nullable_enum_with_constant(bool async) - { - await base.Where_nullable_enum_with_constant(async); - - AssertSql( - """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" = 1 -"""); - } - public override async Task Project_navigation_defined_on_base_from_entity_with_inheritance_using_soft_cast(bool async) { await base.Project_navigation_defined_on_base_from_entity_with_inheritance_using_soft_cast(async); @@ -5067,20 +4379,6 @@ LEFT JOIN ( """); } - public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool async) - { - await base.Where_enum_has_flag_with_non_nullable_parameter(async); - - AssertSql( - """ -@parameter='2' - -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 "g"."Rank" & @parameter = @parameter -"""); - } - public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) { await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); @@ -5113,40 +4411,6 @@ SELECT 1 """); } - public override async Task Where_enum_has_flag_subquery(bool async) - { - await base.Where_enum_has_flag_subquery(async); - - AssertSql( - """ -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 "g"."Rank" & COALESCE(( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1), 0) = COALESCE(( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1), 0) -""", - // - """ -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 2 & COALESCE(( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1), 0) = COALESCE(( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1), 0) -"""); - } - public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) { await base.Select_correlated_filtered_collection_with_composite_key(async); @@ -5212,17 +4476,6 @@ LEFT JOIN ( """); } - public override async Task DateTimeOffset_DateAdd_AddYears(bool async) - { - await base.DateTimeOffset_DateAdd_AddYears(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation( bool async) { @@ -5426,48 +4679,6 @@ LIMIT 1 """); } - public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async) - { - await base.Where_enum_has_flag_subquery_with_pushdown(async); - - AssertSql( - """ -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 "g"."Rank" & ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) = ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) OR ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) IS NULL -""", - // - """ -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 2 & ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) = ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) OR ( - SELECT "g0"."Rank" - FROM "Gears" AS "g0" - ORDER BY "g0"."Nickname", "g0"."SquadId" - LIMIT 1) IS NULL -"""); - } - public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) { await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); @@ -5918,31 +5129,6 @@ public override async Task Accessing_derived_property_using_hard_and_soft_cast(b """); } - public override async Task DateTimeOffset_DateAdd_AddSeconds(bool async) - { - await base.DateTimeOffset_DateAdd_AddSeconds(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - - public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) - { - await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' - -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" & @ammunitionType > 0 -"""); - } - public override async Task Include_with_join_and_inheritance3(bool async) { await base.Include_with_join_and_inheritance3(async); @@ -5973,24 +5159,6 @@ ORDER BY "g"."Nickname" """); } - public override async Task Where_bitwise_and_enum(bool async) - { - await base.Where_bitwise_and_enum(async); - - AssertSql( - """ -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 "g"."Rank" & 2 > 0 -""", - // - """ -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 "g"."Rank" & 2 = 2 -"""); - } - public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) { await base.Select_conditional_with_anonymous_type_and_null_constant(async); @@ -6085,17 +5253,6 @@ ORDER BY "f"."Name" """); } - public override async Task DateTimeOffset_DateAdd_AddDays(bool async) - { - await base.DateTimeOffset_DateAdd_AddDays(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - public override async Task Select_ternary_operation_with_inverted_boolean(bool async) { await base.Select_ternary_operation_with_inverted_boolean(async); @@ -6357,17 +5514,6 @@ public override async Task Bitwise_operation_with_non_null_parameter_optimizes_n """); } - public override async Task TimeSpan_Minutes(bool async) - { - await base.TimeSpan_Minutes(async); - - AssertSql( - """ -SELECT "m"."Duration" -FROM "Missions" AS "m" -"""); - } - public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) { await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); @@ -6430,18 +5576,6 @@ SELECT COUNT(*) """); } - public override async Task Filter_with_new_Guid(bool async) - { - await base.Filter_with_new_Guid(async); - - AssertSql( - """ -SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" -FROM "Tags" AS "t" -WHERE "t"."Id" = 'DF36F493-463F-4123-83F9-6B135DEEB7BA' -"""); - } - public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(bool async) { await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(async); @@ -6598,20 +5732,6 @@ public override async Task Composite_key_entity_not_equal_null(bool async) """); } - public override async Task Where_nullable_enum_with_non_nullable_parameter(bool async) - { - await base.Where_nullable_enum_with_non_nullable_parameter(async); - - AssertSql( - """ -@ammunitionType='1' - -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" = @ammunitionType -"""); - } - public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) { await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); @@ -7665,17 +6785,6 @@ public override async Task Order_by_entity_qsre_composite_key(bool async) """); } - public override async Task Time_of_day_datetimeoffset(bool async) - { - await base.Time_of_day_datetimeoffset(async); - - AssertSql( - """ -SELECT "m"."Timeline" -FROM "Missions" AS "m" -"""); - } - public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) { await base.Contains_on_collection_of_nullable_byte_subquery(async); @@ -7772,18 +6881,6 @@ LEFT JOIN ( """); } - public override async Task Where_nullable_enum_with_null_constant(bool async) - { - await base.Where_nullable_enum_with_null_constant(async); - - AssertSql( - """ -SELECT "w"."Id", "w"."AmmunitionType", "w"."IsAutomatic", "w"."Name", "w"."OwnerFullName", "w"."SynergyWithId" -FROM "Weapons" AS "w" -WHERE "w"."AmmunitionType" IS NULL -"""); - } - public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) { await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); @@ -7860,18 +6957,6 @@ ORDER BY "w"."Id" """); } - public override async Task Where_bitwise_or_enum(bool async) - { - await base.Where_bitwise_or_enum(async); - - AssertSql( - """ -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 "g"."Rank" | 2 > 0 -"""); - } - public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) { await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); @@ -8459,17 +7544,6 @@ public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArra """); } - public override async Task TimeSpan_Milliseconds(bool async) - { - await base.TimeSpan_Milliseconds(async); - - AssertSql( - """ -SELECT "m"."Duration" -FROM "Missions" AS "m" -"""); - } - public override async Task Double_order_by_on_is_null(bool async) { await base.Double_order_by_on_is_null(async); @@ -8992,19 +8066,6 @@ public override async Task Project_shadow_properties(bool async) """); } - public override async Task Select_enum_has_flag(bool async) - { - await base.Select_enum_has_flag(async); - - AssertSql( - """ -SELECT "g"."Rank" & 2 = 2 AS "hasFlagTrue", "g"."Rank" & 4 = 4 AS "hasFlagFalse" -FROM "Gears" AS "g" -WHERE "g"."Rank" & 2 = 2 -LIMIT 1 -"""); - } - public override async Task Correlated_collection_with_groupby_with_complex_grouping_key_not_projecting_identifier_column_with_group_aggregate_in_final_projection( bool async) @@ -9743,12 +8804,6 @@ public override async Task Nav_expansion_inside_ElementAt_correlated_to_source(b AssertSql(); } - public override Task DateTimeOffset_to_unix_time_milliseconds(bool async) - => AssertTranslationFailed(() => base.DateTimeOffset_to_unix_time_milliseconds(async)); - - public override Task DateTimeOffset_to_unix_time_seconds(bool async) - => AssertTranslationFailed(() => base.DateTimeOffset_to_unix_time_seconds(async)); - public override async Task Include_one_to_many_on_composite_key_then_orderby_key_properties(bool async) { await base.Include_one_to_many_on_composite_key_then_orderby_key_properties(async); @@ -9903,24 +8958,6 @@ FROM json_each(@keys) AS "k" """); } - public override Task Where_datetimeoffset_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_microsecond_component(async)); - - public override Task Where_datetimeoffset_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_nanosecond_component(async)); - - public override Task Where_timespan_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timespan_microsecond_component(async)); - - public override Task Where_timespan_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timespan_nanosecond_component(async)); - - public override Task Where_timeonly_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timeonly_microsecond_component(async)); - - public override Task Where_timeonly_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timeonly_nanosecond_component(async)); - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs index 97cd408ac0f..33e82557551 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindFunctionsQuerySqliteTest.cs @@ -20,66 +20,40 @@ public NorthwindFunctionsQuerySqliteTest( Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - public override Task Convert_ToBoolean(bool async) - => AssertTranslationFailed(() => base.Convert_ToBoolean(async)); - - public override Task Convert_ToByte(bool async) - => AssertTranslationFailed(() => base.Convert_ToByte(async)); - - public override Task Convert_ToDecimal(bool async) - => AssertTranslationFailed(() => base.Convert_ToDecimal(async)); - - public override Task Convert_ToDouble(bool async) - => AssertTranslationFailed(() => base.Convert_ToDouble(async)); - - public override Task Convert_ToInt16(bool async) - => AssertTranslationFailed(() => base.Convert_ToInt16(async)); - - public override Task Convert_ToInt32(bool async) - => AssertTranslationFailed(() => base.Convert_ToInt32(async)); - - public override Task Convert_ToInt64(bool async) - => AssertTranslationFailed(() => base.Convert_ToInt64(async)); - - public override Task Convert_ToString(bool async) - => AssertTranslationFailed(() => base.Convert_ToString(async)); - - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice(bool async) + public override async Task Client_evaluation_of_uncorrelated_method_call(bool async) { - await base.Projecting_Math_Truncate_and_ordering_by_it_twice(async); + await base.Client_evaluation_of_uncorrelated_method_call(async); AssertSql( """ -SELECT trunc(CAST("o"."OrderID" AS REAL)) AS "A" -FROM "Orders" AS "o" -WHERE "o"."OrderID" < 10250 -ORDER BY trunc(CAST("o"."OrderID" AS REAL)) +SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" +FROM "Order Details" AS "o" +WHERE "o"."UnitPrice" < 7.0 AND 10 < "o"."ProductID" """); } - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice2(bool async) + public override async Task Order_by_length_twice(bool async) { - await base.Projecting_Math_Truncate_and_ordering_by_it_twice2(async); + await base.Order_by_length_twice(async); AssertSql( """ -SELECT trunc(CAST("o"."OrderID" AS REAL)) AS "A" -FROM "Orders" AS "o" -WHERE "o"."OrderID" < 10250 -ORDER BY trunc(CAST("o"."OrderID" AS REAL)) DESC +SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" +FROM "Customers" AS "c" +ORDER BY length("c"."CustomerID"), "c"."CustomerID" """); } - public override async Task Projecting_Math_Truncate_and_ordering_by_it_twice3(bool async) + public override async Task Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(bool async) { - await base.Projecting_Math_Truncate_and_ordering_by_it_twice3(async); + await base.Order_by_length_twice_followed_by_projection_of_naked_collection_navigation(async); AssertSql( """ -SELECT trunc(CAST("o"."OrderID" AS REAL)) AS "A" -FROM "Orders" AS "o" -WHERE "o"."OrderID" < 10250 -ORDER BY trunc(CAST("o"."OrderID" AS REAL)) DESC +SELECT "c"."CustomerID", "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" +FROM "Customers" AS "c" +LEFT JOIN "Orders" AS "o" ON "c"."CustomerID" = "o"."CustomerID" +ORDER BY length("c"."CustomerID"), "c"."CustomerID" """); } @@ -95,245 +69,6 @@ WHERE pow(CAST(length("c"."CustomerID") AS REAL), 2.0) = 25.0 """); } - public override Task Where_guid_newguid(bool async) - => AssertTranslationFailed(() => base.Where_guid_newguid(async)); - - public override Task Where_math_abs3(bool async) - => AssertTranslationFailed(() => base.Where_math_abs3(async)); - - public override async Task Where_math_acos(bool async) - { - await base.Where_math_acos(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND acos(CAST("o"."Discount" AS REAL)) > 1.0 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_math_acosh(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Acosh(od.Discount + 1) > 0)); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND acosh(CAST("o"."Discount" + 1 AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_asin(bool async) - { - await base.Where_math_asin(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND asin(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_math_asinh(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Asinh(od.Discount) > 0)); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND asinh(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_atan(bool async) - { - await base.Where_math_atan(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND atan(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_atan2(bool async) - { - await base.Where_math_atan2(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND atan2(CAST("o"."Discount" AS REAL), 1.0) > 0.0 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_math_atanh(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Atanh(od.Discount) > 0)); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND atanh(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_ceiling1(bool async) - { - await base.Where_math_ceiling1(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."UnitPrice" < 7.0 AND ceiling(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override Task Where_math_ceiling2(bool async) - => AssertTranslationFailed(() => base.Where_math_ceiling2(async)); - - public override async Task Where_math_cos(bool async) - { - await base.Where_math_cos(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND cos(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_math_cosh(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Cosh(od.Discount) > 0)); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND cosh(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_exp(bool async) - { - await base.Where_math_exp(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND exp(CAST("o"."Discount" AS REAL)) > 1.0 -"""); - } - - public override Task Where_math_floor(bool async) - => AssertTranslationFailed(() => base.Where_math_floor(async)); - - public override async Task Where_math_log(bool async) - { - await base.Where_math_log(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND "o"."Discount" > 0 AND ln(CAST("o"."Discount" AS REAL)) < 0.0 -"""); - } - - public override async Task Where_math_log_new_base(bool async) - { - await base.Where_math_log_new_base(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND "o"."Discount" > 0 AND log(7.0, CAST("o"."Discount" AS REAL)) < -1.0 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_math_log2(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077 && od.Discount > 0).Where(od => Math.Log2(od.Discount) < 0)); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND "o"."Discount" > 0 AND log2(CAST("o"."Discount" AS REAL)) < 0.0 -"""); - } - - public override async Task Where_math_log10(bool async) - { - await base.Where_math_log10(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND "o"."Discount" > 0 AND log10(CAST("o"."Discount" AS REAL)) < 0.0 -"""); - } - - public override async Task Where_math_power(bool async) - { - await base.Where_math_power(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE pow(CAST("o"."Discount" AS REAL), 3.0) > 0.004999999888241291 -"""); - } - - public override async Task Where_math_square(bool async) - { - await base.Where_math_square(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE pow(CAST("o"."Discount" AS REAL), 2.0) > 0.05000000074505806 -"""); - } - - public override Task Where_math_round(bool async) - => AssertTranslationFailed(() => base.Where_math_round(async)); - public override Task Sum_over_round_works_correctly_in_projection(bool async) => AssertTranslationFailed(() => base.Sum_over_round_works_correctly_in_projection(async)); @@ -346,1210 +81,6 @@ public override Task Sum_over_truncate_works_correctly_in_projection(bool async) public override Task Sum_over_truncate_works_correctly_in_projection_2(bool async) => AssertTranslationFailed(() => base.Sum_over_truncate_works_correctly_in_projection_2(async)); - public override Task Where_math_round2(bool async) - => AssertTranslationFailed(() => base.Where_math_round2(async)); - - public override async Task Where_math_sign(bool async) - { - await base.Where_math_sign(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND sign("o"."Discount") > 0 -"""); - } - - public override async Task Where_math_sin(bool async) - { - await base.Where_math_sin(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND sin(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_math_sinh(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Sinh(od.Discount) > 0)); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND sinh(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_sqrt(bool async) - { - await base.Where_math_sqrt(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND sqrt(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_tan(bool async) - { - await base.Where_math_tan(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND tan(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Where_math_tanh(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(od => od.OrderID == 11077).Where(od => Math.Tanh(od.Discount) > 0)); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND tanh(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override Task Where_math_truncate(bool async) - => AssertTranslationFailed(() => base.Where_math_truncate(async)); - - public override async Task Where_math_degrees(bool async) - { - await base.Where_math_degrees(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND degrees(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_math_radians(bool async) - { - await base.Where_math_radians(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND radians(CAST("o"."Discount" AS REAL)) > 0.0 -"""); - } - - public override async Task Where_mathf_acos(bool async) - { - await base.Where_mathf_acos(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND acos("o"."Discount") > 1 -"""); - } - - public override async Task Where_mathf_asin(bool async) - { - await base.Where_mathf_asin(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND asin("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_atan(bool async) - { - await base.Where_mathf_atan(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND atan("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_atan2(bool async) - { - await base.Where_mathf_atan2(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND atan2("o"."Discount", 1) > 0 -"""); - } - - public override async Task Where_mathf_ceiling1(bool async) - { - await base.Where_mathf_ceiling1(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."UnitPrice" < 7.0 AND ceiling("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_cos(bool async) - { - await base.Where_mathf_cos(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND cos("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_exp(bool async) - { - await base.Where_mathf_exp(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND exp("o"."Discount") > 1 -"""); - } - - public override async Task Where_mathf_floor(bool async) - { - await base.Where_mathf_floor(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."Quantity" < 5 AND floor(CAST("o"."UnitPrice" AS REAL)) > 10 -"""); - } - - public override async Task Where_mathf_log(bool async) - { - await base.Where_mathf_log(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND "o"."Discount" > 0 AND ln("o"."Discount") < 0 -"""); - } - - public override async Task Where_mathf_log_new_base(bool async) - { - await base.Where_mathf_log_new_base(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND "o"."Discount" > 0 AND log(7, "o"."Discount") < -1 -"""); - } - - public override async Task Where_mathf_log10(bool async) - { - await base.Where_mathf_log10(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND "o"."Discount" > 0 AND log10("o"."Discount") < 0 -"""); - } - - public override async Task Where_mathf_power(bool async) - { - await base.Where_mathf_power(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE pow("o"."Discount", 3) > 0.005 -"""); - } - - public override async Task Where_mathf_square(bool async) - { - await base.Where_mathf_square(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE pow("o"."Discount", 2) > 0.05 -"""); - } - - public override async Task Where_mathf_sign(bool async) - { - await base.Where_mathf_sign(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND sign("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_sin(bool async) - { - await base.Where_mathf_sin(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND sin("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_sqrt(bool async) - { - await base.Where_mathf_sqrt(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND sqrt("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_tan(bool async) - { - await base.Where_mathf_tan(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND tan("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_truncate(bool async) - { - await base.Where_mathf_truncate(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."Quantity" < 5 AND trunc(CAST("o"."UnitPrice" AS REAL)) > 10 -"""); - } - - public override async Task Where_mathf_degrees(bool async) - { - await base.Where_mathf_degrees(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND degrees("o"."Discount") > 0 -"""); - } - - public override async Task Where_mathf_radians(bool async) - { - await base.Where_mathf_radians(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND radians("o"."Discount") > 0 -"""); - } - - public override async Task String_StartsWith_Literal(bool async) - { - await base.String_StartsWith_Literal(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" LIKE 'M%' -"""); - } - - public override async Task String_StartsWith_Parameter(bool async) - { - await base.String_StartsWith_Parameter(async); - - AssertSql( - """ -@pattern_startswith='M%' (Size = 2) - -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" LIKE @pattern_startswith ESCAPE '\' -"""); - } - - public override async Task String_StartsWith_Identity(bool async) - { - await base.String_StartsWith_Identity(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" IS NOT NULL AND (substr("c"."ContactName", 1, length("c"."ContactName")) = "c"."ContactName" OR "c"."ContactName" = '') -"""); - } - - public override async Task String_StartsWith_Column(bool async) - { - await base.String_StartsWith_Column(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" IS NOT NULL AND (substr("c"."ContactName", 1, length("c"."ContactName")) = "c"."ContactName" OR "c"."ContactName" = '') -"""); - } - - public override async Task String_StartsWith_MethodCall(bool async) - { - await base.String_StartsWith_MethodCall(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" LIKE 'M%' -"""); - } - - public override async Task String_EndsWith_Literal(bool async) - { - await base.String_EndsWith_Literal(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" LIKE '%b' -"""); - } - - public override async Task String_EndsWith_Parameter(bool async) - { - await base.String_EndsWith_Parameter(async); - - AssertSql( - """ -@pattern_endswith='%b' (Size = 2) - -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" LIKE @pattern_endswith ESCAPE '\' -"""); - } - - public override async Task String_EndsWith_Identity(bool async) - { - await base.String_EndsWith_Identity(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" IS NOT NULL AND (substr("c"."ContactName", -length("c"."ContactName")) = "c"."ContactName" OR "c"."ContactName" = '') -"""); - } - - public override async Task String_EndsWith_Column(bool async) - { - await base.String_EndsWith_Column(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" IS NOT NULL AND (substr("c"."ContactName", -length("c"."ContactName")) = "c"."ContactName" OR "c"."ContactName" = '') -"""); - } - - public override async Task String_EndsWith_MethodCall(bool async) - { - await base.String_EndsWith_MethodCall(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."ContactName" LIKE '%m' -"""); - } - - public override async Task String_Contains_Literal(bool async) - { - await base.String_Contains_Literal(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."ContactName", 'M') > 0 -"""); - } - - public override async Task String_Contains_Identity(bool async) - { - await base.String_Contains_Identity(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."ContactName", "c"."ContactName") > 0 -"""); - } - - public override async Task String_Contains_Column(bool async) - { - await base.String_Contains_Column(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."CompanyName", "c"."ContactName") > 0 -"""); - } - - public override async Task String_Contains_in_projection(bool async) - { - await base.String_Contains_in_projection(async); - - AssertSql( - """ -SELECT "c"."CustomerID" AS "Id", CASE - WHEN instr("c"."CompanyName", "c"."ContactName") > 0 THEN 1 - ELSE 0 -END AS "Value" -FROM "Customers" AS "c" -"""); - } - - public override async Task String_Contains_negated_in_predicate(bool async) - { - await base.String_Contains_negated_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE CASE - WHEN instr("c"."CompanyName", "c"."ContactName") > 0 THEN 0 - ELSE 1 -END -"""); - } - - public override async Task String_Contains_negated_in_projection(bool async) - { - await base.String_Contains_negated_in_projection(async); - - AssertSql( - """ -SELECT "c"."CustomerID" AS "Id", CASE - WHEN instr("c"."CompanyName", "c"."ContactName") > 0 THEN 0 - ELSE 1 -END AS "Value" -FROM "Customers" AS "c" -"""); - } - - public override async Task String_FirstOrDefault_MethodCall(bool async) - { - await base.String_FirstOrDefault_MethodCall(async); - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE substr("c"."ContactName", 1, 1) = 'A' -"""); - } - - public override async Task String_LastOrDefault_MethodCall(bool async) - { - await base.String_LastOrDefault_MethodCall(async); - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE substr("c"."ContactName", length("c"."ContactName"), 1) = 's' -"""); - } - - public override async Task String_Contains_MethodCall(bool async) - { - await base.String_Contains_MethodCall(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."ContactName", 'M') > 0 -"""); - } - - public override async Task String_Join_over_non_nullable_column(bool async) - { - await base.String_Join_over_non_nullable_column(async); - - AssertSql( - """ -SELECT "c"."City", COALESCE(group_concat("c"."CustomerID", '|'), '') AS "Customers" -FROM "Customers" AS "c" -GROUP BY "c"."City" -"""); - } - - public override async Task String_Join_over_nullable_column(bool async) - { - await base.String_Join_over_nullable_column(async); - - AssertSql( - """ -SELECT "c"."City", COALESCE(group_concat(COALESCE("c"."Region", ''), '|'), '') AS "Regions" -FROM "Customers" AS "c" -GROUP BY "c"."City" -"""); - } - - public override async Task String_Join_with_predicate(bool async) - { - await base.String_Join_with_predicate(async); - - AssertSql( - """ -SELECT "c"."City", COALESCE(group_concat(CASE - WHEN length("c"."ContactName") > 10 THEN "c"."CustomerID" -END, '|'), '') AS "Customers" -FROM "Customers" AS "c" -GROUP BY "c"."City" -"""); - } - - public override async Task String_Join_with_ordering(bool async) - { - // SQLite does not support input ordering on aggregate methods; the below does client evaluation. - await base.String_Join_with_ordering(async); - - AssertSql( - """ -SELECT "c1"."City", "c0"."CustomerID" -FROM ( - SELECT "c"."City" - FROM "Customers" AS "c" - GROUP BY "c"."City" -) AS "c1" -LEFT JOIN "Customers" AS "c0" ON "c1"."City" = "c0"."City" -ORDER BY "c1"."City", "c0"."CustomerID" DESC -"""); - } - - public override Task String_Join_non_aggregate(bool async) - => AssertTranslationFailed(() => base.String_Join_non_aggregate(async)); - - public override async Task String_Concat(bool async) - { - await base.String_Concat(async); - - AssertSql( - """ -SELECT "c"."City", COALESCE(group_concat("c"."CustomerID", ''), '') AS "Customers" -FROM "Customers" AS "c" -GROUP BY "c"."City" -"""); - } - - public override async Task IsNullOrWhiteSpace_in_predicate(bool async) - { - await base.IsNullOrWhiteSpace_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."Region" IS NULL OR trim("c"."Region") = '' -"""); - } - - public override async Task Indexof_with_emptystring(bool async) - { - await base.Indexof_with_emptystring(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."Region", '') - 1 = 0 -"""); - } - - public override async Task Indexof_with_one_constant_arg(bool async) - { - await base.Indexof_with_one_constant_arg(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."ContactName", 'a') - 1 = 1 -"""); - } - - public override async Task Indexof_with_one_parameter_arg(bool async) - { - await base.Indexof_with_one_parameter_arg(async); - - AssertSql( - """ -@pattern='a' (Size = 1) - -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."ContactName", @pattern) - 1 = 1 -"""); - } - - public override Task Indexof_with_constant_starting_position(bool async) - => AssertTranslationFailed(() => base.Indexof_with_constant_starting_position(async)); - - public override Task Indexof_with_parameter_starting_position(bool async) - => AssertTranslationFailed(() => base.Indexof_with_parameter_starting_position(async)); - - public override async Task Replace_with_emptystring(bool async) - { - await base.Replace_with_emptystring(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE replace("c"."ContactName", 'ia', '') = 'Mar Anders' -"""); - } - - public override async Task Replace_using_property_arguments(bool async) - { - await base.Replace_using_property_arguments(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE replace("c"."ContactName", "c"."ContactName", "c"."CustomerID") = "c"."CustomerID" -"""); - } - - public override async Task Substring_with_one_arg_with_zero_startindex(bool async) - { - await base.Substring_with_one_arg_with_zero_startindex(async); - - AssertSql( - """ -SELECT "c"."ContactName" -FROM "Customers" AS "c" -WHERE substr("c"."CustomerID", 0 + 1) = 'ALFKI' -"""); - } - - public override async Task Substring_with_one_arg_with_constant(bool async) - { - await base.Substring_with_one_arg_with_constant(async); - - AssertSql( - """ -SELECT "c"."ContactName" -FROM "Customers" AS "c" -WHERE substr("c"."CustomerID", 1 + 1) = 'LFKI' -"""); - } - - public override async Task Substring_with_one_arg_with_closure(bool async) - { - await base.Substring_with_one_arg_with_closure(async); - - AssertSql( - """ -@start='2' - -SELECT "c"."ContactName" -FROM "Customers" AS "c" -WHERE substr("c"."CustomerID", @start + 1) = 'FKI' -"""); - } - - public override async Task Substring_with_two_args_with_zero_startindex(bool async) - { - await base.Substring_with_two_args_with_zero_startindex(async); - - AssertSql( - """ -SELECT substr("c"."ContactName", 0 + 1, 3) -FROM "Customers" AS "c" -WHERE "c"."CustomerID" = 'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_constant(bool async) - { - await base.Substring_with_two_args_with_constant(async); - - AssertSql( - """ -SELECT substr("c"."ContactName", 1 + 1, 3) -FROM "Customers" AS "c" -WHERE "c"."CustomerID" = 'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_closure(bool async) - { - await base.Substring_with_two_args_with_closure(async); - - AssertSql( - """ -@start='2' - -SELECT substr("c"."ContactName", @start + 1, 3) -FROM "Customers" AS "c" -WHERE "c"."CustomerID" = 'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_Index_of(bool async) - { - await base.Substring_with_two_args_with_Index_of(async); - - AssertSql( - """ -SELECT substr("c"."ContactName", (instr("c"."ContactName", 'a') - 1) + 1, 3) -FROM "Customers" AS "c" -WHERE "c"."CustomerID" = 'ALFKI' -"""); - } - - public override async Task Substring_with_two_args_with_zero_length(bool async) - { - await base.Substring_with_two_args_with_zero_length(async); - - AssertSql( - """ -SELECT substr("c"."ContactName", 2 + 1, 0) -FROM "Customers" AS "c" -WHERE "c"."CustomerID" = 'ALFKI' -"""); - } - - public override async Task Where_math_abs1(bool async) - { - await base.Where_math_abs1(async); - - AssertSql( - """ -SELECT "p"."ProductID", "p"."Discontinued", "p"."ProductName", "p"."SupplierID", "p"."UnitPrice", "p"."UnitsInStock" -FROM "Products" AS "p" -WHERE abs("p"."ProductID") > 10 -"""); - } - - public override async Task Where_math_abs2(bool async) - { - await base.Where_math_abs2(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."UnitPrice" < 7.0 AND abs("o"."Quantity") > 10 -"""); - } - - public override async Task Where_math_abs_uncorrelated(bool async) - { - await base.Where_math_abs_uncorrelated(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."UnitPrice" < 7.0 AND 10 < "o"."ProductID" -"""); - } - - public override async Task Select_math_round_int(bool async) - { - await base.Select_math_round_int(async); - - AssertSql( - """ -SELECT round(CAST("o"."OrderID" AS REAL)) AS "A" -FROM "Orders" AS "o" -WHERE "o"."OrderID" < 10250 -"""); - } - - public override async Task Where_math_min(bool async) - { - await base.Where_math_min(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND min("o"."OrderID", "o"."ProductID") = "o"."ProductID" -"""); - } - - public override async Task Where_math_min_nested(bool async) - { - await base.Where_math_min_nested(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND min("o"."OrderID", "o"."ProductID", 99999) = "o"."ProductID" -"""); - } - - public override async Task Where_math_min_nested_twice(bool async) - { - await base.Where_math_min_nested_twice(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND min(99999, "o"."OrderID", 99998, "o"."ProductID") = "o"."ProductID" -"""); - } - - public override async Task Where_math_max(bool async) - { - await base.Where_math_max(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND max("o"."OrderID", "o"."ProductID") = "o"."OrderID" -"""); - } - - public override async Task Where_math_max_nested(bool async) - { - await base.Where_math_max_nested(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND max("o"."OrderID", "o"."ProductID", 1) = "o"."OrderID" -"""); - } - - public override async Task Where_math_max_nested_twice(bool async) - { - await base.Where_math_max_nested_twice(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."ProductID", "o"."Discount", "o"."Quantity", "o"."UnitPrice" -FROM "Order Details" AS "o" -WHERE "o"."OrderID" = 11077 AND max(1, "o"."OrderID", 2, "o"."ProductID") = "o"."OrderID" -"""); - } - - public override async Task Where_string_to_lower(bool async) - { - await base.Where_string_to_lower(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE lower("c"."CustomerID") = 'alfki' -"""); - } - - public override async Task Where_string_to_upper(bool async) - { - await base.Where_string_to_upper(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE upper("c"."CustomerID") = 'ALFKI' -"""); - } - - public override async Task TrimStart_without_arguments_in_predicate(bool async) - { - await base.TrimStart_without_arguments_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE ltrim("c"."ContactTitle") = 'Owner' -"""); - } - - public override async Task TrimStart_with_char_argument_in_predicate(bool async) - { - await base.TrimStart_with_char_argument_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE ltrim("c"."ContactTitle", 'O') = 'wner' -"""); - } - - public override async Task TrimStart_with_char_array_argument_in_predicate(bool async) - { - await base.TrimStart_with_char_array_argument_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE ltrim("c"."ContactTitle", 'Ow') = 'ner' -"""); - } - - public override async Task TrimEnd_without_arguments_in_predicate(bool async) - { - await base.TrimEnd_without_arguments_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE rtrim("c"."ContactTitle") = 'Owner' -"""); - } - - public override async Task TrimEnd_with_char_argument_in_predicate(bool async) - { - await base.TrimEnd_with_char_argument_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE rtrim("c"."ContactTitle", 'r') = 'Owne' -"""); - } - - public override async Task TrimEnd_with_char_array_argument_in_predicate(bool async) - { - await base.TrimEnd_with_char_array_argument_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE rtrim("c"."ContactTitle", 'er') = 'Own' -"""); - } - - public override async Task Trim_without_argument_in_predicate(bool async) - { - await base.Trim_without_argument_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE trim("c"."ContactTitle") = 'Owner' -"""); - } - - public override async Task Trim_with_char_argument_in_predicate(bool async) - { - await base.Trim_with_char_argument_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE trim("c"."ContactTitle", 'O') = 'wner' -"""); - } - - public override async Task Trim_with_char_array_argument_in_predicate(bool async) - { - await base.Trim_with_char_array_argument_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE trim("c"."ContactTitle", 'Or') = 'wne' -"""); - } - - public override async Task Regex_IsMatch_MethodCall(bool async) - { - await base.Regex_IsMatch_MethodCall(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."CustomerID" REGEXP '^T' -"""); - } - - public override async Task Regex_IsMatch_MethodCall_constant_input(bool async) - { - await base.Regex_IsMatch_MethodCall_constant_input(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE 'ALFKI' REGEXP "c"."CustomerID" -"""); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Regex_IsMatch_MethodCall_negated(bool async) - { - await AssertQuery( - async, - ss => ss.Set().Where(o => !Regex.IsMatch(o.CustomerID, "^[^T]"))); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."CustomerID" NOT REGEXP '^[^T]' -"""); - } - - public override async Task IsNullOrEmpty_in_predicate(bool async) - { - await base.IsNullOrEmpty_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."Region" IS NULL OR "c"."Region" = '' -"""); - } - - public override async Task IsNullOrEmpty_in_projection(bool async) - { - await base.IsNullOrEmpty_in_projection(async); - - AssertSql( - """ -SELECT "c"."CustomerID" AS "Id", "c"."Region" IS NULL OR "c"."Region" = '' AS "Value" -FROM "Customers" AS "c" -"""); - } - - public override async Task IsNullOrEmpty_negated_in_predicate(bool async) - { - await base.IsNullOrEmpty_negated_in_predicate(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE "c"."Region" IS NOT NULL AND "c"."Region" <> '' -"""); - } - - public override Task Datetime_subtraction_TotalDays(bool async) - => AssertTranslationFailed(() => base.Datetime_subtraction_TotalDays(async)); - - public override async Task Where_DateOnly_FromDateTime(bool async) - { - await base.Where_DateOnly_FromDateTime(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE "o"."OrderDate" IS NOT NULL AND date("o"."OrderDate") = '1996-09-16' -"""); - } - - public override async Task Select_ToString_IndexOf(bool async) - { - await base.Select_ToString_IndexOf(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE instr(CAST("o"."OrderID" AS TEXT), '123') - 1 = -1 -"""); - } - - public override async Task Select_IndexOf_ToString(bool async) - { - await base.Select_IndexOf_ToString(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE instr('123', CAST("o"."OrderID" AS TEXT)) - 1 = -1 -"""); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs index 4931c0b3a0e..eb8c0881e65 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/NorthwindWhereQuerySqliteTest.cs @@ -29,15 +29,6 @@ ELSE 0 """); } - public override Task Where_datetimeoffset_now_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_now_component(async)); - - public override Task Where_datetimeoffset_utcnow_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow_component(async)); - - public override Task Where_datetimeoffset_utcnow(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow_component(async)); - public override async Task Where_simple_closure(bool async) { var queryString = await base.Where_simple_closure(async); @@ -64,203 +55,6 @@ .param set @city 'London' return null; } - public override async Task Where_datetime_now(bool async) - { - await base.Where_datetime_now(async); - - AssertSql( - """ -@myDatetime='2015-04-10T00:00:00.0000000' (DbType = DateTime) - -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') <> @myDatetime -"""); - } - - public override async Task Where_datetime_utcnow(bool async) - { - await base.Where_datetime_utcnow(async); - - AssertSql( - """ -@myDatetime='2015-04-10T00:00:00.0000000' (DbType = DateTime) - -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') <> @myDatetime -"""); - } - - public override async Task Where_datetime_today(bool async) - { - await base.Where_datetime_today(async); - - AssertSql( - """ -SELECT "e"."EmployeeID", "e"."City", "e"."Country", "e"."FirstName", "e"."ReportsTo", "e"."Title" -FROM "Employees" AS "e" -"""); - } - - public override async Task Where_datetime_date_component(bool async) - { - await base.Where_datetime_date_component(async); - - AssertSql( - """ -@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) - -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', "o"."OrderDate", 'start of day'), '0'), '.') = @myDatetime -"""); - } - - public override async Task Where_datetime_year_component(bool async) - { - await base.Where_datetime_year_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST(strftime('%Y', "o"."OrderDate") AS INTEGER) = 1998 -"""); - } - - public override async Task Where_datetime_month_component(bool async) - { - await base.Where_datetime_month_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST(strftime('%m', "o"."OrderDate") AS INTEGER) = 4 -"""); - } - - public override async Task Where_datetime_dayOfYear_component(bool async) - { - await base.Where_datetime_dayOfYear_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST(strftime('%j', "o"."OrderDate") AS INTEGER) = 68 -"""); - } - - public override async Task Where_datetime_day_component(bool async) - { - await base.Where_datetime_day_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST(strftime('%d', "o"."OrderDate") AS INTEGER) = 4 -"""); - } - - public override async Task Where_datetime_hour_component(bool async) - { - await base.Where_datetime_hour_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST(strftime('%H', "o"."OrderDate") AS INTEGER) = 0 -"""); - } - - public override async Task Where_datetime_minute_component(bool async) - { - await base.Where_datetime_minute_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST(strftime('%M', "o"."OrderDate") AS INTEGER) = 0 -"""); - } - - public override async Task Where_datetime_second_component(bool async) - { - await base.Where_datetime_second_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST(strftime('%S', "o"."OrderDate") AS INTEGER) = 0 -"""); - } - - public override async Task Where_datetime_millisecond_component(bool async) - { - await base.Where_datetime_millisecond_component(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE (CAST(strftime('%f', "o"."OrderDate") AS REAL) * 1000.0) % 1000.0 = 0.0 -"""); - } - - public override async Task Where_string_length(bool async) - { - await base.Where_string_length(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE length("c"."City") = 6 -"""); - } - - public override async Task Where_string_indexof(bool async) - { - await base.Where_string_indexof(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE instr("c"."City", 'Sea') - 1 <> -1 OR "c"."City" IS NULL -"""); - } - - public override async Task Where_string_replace(bool async) - { - await base.Where_string_replace(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE replace("c"."City", 'Sea', 'Rea') = 'Reattle' -"""); - } - - public override async Task Where_string_substring(bool async) - { - await base.Where_string_substring(async); - - AssertSql( - """ -SELECT "c"."CustomerID", "c"."Address", "c"."City", "c"."CompanyName", "c"."ContactName", "c"."ContactTitle", "c"."Country", "c"."Fax", "c"."Phone", "c"."PostalCode", "c"."Region" -FROM "Customers" AS "c" -WHERE substr("c"."City", 1 + 1, 2) = 'ea' -"""); - } - public override async Task Decimal_cast_to_double_works(bool async) { await base.Decimal_cast_to_double_works(async); @@ -273,18 +67,6 @@ WHERE CAST("p"."UnitPrice" AS REAL) > 100.0 """); } - public override async Task Like_with_non_string_column_using_ToString(bool async) - { - await base.Like_with_non_string_column_using_ToString(async); - - AssertSql( - """ -SELECT "o"."OrderID", "o"."CustomerID", "o"."EmployeeID", "o"."OrderDate" -FROM "Orders" AS "o" -WHERE CAST("o"."OrderID" AS TEXT) LIKE '%20%' -"""); - } - public override async Task Where_bitwise_xor(bool async) { // Cannot eval 'where (([c].CustomerID == \"ALFKI\") ^ True)'. Issue #16645. diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs index 65483efb2d4..ac18f80a235 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPCGearsOfWarQuerySqliteTest.cs @@ -17,39 +17,6 @@ public TPCGearsOfWarQuerySqliteTest(TPCGearsOfWarQuerySqliteFixture fixture, ITe Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - public override Task Where_datetimeoffset_date_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - - public override Task Where_datetimeoffset_day_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - - public override Task Where_datetimeoffset_dayofyear_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_dayofyear_component(async)); - - public override Task Where_datetimeoffset_hour_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_hour_component(async)); - - public override Task Where_datetimeoffset_millisecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_millisecond_component(async)); - - public override Task Where_datetimeoffset_minute_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_minute_component(async)); - - public override Task Where_datetimeoffset_month_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_month_component(async)); - - public override Task Where_datetimeoffset_now(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_now(async)); - - public override Task Where_datetimeoffset_second_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_second_component(async)); - - public override Task Where_datetimeoffset_utcnow(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow(async)); - - public override Task Where_datetimeoffset_year_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_year_component(async)); - public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) => AssertTranslationFailed(() => base.DateTimeOffset_Contains_Less_than_Greater_than(async)); @@ -301,141 +268,6 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async) """); } - public override Task Where_TimeSpan_Hours(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Hours(async)); - - public override Task Where_TimeSpan_Minutes(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Minutes(async)); - - public override Task Where_TimeSpan_Seconds(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Seconds(async)); - - public override Task Where_TimeSpan_Milliseconds(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Milliseconds(async)); - - public override Task First_on_byte_array(bool async) - // Array access. Issue #16428. - => AssertTranslationFailed(() => base.First_on_byte_array(async)); - - public override Task Array_access_on_byte_array(bool async) - // Array access. Issue #16428. - => AssertTranslationFailed(() => base.Array_access_on_byte_array(async)); - - public override Task Where_TimeOnly_Hour(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Hour(async)); - - public override Task Where_TimeOnly_Minute(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Minute(async)); - - public override Task Where_TimeOnly_Second(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Second(async)); - - public override Task Where_TimeOnly_Millisecond(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Millisecond(async)); - - public override Task Where_TimeOnly_AddHours(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_AddHours(async)); - - public override Task Where_TimeOnly_AddMinutes(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_AddMinutes(async)); - - public override Task Where_TimeOnly_Add_TimeSpan(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Add_TimeSpan(async)); - - public override Task Where_TimeOnly_IsBetween(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_IsBetween(async)); - - public override Task Where_TimeOnly_subtract_TimeOnly(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_subtract_TimeOnly(async)); - - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_property(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_parameter(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_constant(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromTimeSpan_compared_to_property(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async)); - - AssertSql(); - } - - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Order_by_TimeOnly_FromTimeSpan(async)); - - AssertSql(); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); - - AssertSql( - """ -SELECT "t"."Id" AS "TagId", "m"."Id" AS "MissionId" -FROM "Tags" AS "t" -CROSS JOIN "Missions" AS "m" -WHERE date("t"."IssueDate") > "m"."Date" -"""); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); - - AssertSql( - """ -@prm='10/11/0002' (DbType = Date) - -SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" -FROM "Tags" AS "t" -WHERE date("t"."IssueDate") IN (@prm, '0015-03-07') -"""); - } - public override async Task Where_subquery_with_ElementAt_using_column_as_index(bool async) { var message = (await Assert.ThrowsAsync( @@ -462,30 +294,6 @@ ORDER BY "u"."Nickname" """); } - public override Task DateTimeOffset_to_unix_time_milliseconds(bool async) - => AssertTranslationFailed(() => base.DateTimeOffset_to_unix_time_milliseconds(async)); - - public override Task DateTimeOffset_to_unix_time_seconds(bool async) - => AssertTranslationFailed(() => base.DateTimeOffset_to_unix_time_seconds(async)); - - public override Task Where_datetimeoffset_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_microsecond_component(async)); - - public override Task Where_datetimeoffset_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_nanosecond_component(async)); - - public override Task Where_timespan_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timespan_microsecond_component(async)); - - public override Task Where_timespan_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timespan_nanosecond_component(async)); - - public override Task Where_timeonly_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timeonly_microsecond_component(async)); - - public override Task Where_timeonly_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timeonly_nanosecond_component(async)); - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs index 8da915c5ab8..11e11b3d064 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/TPTGearsOfWarQuerySqliteTest.cs @@ -17,39 +17,6 @@ public TPTGearsOfWarQuerySqliteTest(TPTGearsOfWarQuerySqliteFixture fixture, ITe Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } - public override Task Where_datetimeoffset_date_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - - public override Task Where_datetimeoffset_day_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_date_component(async)); - - public override Task Where_datetimeoffset_dayofyear_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_dayofyear_component(async)); - - public override Task Where_datetimeoffset_hour_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_hour_component(async)); - - public override Task Where_datetimeoffset_millisecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_millisecond_component(async)); - - public override Task Where_datetimeoffset_minute_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_minute_component(async)); - - public override Task Where_datetimeoffset_month_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_month_component(async)); - - public override Task Where_datetimeoffset_now(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_now(async)); - - public override Task Where_datetimeoffset_second_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_second_component(async)); - - public override Task Where_datetimeoffset_utcnow(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_utcnow(async)); - - public override Task Where_datetimeoffset_year_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_year_component(async)); - public override Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) => AssertTranslationFailed(() => base.DateTimeOffset_Contains_Less_than_Greater_than(async)); @@ -301,141 +268,6 @@ public override async Task Byte_array_filter_by_SequenceEqual(bool async) """); } - public override Task Where_TimeSpan_Hours(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Hours(async)); - - public override Task Where_TimeSpan_Minutes(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Minutes(async)); - - public override Task Where_TimeSpan_Seconds(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Seconds(async)); - - public override Task Where_TimeSpan_Milliseconds(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeSpan_Milliseconds(async)); - - public override Task First_on_byte_array(bool async) - // Array access. Issue #16428. - => AssertTranslationFailed(() => base.First_on_byte_array(async)); - - public override Task Array_access_on_byte_array(bool async) - // Array access. Issue #16428. - => AssertTranslationFailed(() => base.Array_access_on_byte_array(async)); - - public override Task Where_TimeOnly_Hour(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Hour(async)); - - public override Task Where_TimeOnly_Minute(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Minute(async)); - - public override Task Where_TimeOnly_Second(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Second(async)); - - public override Task Where_TimeOnly_Millisecond(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Millisecond(async)); - - public override Task Where_TimeOnly_AddHours(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_AddHours(async)); - - public override Task Where_TimeOnly_AddMinutes(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_AddMinutes(async)); - - public override Task Where_TimeOnly_Add_TimeSpan(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_Add_TimeSpan(async)); - - public override Task Where_TimeOnly_IsBetween(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_IsBetween(async)); - - public override Task Where_TimeOnly_subtract_TimeOnly(bool async) - // TimeSpan. Issue #18844. - => AssertTranslationFailed(() => base.Where_TimeOnly_subtract_TimeOnly(async)); - - public override async Task Where_TimeOnly_FromDateTime_compared_to_property(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_property(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_parameter(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_parameter(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromDateTime_compared_to_constant(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromDateTime_compared_to_constant(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_property(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromTimeSpan_compared_to_property(async)); - - AssertSql(); - } - - public override async Task Where_TimeOnly_FromTimeSpan_compared_to_parameter(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Where_TimeOnly_FromTimeSpan_compared_to_parameter(async)); - - AssertSql(); - } - - public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) - { - // TimeOnly/DateOnly is not supported. Issue #25103. - await AssertTranslationFailed(() => base.Order_by_TimeOnly_FromTimeSpan(async)); - - AssertSql(); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_property(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_property(async); - - AssertSql( - """ -SELECT "t"."Id" AS "TagId", "m"."Id" AS "MissionId" -FROM "Tags" AS "t" -CROSS JOIN "Missions" AS "m" -WHERE date("t"."IssueDate") > "m"."Date" -"""); - } - - public override async Task Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) - { - await base.Where_DateOnly_FromDateTime_compared_to_constant_and_parameter(async); - - AssertSql( - """ -@prm='10/11/0002' (DbType = Date) - -SELECT "t"."Id", "t"."GearNickName", "t"."GearSquadId", "t"."IssueDate", "t"."Note" -FROM "Tags" AS "t" -WHERE date("t"."IssueDate") IN (@prm, '0015-03-07') -"""); - } - public override async Task Where_subquery_with_ElementAt_using_column_as_index(bool async) { var message = (await Assert.ThrowsAsync( @@ -456,30 +288,6 @@ ORDER BY "g"."Nickname" """); } - public override Task DateTimeOffset_to_unix_time_milliseconds(bool async) - => AssertTranslationFailed(() => base.DateTimeOffset_to_unix_time_milliseconds(async)); - - public override Task DateTimeOffset_to_unix_time_seconds(bool async) - => AssertTranslationFailed(() => base.DateTimeOffset_to_unix_time_seconds(async)); - - public override Task Where_datetimeoffset_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_microsecond_component(async)); - - public override Task Where_datetimeoffset_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_datetimeoffset_nanosecond_component(async)); - - public override Task Where_timespan_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timespan_microsecond_component(async)); - - public override Task Where_timespan_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timespan_nanosecond_component(async)); - - public override Task Where_timeonly_microsecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timeonly_microsecond_component(async)); - - public override Task Where_timeonly_nanosecond_component(bool async) - => AssertTranslationFailed(() => base.Where_timeonly_nanosecond_component(async)); - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/BasicTypesQuerySqliteFixture.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/BasicTypesQuerySqliteFixture.cs new file mode 100644 index 00000000000..f13654732e6 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/BasicTypesQuerySqliteFixture.cs @@ -0,0 +1,12 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class BasicTypesQuerySqliteFixture : BasicTypesQueryFixtureBase, ITestSqlLoggerFactory +{ + protected override ITestStoreFactory TestStoreFactory => SqliteTestStoreFactory.Instance; + + public TestSqlLoggerFactory TestSqlLoggerFactory + => (TestSqlLoggerFactory)ListLoggerFactory; +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/EnumTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/EnumTranslationsSqliteTest.cs new file mode 100644 index 00000000000..54abbded98d --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/EnumTranslationsSqliteTest.cs @@ -0,0 +1,311 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class EnumTranslationsSqliteTest : EnumTranslationsTestBase +{ + public EnumTranslationsSqliteTest(BasicTypesQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equality + + public override async Task Equality_to_constant(bool async) + { + await base.Equality_to_constant(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Enum" = 0 +"""); + } + + public override async Task Equality_to_parameter(bool async) + { + await base.Equality_to_parameter(async); + + AssertSql( + """ +@basicEnum='0' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Enum" = @basicEnum +"""); + } + + public override async Task Equality_nullable_enum_to_constant(bool async) + { + await base.Equality_nullable_enum_to_constant(async); + + AssertSql( + """ +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."Enum" = 0 +"""); + } + + public override async Task Equality_nullable_enum_to_parameter(bool async) + { + await base.Equality_nullable_enum_to_parameter(async); + + AssertSql( + """ +@basicEnum='0' + +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."Enum" = @basicEnum +"""); + } + + public override async Task Equality_nullable_enum_to_null_constant(bool async) + { + await base.Equality_nullable_enum_to_null_constant(async); + + AssertSql( + """ +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."Enum" IS NULL +"""); + } + + public override async Task Equality_nullable_enum_to_null_parameter(bool async) + { + await base.Equality_nullable_enum_to_null_parameter(async); + + AssertSql( + """ +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."Enum" IS NULL +"""); + } + + public override async Task Equality_nullable_enum_to_nullable_parameter(bool async) + { + await base.Equality_nullable_enum_to_nullable_parameter(async); + + AssertSql( + """ +@basicEnum='0' (Nullable = true) + +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."Enum" = @basicEnum +"""); + } + + #endregion Equality + + public override async Task Bitwise_and_enum_constant(bool async) + { + await base.Bitwise_and_enum_constant(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 1 > 0 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 1 = 1 +"""); + } + + public override async Task Bitwise_and_integral_constant(bool async) + { + await base.Bitwise_and_integral_constant(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 8 = 8 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST("b"."FlagsEnum" AS INTEGER) & 8 = 8 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST("b"."FlagsEnum" AS INTEGER) & 8 = 8 +"""); + } + + public override async Task Bitwise_and_nullable_enum_with_constant(bool async) + { + await base.Bitwise_and_nullable_enum_with_constant(async); + + AssertSql( + """ +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."FlagsEnum" & 8 > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) + { + await base.Where_bitwise_and_nullable_enum_with_null_constant(async); + + AssertSql( + """ +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."FlagsEnum" & NULL > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) + { + await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' + +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."FlagsEnum" & @flagsEnum > 0 +"""); + } + + public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) + { + await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' (Nullable = true) + +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."FlagsEnum" & @flagsEnum > 0 +""", + // + """ +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."FlagsEnum" & NULL > 0 +"""); + } + + public override async Task Bitwise_or(bool async) + { + await base.Bitwise_or(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" | 8 > 0 +"""); + } + + public override async Task Bitwise_projects_values_in_select(bool async) + { + await base.Bitwise_projects_values_in_select(async); + + AssertSql( + """ +SELECT "b"."FlagsEnum" & 8 = 8 AS "BitwiseTrue", "b"."FlagsEnum" & 8 = 4 AS "BitwiseFalse", "b"."FlagsEnum" & 8 AS "BitwiseValue" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 8 = 8 +LIMIT 1 +"""); + } + + public override async Task HasFlag(bool async) + { + await base.HasFlag(async); + +AssertSql( +""" +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 8 = 8 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 12 = 12 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 8 = 8 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 8 = 8 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE 8 & "b"."FlagsEnum" = "b"."FlagsEnum" +""", + // + """ +SELECT "b"."FlagsEnum" & 8 = 8 AS "hasFlagTrue", "b"."FlagsEnum" & 4 = 4 AS "hasFlagFalse" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & 8 = 8 +LIMIT 1 +"""); + } + + public override async Task HasFlag_with_non_nullable_parameter(bool async) + { + await base.HasFlag_with_non_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & @flagsEnum = @flagsEnum +"""); + } + + public override async Task HasFlag_with_nullable_parameter(bool async) + { + await base.HasFlag_with_nullable_parameter(async); + + AssertSql( + """ +@flagsEnum='8' (Nullable = true) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."FlagsEnum" & @flagsEnum = @flagsEnum +"""); + } + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MathTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MathTranslationsSqliteTest.cs new file mode 100644 index 00000000000..444ebc48507 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MathTranslationsSqliteTest.cs @@ -0,0 +1,804 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MathTranslationsSqliteTest : MathTranslationsTestBase +{ + public MathTranslationsSqliteTest(BasicTypesQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Abs_decimal(bool async) + => await AssertTranslationFailed(() => base.Abs_decimal(async)); // SQLite decimal support + + public override async Task Abs_int(bool async) + { + await base.Abs_int(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE abs("b"."Int") = 9 +"""); + } + + public override async Task Abs_double(bool async) + { + await base.Abs_double(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE abs("b"."Double") = 9.5 +"""); + } + + public override async Task Abs_float(bool async) + { + await base.Abs_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(abs("b"."Float") AS REAL) = 9.5 +"""); + } + + public override async Task Ceiling(bool async) + { + await base.Ceiling(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE ceiling("b"."Double") = 9.0 +"""); + } + + public override async Task Ceiling_float(bool async) + { + await base.Ceiling_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE ceiling("b"."Float") = 9 +"""); + } + + public override async Task Floor_decimal(bool async) + => await AssertTranslationFailed(() => base.Floor_decimal(async)); // SQLite decimal support + + public override async Task Floor_double(bool async) + { + await base.Floor_double(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE floor("b"."Double") = 8.0 +"""); + } + + public override async Task Floor_float(bool async) + { + await base.Floor_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE floor("b"."Float") = 8 +"""); + } + + public override async Task Power(bool async) + { + await base.Power(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE pow(CAST("b"."Int" AS REAL), 2.0) = 64.0 +"""); + } + + public override async Task Power_float(bool async) + { + await base.Power_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE pow("b"."Float", 2) > 73 AND pow("b"."Float", 2) < 74 +"""); + } + + public override async Task Round_decimal(bool async) + => await AssertTranslationFailed(() => base.Round_decimal(async)); // SQLite decimal support + + public override async Task Round_double(bool async) + { + await base.Round_double(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE round("b"."Double") = 9.0 +""", + // + """ +SELECT round("b"."Double") +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Round_float(bool async) + { + await base.Round_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE round("b"."Float") = 9 +""", + // + """ +SELECT round("b"."Float") +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Round_with_digits_decimal(bool async) + => await AssertTranslationFailed(() => base.Round_with_digits_decimal(async)); // SQLite decimal support + + public override async Task Round_with_digits_double(bool async) + { + await base.Round_with_digits_double(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE round("b"."Double", 1) = 255.09999999999999 +"""); + } + + public override async Task Round_with_digits_float(bool async) + { + await base.Round_with_digits_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE round(CAST("b"."Float" AS REAL), 1) = 255.09999999999999 +"""); + } + + public override async Task Truncate_decimal(bool async) + => await AssertTranslationFailed(() => base.Truncate_decimal(async)); // SQLite decimal support + + public override async Task Truncate_double(bool async) + { + await base.Truncate_double(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE trunc("b"."Double") = 8.0 +""", + // + """ +SELECT trunc("b"."Double") +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Truncate_float(bool async) + { + await base.Truncate_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE trunc("b"."Float") = 8 +""", + // + """ +SELECT trunc("b"."Float") +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Truncate_project_and_order_by_it_twice(bool async) + { + await base.Truncate_project_and_order_by_it_twice(async); + + AssertSql( + """ +SELECT trunc("b"."Double") AS "A" +FROM "BasicTypesEntities" AS "b" +ORDER BY trunc("b"."Double") +"""); + } + + // issue #16038 + // AssertSql( + // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] + //FROM [Orders] AS [o] + //WHERE [o].[OrderID] < 10250 + //ORDER BY [A]"); + public override async Task Truncate_project_and_order_by_it_twice2(bool async) + { + await base.Truncate_project_and_order_by_it_twice2(async); + + AssertSql( + """ +SELECT trunc("b"."Double") AS "A" +FROM "BasicTypesEntities" AS "b" +ORDER BY trunc("b"."Double") DESC +"""); + } + + // issue #16038 + // AssertSql( + // @"SELECT ROUND(CAST([o].[OrderID] AS float), 0, 1) AS [A] + //FROM [Orders] AS [o] + //WHERE [o].[OrderID] < 10250 + //ORDER BY [A] DESC"); + public override async Task Truncate_project_and_order_by_it_twice3(bool async) + { + await base.Truncate_project_and_order_by_it_twice3(async); + + AssertSql( + """ +SELECT trunc("b"."Double") AS "A" +FROM "BasicTypesEntities" AS "b" +ORDER BY trunc("b"."Double") DESC +"""); + } + + public override async Task Exp(bool async) + { + await base.Exp(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE exp("b"."Double") > 1.0 +"""); + } + + public override async Task Exp_float(bool async) + { + await base.Exp_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE exp("b"."Float") > 1 +"""); + } + + public override async Task Log(bool async) + { + await base.Log(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Double" > 0.0 AND ln("b"."Double") <> 0.0 +"""); + } + + public override async Task Log_float(bool async) + { + await base.Log_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Float" > 0 AND ln("b"."Float") <> 0 +"""); + } + + public override async Task Log_with_newBase(bool async) + { + await base.Log_with_newBase(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Double" > 0.0 AND log(7.0, "b"."Double") <> 0.0 +"""); + } + + public override async Task Log_with_newBase_float(bool async) + { + await base.Log_with_newBase_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Float" > 0 AND log(7, "b"."Float") <> 0 +"""); + } + + public override async Task Log10(bool async) + { + await base.Log10(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Double" > 0.0 AND log10("b"."Double") <> 0.0 +"""); + } + + public override async Task Log10_float(bool async) + { + await base.Log10_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Float" > 0 AND log10("b"."Float") <> 0 +"""); + } + + public override async Task Log2(bool async) + { + await base.Log2(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Double" > 0.0 AND log2("b"."Double") <> 0.0 +"""); + } + + public override async Task Sqrt(bool async) + { + await base.Sqrt(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Double" > 0.0 AND sqrt("b"."Double") > 0.0 +"""); + } + + public override async Task Sqrt_float(bool async) + { + await base.Sqrt_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Float" > 0 AND sqrt("b"."Float") > 0 +"""); + } + + public override async Task Sign(bool async) + { + await base.Sign(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE sign("b"."Double") > 0.0 +"""); + } + + public override async Task Sign_float(bool async) + { + await base.Sign_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE sign("b"."Float") > 0 +"""); + } + + public override async Task Max(bool async) + { + await base.Max(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE max("b"."Int", "b"."Short" - 3) = "b"."Int" +"""); + } + + public override async Task Max_nested(bool async) + { + await base.Max_nested(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE max("b"."Short" - 3, "b"."Int", 1) = "b"."Int" +"""); + } + + public override async Task Max_nested_twice(bool async) + { + await base.Max_nested_twice(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE max(1, "b"."Int", 2, "b"."Short" - 3) = "b"."Int" +"""); + } + + public override async Task Min(bool async) + { + await base.Min(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE min("b"."Int", "b"."Short" + 3) = "b"."Int" +"""); + } + + public override async Task Min_nested(bool async) + { + await base.Min_nested(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE min("b"."Short" + 3, "b"."Int", 99999) = "b"."Int" +"""); + } + + public override async Task Min_nested_twice(bool async) + { + await base.Min_nested_twice(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE min(99999, "b"."Int", 99998, "b"."Short" + 3) = "b"."Int" +"""); + } + + public override async Task Degrees(bool async) + { + await base.Degrees(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE degrees("b"."Double") > 0.0 +"""); + } + + public override async Task Degrees_float(bool async) + { + await base.Degrees_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE degrees("b"."Float") > 0 +"""); + } + + public override async Task Radians(bool async) + { + await base.Radians(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE radians("b"."Double") > 0.0 +"""); + } + + public override async Task Radians_float(bool async) + { + await base.Radians_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE radians("b"."Float") > 0 +"""); + } + + #region Trigonometry + + public override async Task Acos(bool async) + { + await base.Acos(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Double" >= -1.0 AND "b"."Double" <= 1.0 AND acos("b"."Double") > 1.0 +"""); + } + + public override async Task Acos_float(bool async) + { + await base.Acos_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Float" >= -1 AND "b"."Float" <= 1 AND acos("b"."Float") > 0 +"""); + } + + public override async Task Acosh(bool async) + { + await base.Acosh(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE acosh("b"."Double" + 1.0) > 0.0 +"""); + } + + public override async Task Asin(bool async) + { + await base.Asin(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Double" >= -1.0 AND "b"."Double" <= 1.0 AND asin("b"."Double") > -1.7976931348623157E+308 +"""); + } + + public override async Task Asin_float(bool async) + { + await base.Asin_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Float" >= -1 AND "b"."Float" <= 1 AND CAST(asin("b"."Float") AS REAL) > -1.7976931348623157E+308 +"""); + } + + public override async Task Asinh(bool async) + { + await base.Asinh(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE asinh("b"."Double") > 0.0 +"""); + } + + public override async Task Atan(bool async) + { + await base.Atan(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE atan("b"."Double") > 0.0 +"""); + } + + public override async Task Atan_float(bool async) + { + await base.Atan_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE atan("b"."Float") > 0 +"""); + } + + public override async Task Atanh(bool async) + { + await base.Atanh(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE atanh("b"."Double") > -1.7976931348623157E+308 +"""); + } + + public override async Task Atan2(bool async) + { + await base.Atan2(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE atan2("b"."Double", 1.0) > 0.0 +"""); + } + + public override async Task Atan2_float(bool async) + { + await base.Atan2_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE atan2("b"."Float", 1) > 0 +"""); + } + + public override async Task Cos(bool async) + { + await base.Cos(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE cos("b"."Double") > 0.0 +"""); + } + + public override async Task Cos_float(bool async) + { + await base.Cos_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE cos("b"."Float") > 0 +"""); + } + + public override async Task Cosh(bool async) + { + await base.Cosh(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE cosh("b"."Double") > 0.0 +"""); + } + + public override async Task Sin(bool async) + { + await base.Sin(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE sin("b"."Double") > 0.0 +"""); + } + + public override async Task Sin_float(bool async) + { + await base.Sin_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE sin("b"."Float") > 0 +"""); + } + + public override async Task Sinh(bool async) + { + await base.Sinh(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE sinh("b"."Double") > 0.0 +"""); + } + + public override async Task Tan(bool async) + { + await base.Tan(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE tan("b"."Double") > 0.0 +"""); + } + + public override async Task Tan_float(bool async) + { + await base.Tan_float(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE tan("b"."Float") > 0 +"""); + } + + public override async Task Tanh(bool async) + { + await base.Tanh(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE tanh("b"."Double") > 0.0 +"""); + } + + #endregion Trigonometry + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs new file mode 100644 index 00000000000..87b01cf25e1 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/MiscellaneousTranslationsSqliteTest.cs @@ -0,0 +1,283 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class MiscellaneousTranslationsSqliteTest : MiscellaneousTranslationsTestBase +{ + public MiscellaneousTranslationsSqliteTest(BasicTypesQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Guid + + public override async Task Guid_new_with_constant(bool async) + { + await base.Guid_new_with_constant(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Guid" = 'DF36F493-463F-4123-83F9-6B135DEEB7BA' +"""); + } + + public override async Task Guid_new_with_parameter(bool async) + { + await base.Guid_new_with_parameter(async); + + AssertSql( + """ +@p='df36f493-463f-4123-83f9-6b135deeb7ba' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Guid" = @p +"""); + } + + public override async Task Guid_ToString_projection(bool async) + { + await base.Guid_ToString_projection(async); + + AssertSql( + """ +SELECT CAST("b"."Guid" AS TEXT) +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override Task Guid_NewGuid(bool async) + => AssertTranslationFailed(() => base.Guid_NewGuid(async)); + + #endregion Guid + + #region Byte array + + public override async Task Byte_array_Length(bool async) + { + await base.Byte_array_Length(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."ByteArray") = 4 +"""); + } + + // Array access. Issue #16428. + public override Task Byte_array_array_index(bool async) + => AssertTranslationFailed(() => base.Byte_array_array_index(async)); + + // Array access. Issue #16428. + public override Task Byte_array_First(bool async) + => AssertTranslationFailed(() => base.Byte_array_First(async)); + + #endregion Byte array + + #region Convert + + public override Task Convert_ToBoolean(bool async) + => AssertTranslationFailed(() => base.Convert_ToBoolean(async)); + + public override Task Convert_ToByte(bool async) + => AssertTranslationFailed(() => base.Convert_ToByte(async)); + + public override Task Convert_ToDecimal(bool async) + => AssertTranslationFailed(() => base.Convert_ToDecimal(async)); + + public override Task Convert_ToDouble(bool async) + => AssertTranslationFailed(() => base.Convert_ToDouble(async)); + + public override Task Convert_ToInt16(bool async) + => AssertTranslationFailed(() => base.Convert_ToInt16(async)); + + public override Task Convert_ToInt32(bool async) + => AssertTranslationFailed(() => base.Convert_ToInt32(async)); + + public override Task Convert_ToInt64(bool async) + => AssertTranslationFailed(() => base.Convert_ToInt64(async)); + + public override Task Convert_ToString(bool async) + => AssertTranslationFailed(() => base.Convert_ToString(async)); + + #endregion Convert + + #region Compare + + public override async Task Int_Compare_to_simple_zero(bool async) + { + await base.Int_Compare_to_simple_zero(async); + +AssertSql( +""" +@orderId='8' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" = @orderId +""", + // + """ +@orderId='8' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" <> @orderId +""", + // + """ +@orderId='8' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" > @orderId +""", + // + """ +@orderId='8' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" <= @orderId +""", + // + """ +@orderId='8' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" > @orderId +""", + // + """ +@orderId='8' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."Int" <= @orderId +"""); + } + + public override async Task DateTime_Compare_to_simple_zero(bool async, bool compareTo) + { + await base.DateTime_Compare_to_simple_zero(async, compareTo); + + AssertSql( +""" +@dateTime='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" = @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" <> @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" > @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" <= @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" > @dateTime +""", + // + """ +@dateTime='1998-05-04T15:30:10.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" <= @dateTime +"""); + } + + public override async Task TimeSpan_Compare_to_simple_zero(bool async, bool compareTo) + { + await base.TimeSpan_Compare_to_simple_zero(async, compareTo); + + AssertSql( +""" +@timeSpan='01:02:03' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."TimeSpan" = @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."TimeSpan" <> @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."TimeSpan" > @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."TimeSpan" <= @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."TimeSpan" > @timeSpan +""", + // + """ +@timeSpan='01:02:03' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."TimeSpan" <= @timeSpan +"""); + } + + #endregion Compare + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs new file mode 100644 index 00000000000..48a318ac958 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/StringTranslationsSqliteTest.cs @@ -0,0 +1,1517 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Text.RegularExpressions; +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class StringTranslationsSqliteTest : StringTranslationsRelationalTestBase +{ + public StringTranslationsSqliteTest(BasicTypesQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region Equals + + public override async Task Equals(bool async) + { + await base.Equals(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'Seattle' +"""); + } + + public override async Task Equals_with_OrdinalIgnoreCase(bool async) + { + await base.Equals_with_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task Equals_with_Ordinal(bool async) + { + await base.Equals_with_Ordinal(async); + + AssertSql(); + } + + public override async Task Static_Equals(bool async) + { + await base.Static_Equals(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'Seattle' +"""); + } + + public override async Task Static_Equals_with_OrdinalIgnoreCase(bool async) + { + await base.Static_Equals_with_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task Static_Equals_with_Ordinal(bool async) + { + await base.Static_Equals_with_Ordinal(async); + + AssertSql(); + } + + #endregion Equals + + #region Miscellaneous + + public override async Task Length(bool async) + { + await base.Length(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."String") = 7 +"""); + } + + public override async Task ToLower(bool async) + { + await base.ToLower(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE lower("b"."String") = 'seattle' +"""); + } + + public override async Task ToUpper(bool async) + { + await base.ToUpper(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE upper("b"."String") = 'SEATTLE' +"""); + } + + #endregion Miscellaneous + + #region IndexOf + + public override async Task IndexOf(bool async) + { + await base.IndexOf(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", 'eattl') - 1 <> -1 +"""); + } + + public override async Task IndexOf_with_empty_string(bool async) + { + await base.IndexOf_with_empty_string(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", '') - 1 = 0 +"""); + } + + public override async Task IndexOf_with_one_parameter_arg(bool async) + { + await base.IndexOf_with_one_parameter_arg(async); + + AssertSql( + """ +@pattern='eattl' (Size = 5) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", @pattern) - 1 = 1 +"""); + } + + public override Task IndexOf_with_constant_starting_position(bool async) + => AssertTranslationFailed(() => base.IndexOf_with_constant_starting_position(async)); + + public override Task IndexOf_with_parameter_starting_position(bool async) + => AssertTranslationFailed(() => base.IndexOf_with_parameter_starting_position(async)); + + public override async Task IndexOf_after_ToString(bool async) + { + await base.IndexOf_after_ToString(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr(CAST("b"."Int" AS TEXT), '55') - 1 = 1 +"""); + } + + public override async Task IndexOf_over_ToString(bool async) + { + await base.IndexOf_over_ToString(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr('12559', CAST("b"."Int" AS TEXT)) - 1 = 1 +"""); + } + + #endregion IndexOf + + #region Replace + + public override async Task Replace(bool async) + { + await base.Replace(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE replace("b"."String", 'Sea', 'Rea') = 'Reattle' +"""); + } + + public override async Task Replace_with_empty_string(bool async) + { + await base.Replace_with_empty_string(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <> '' AND replace("b"."String", "b"."String", '') = '' +"""); + } + + public override async Task Replace_using_property_arguments(bool async) + { + await base.Replace_using_property_arguments(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <> '' AND replace("b"."String", "b"."String", CAST("b"."Int" AS TEXT)) = CAST("b"."Int" AS TEXT) +"""); + } + + #endregion Replace + + #region Substring + + public override async Task Substring(bool async) + { + await base.Substring(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."String") >= 3 AND substr("b"."String", 1 + 1, 2) = 'ea' +"""); + } + + public override async Task Substring_with_one_arg_with_zero_startIndex(bool async) + { + await base.Substring_with_one_arg_with_zero_startIndex(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE substr("b"."String", 0 + 1) = 'Seattle' +"""); + } + + public override async Task Substring_with_one_arg_with_constant(bool async) + { + await base.Substring_with_one_arg_with_constant(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."String") >= 1 AND substr("b"."String", 1 + 1) = 'eattle' +"""); + } + + public override async Task Substring_with_one_arg_with_parameter(bool async) + { + await base.Substring_with_one_arg_with_parameter(async); + + AssertSql( + """ +@start='2' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."String") >= 2 AND substr("b"."String", @start + 1) = 'attle' +"""); + } + + public override async Task Substring_with_two_args_with_zero_startIndex(bool async) + { + await base.Substring_with_two_args_with_zero_startIndex(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."String") >= 3 AND substr("b"."String", 0 + 1, 3) = 'Sea' +"""); + } + + public override async Task Substring_with_two_args_with_parameter(bool async) + { + await base.Substring_with_two_args_with_parameter(async); + + AssertSql( + """ +@start='2' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."String") >= 5 AND substr("b"."String", @start + 1, 3) = 'att' +"""); + } + + public override async Task Substring_with_two_args_with_IndexOf(bool async) + { + await base.Substring_with_two_args_with_IndexOf(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", 'a') > 0 AND substr("b"."String", (instr("b"."String", 'a') - 1) + 1, 3) = 'att' +"""); + } + + public override async Task Substring_with_two_args_with_zero_length(bool async) + { + await base.Substring_with_two_args_with_zero_length(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE length("b"."String") >= 2 AND substr("b"."String", 2 + 1, 0) = '' +"""); + } + + #endregion Substring + + #region IsNullOrEmpty/Whitespace + + public override async Task IsNullOrEmpty(bool async) + { + await base.IsNullOrWhiteSpace(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE trim("b"."String") = '' +"""); + } + + public override async Task IsNullOrEmpty_negated(bool async) + { + await base.IsNullOrEmpty_negated(async); + + AssertSql( + """ +SELECT "n"."Id", "n"."Bool", "n"."Byte", "n"."ByteArray", "n"."DateOnly", "n"."DateTime", "n"."DateTimeOffset", "n"."Decimal", "n"."Double", "n"."Enum", "n"."FlagsEnum", "n"."Float", "n"."Guid", "n"."Int", "n"."Long", "n"."Short", "n"."String", "n"."TimeOnly", "n"."TimeSpan" +FROM "NullableBasicTypesEntities" AS "n" +WHERE "n"."String" IS NOT NULL AND "n"."String" <> '' +""", + // + """ +SELECT "n"."String" IS NOT NULL AND "n"."String" <> '' +FROM "NullableBasicTypesEntities" AS "n" +"""); + } + + public override async Task IsNullOrWhiteSpace(bool async) + { + await base.IsNullOrWhiteSpace(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE trim("b"."String") = '' +"""); + } + + #endregion IsNullOrEmpty/Whitespace + + #region StartsWith + + public override async Task StartsWith_Literal(bool async) + { + await base.StartsWith_Literal(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" LIKE 'Se%' +"""); + } + + public override async Task StartsWith_Parameter(bool async) + { + await base.StartsWith_Parameter(async); + + AssertSql( + """ +@pattern_startswith='Se%' (Size = 3) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" LIKE @pattern_startswith ESCAPE '\' +"""); + } + + public override async Task StartsWith_Column(bool async) + { + await base.StartsWith_Column(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE substr("b"."String", 1, length("b"."String")) = "b"."String" OR "b"."String" = '' +"""); + } + + public override async Task StartsWith_with_StringComparison_Ordinal(bool async) + { + await base.StartsWith_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task StartsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.StartsWith_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task StartsWith_with_StringComparison_unsupported(bool async) + { + await base.StartsWith_with_StringComparison_unsupported(async); + + AssertSql(); + } + + #endregion StartsWith + + #region EndsWith + + public override async Task EndsWith_Literal(bool async) + { + await base.EndsWith_Literal(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" LIKE '%le' +"""); + } + + public override async Task EndsWith_Parameter(bool async) + { + await base.EndsWith_Parameter(async); + + AssertSql( + """ +@pattern_endswith='%le' (Size = 3) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" LIKE @pattern_endswith ESCAPE '\' +"""); + } + + public override async Task EndsWith_Column(bool async) + { + await base.EndsWith_Column(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE substr("b"."String", -length("b"."String")) = "b"."String" OR "b"."String" = '' +"""); + } + + public override async Task EndsWith_with_StringComparison_Ordinal(bool async) + { + await base.EndsWith_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task EndsWith_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.EndsWith_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task EndsWith_with_StringComparison_unsupported(bool async) + { + await base.EndsWith_with_StringComparison_unsupported(async); + + AssertSql(); + } + + #endregion EndsWith + + #region Contains + + public override async Task Contains_Literal(bool async) + { + await base.Contains_Literal(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", 'eattl') > 0 +"""); + } + + public override async Task Contains_Column(bool async) + { + await base.Contains_Column(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", "b"."String") > 0 +""", + // + """ +SELECT instr("b"."String", "b"."String") > 0 +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Contains_negated(bool async) + { + await base.Contains_negated(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", 'eattle') <= 0 +""", + // + """ +SELECT instr("b"."String", 'eattle') <= 0 +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task Contains_with_StringComparison_Ordinal(bool async) + { + await base.Contains_with_StringComparison_Ordinal(async); + + AssertSql(); + } + + public override async Task Contains_with_StringComparison_OrdinalIgnoreCase(bool async) + { + await base.Contains_with_StringComparison_OrdinalIgnoreCase(async); + + AssertSql(); + } + + public override async Task Contains_with_StringComparison_unsupported(bool async) + { + await base.Contains_with_StringComparison_unsupported(async); + + AssertSql(); + } + + public override async Task Contains_constant_with_whitespace(bool async) + { + await base.Contains_constant_with_whitespace(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", ' ') > 0 +"""); + } + + public override async Task Contains_parameter_with_whitespace(bool async) + { + await base.Contains_parameter_with_whitespace(async); + + AssertSql( + """ +@pattern=' ' (Size = 5) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE instr("b"."String", @pattern) > 0 +"""); + } + + #endregion Contains + + #region TrimStart + + public override async Task TrimStart_without_arguments(bool async) + { + await base.TrimStart_without_arguments(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE ltrim("b"."String") = 'Boston ' +"""); + } + + public override async Task TrimStart_with_char_argument(bool async) + { + await base.TrimStart_with_char_argument(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE ltrim("b"."String", 'S') = 'eattle' +"""); + } + + public override async Task TrimStart_with_char_array_argument(bool async) + { + await base.TrimStart_with_char_array_argument(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE ltrim("b"."String", 'Se') = 'attle' +"""); + } + + #endregion TrimStart + + #region TrimEnd + + public override async Task TrimEnd_without_arguments(bool async) + { + await base.TrimEnd_without_arguments(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE rtrim("b"."String") = ' Boston' +"""); + } + + public override async Task TrimEnd_with_char_argument(bool async) + { + await base.TrimEnd_with_char_argument(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE rtrim("b"."String", 'e') = 'Seattl' +"""); + } + + public override async Task TrimEnd_with_char_array_argument(bool async) + { + await base.TrimEnd_with_char_array_argument(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE rtrim("b"."String", 'le') = 'Seatt' +"""); + } + + #endregion TrimEnd + + #region Trim + + public override async Task Trim_without_argument_in_predicate(bool async) + { + await base.Trim_without_argument_in_predicate(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE trim("b"."String") = 'Boston' +"""); + } + + public override async Task Trim_with_char_argument_in_predicate(bool async) + { + await base.Trim_with_char_argument_in_predicate(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE trim("b"."String", 'S') = 'eattle' +"""); + } + + public override async Task Trim_with_char_array_argument_in_predicate(bool async) + { + await base.Trim_with_char_array_argument_in_predicate(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE trim("b"."String", 'Se') = 'attl' +"""); + } + + #endregion Trim + + #region Compare + + public override async Task Compare_simple_zero(bool async) + { + await base.Compare_simple_zero(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <> 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +"""); + } + + public override async Task Compare_simple_one(bool async) + { + await base.Compare_simple_one(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" < 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= 'Seattle' +"""); + } + + public override async Task Compare_with_parameter(bool async) + { + await base.Compare_with_parameter(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'Seattle' +LIMIT 2 +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" < @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= @basicTypeEntity_String +""", + // + """ +@basicTypeEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= @basicTypeEntity_String +"""); + } + + public override async Task Compare_simple_more_than_one(bool async) + { + await base.Compare_simple_more_than_one(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CASE + WHEN "b"."String" = 'Seattle' THEN 0 + WHEN "b"."String" > 'Seattle' THEN 1 + WHEN "b"."String" < 'Seattle' THEN -1 +END = 42 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CASE + WHEN "b"."String" = 'Seattle' THEN 0 + WHEN "b"."String" > 'Seattle' THEN 1 + WHEN "b"."String" < 'Seattle' THEN -1 +END > 42 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE 42 > CASE + WHEN "b"."String" = 'Seattle' THEN 0 + WHEN "b"."String" > 'Seattle' THEN 1 + WHEN "b"."String" < 'Seattle' THEN -1 +END +"""); + } + + public override async Task Compare_nested(bool async) + { + await base.Compare_nested(async); + +AssertSql( +""" +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'M' || "b"."String" +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <> substr("b"."String", 0 + 1, 0) +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > replace('Seattle', 'Sea', "b"."String") +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'M' || "b"."String" +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > substr("b"."String", 0 + 1, 0) +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" < replace('Seattle', 'Sea', "b"."String") +"""); + } + + public override async Task Compare_multi_predicate(bool async) + { + await base.Compare_multi_predicate(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= 'Seattle' AND "b"."String" < 'Toronto' +"""); + } + + public override async Task CompareTo_simple_zero(bool async) + { + await base.CompareTo_simple_zero(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <> 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +"""); + } + + public override async Task CompareTo_simple_one(bool async) + { + await base.CompareTo_simple_one(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" < 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= 'Seattle' +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= 'Seattle' +"""); + } + + public override async Task CompareTo_with_parameter(bool async) + { + await base.CompareTo_with_parameter(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'Seattle' +LIMIT 2 +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" < @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= @basicTypesEntity_String +""", + // + """ +@basicTypesEntity_String='Seattle' (Size = 7) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= @basicTypesEntity_String +"""); + } + + public override async Task CompareTo_simple_more_than_one(bool async) + { + await base.CompareTo_simple_more_than_one(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CASE + WHEN "b"."String" = 'Seattle' THEN 0 + WHEN "b"."String" > 'Seattle' THEN 1 + WHEN "b"."String" < 'Seattle' THEN -1 +END = 42 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CASE + WHEN "b"."String" = 'Seattle' THEN 0 + WHEN "b"."String" > 'Seattle' THEN 1 + WHEN "b"."String" < 'Seattle' THEN -1 +END > 42 +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE 42 > CASE + WHEN "b"."String" = 'Seattle' THEN 0 + WHEN "b"."String" > 'Seattle' THEN 1 + WHEN "b"."String" < 'Seattle' THEN -1 +END +"""); + } + + public override async Task CompareTo_nested(bool async) + { + await base.CompareTo_nested(async); + +AssertSql( +""" +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" = 'M' || "b"."String" +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <> substr("b"."String", 0 + 1, 0) +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > replace('Seattle', 'Sea', "b"."String") +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" <= 'M' || "b"."String" +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" > substr("b"."String", 0 + 1, 0) +""", + // + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" < replace('Seattle', 'Sea', "b"."String") +"""); + } + + public override async Task Compare_to_multi_predicate(bool async) + { + await base.Compare_to_multi_predicate(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" >= 'Seattle' AND "b"."String" < 'Toronto' +"""); + } + + #endregion Compare + + #region Join + + public override async Task Join_over_non_nullable_column(bool async) + { + await base.Join_over_non_nullable_column(async); + + AssertSql( + """ +SELECT "b"."Int" AS "Key", COALESCE(group_concat("b"."String", '|'), '') AS "Strings" +FROM "BasicTypesEntities" AS "b" +GROUP BY "b"."Int" +"""); + } + + public override async Task Join_over_nullable_column(bool async) + { + await base.Join_over_nullable_column(async); + + AssertSql( + """ +SELECT "n0"."Key", COALESCE(group_concat(COALESCE("n0"."String", ''), '|'), '') AS "Regions" +FROM ( + SELECT "n"."String", COALESCE("n"."Int", 0) AS "Key" + FROM "NullableBasicTypesEntities" AS "n" +) AS "n0" +GROUP BY "n0"."Key" +"""); + } + + public override async Task Join_with_predicate(bool async) + { + await base.Join_with_predicate(async); + + AssertSql( + """ +SELECT "b"."Int" AS "Key", COALESCE(group_concat(CASE + WHEN length("b"."String") > 6 THEN "b"."String" +END, '|'), '') AS "Strings" +FROM "BasicTypesEntities" AS "b" +GROUP BY "b"."Int" +"""); + } + + public override async Task Join_with_ordering(bool async) + { + // SQLite does not support input ordering on aggregate methods; the below does client evaluation. + await base.Join_with_ordering(async); + + AssertSql( + """ +SELECT "b1"."Int", "b0"."String", "b0"."Id" +FROM ( + SELECT "b"."Int" + FROM "BasicTypesEntities" AS "b" + GROUP BY "b"."Int" +) AS "b1" +LEFT JOIN "BasicTypesEntities" AS "b0" ON "b1"."Int" = "b0"."Int" +ORDER BY "b1"."Int", "b0"."Id" DESC +"""); + } + + public override Task Join_non_aggregate(bool async) + => AssertTranslationFailed(() => base.Join_non_aggregate(async)); + + #endregion Join + + #region Concatenation + + public override async Task Concat_aggregate(bool async) + { + await base.Concat_aggregate(async); + + AssertSql( + """ +SELECT "b"."Int" AS "Key", COALESCE(group_concat("b"."String", ''), '') AS "BasicTypesEntitys" +FROM "BasicTypesEntities" AS "b" +GROUP BY "b"."Int" +"""); + } + + public override async Task Concat_string_int_comparison1(bool async) + { + await base.Concat_string_int_comparison1(async); + + AssertSql( + """ +@i='10' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" || CAST(@i AS TEXT) = 'Seattle10' +"""); + } + + public override async Task Concat_string_int_comparison2(bool async) + { + await base.Concat_string_int_comparison2(async); + + AssertSql( + """ +@i='10' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(@i AS TEXT) || "b"."String" = '10Seattle' +"""); + } + + public override async Task Concat_string_int_comparison3(bool async) + { + await base.Concat_string_int_comparison3(async); + + AssertSql( + """ +@p='30' +@j='21' + +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(@p AS TEXT) || "b"."String" || CAST(@j AS TEXT) || CAST(42 AS TEXT) = '30Seattle2142' +"""); + } + + public override async Task Concat_string_int_comparison4(bool async) + { + await base.Concat_string_int_comparison4(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST("b"."Int" AS TEXT) || "b"."String" = '8Seattle' +"""); + } + + public override async Task Concat_string_string_comparison(bool async) + { + await base.Concat_string_string_comparison(async); + + AssertSql( + """ +@i='A' (Size = 1) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE @i || "b"."String" = 'ASeattle' +"""); + } + + public override async Task Concat_method_comparison(bool async) + { + await base.Concat_method_comparison(async); + + AssertSql( + """ +@i='A' (Size = 1) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE @i || "b"."String" = 'ASeattle' +"""); + } + + public override async Task Concat_method_comparison_2(bool async) + { + await base.Concat_method_comparison_2(async); + + AssertSql( + """ +@i='A' (Size = 1) +@j='B' (Size = 1) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE @i || @j || "b"."String" = 'ABSeattle' +"""); + } + + public override async Task Concat_method_comparison_3(bool async) + { + await base.Concat_method_comparison_3(async); + + AssertSql( + """ +@i='A' (Size = 1) +@j='B' (Size = 1) +@k='C' (Size = 1) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE @i || @j || @k || "b"."String" = 'ABCSeattle' +"""); + } + + #endregion Concatenation + + #region LINQ Operators + + public override async Task FirstOrDefault(bool async) + { + await base.FirstOrDefault(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE substr("b"."String", 1, 1) = 'S' +"""); + } + + public override async Task LastOrDefault(bool async) + { + await base.LastOrDefault(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE substr("b"."String", length("b"."String"), 1) = 'e' +"""); + } + + #endregion LINQ Operators + + #region Regex + + public override async Task Regex_IsMatch(bool async) + { + await base.Regex_IsMatch(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" REGEXP '^S' +"""); + } + + public override async Task Regex_IsMatch_constant_input(bool async) + { + await base.Regex_IsMatch_constant_input(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE 'Seattle' REGEXP "b"."String" +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Regex_IsMatch_negated(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(o => !Regex.IsMatch(o.String, "^[^S]"))); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" NOT REGEXP '^[^S]' +"""); + } + + #endregion Regex + + #region Like + + public override async Task Where_Like_and_comparison(bool async) + { + await base.Where_Like_and_comparison(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" LIKE 'S%' AND "b"."Int" = 8 +"""); + } + + public override async Task Where_Like_or_comparison(bool async) + { + await base.Where_Like_or_comparison(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."String" LIKE 'S%' OR "b"."Int" = 2147483647 +"""); + } + + public override async Task Like_with_non_string_column_using_ToString(bool async) + { + await base.Like_with_non_string_column_using_ToString(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST("b"."Int" AS TEXT) LIKE '%5%' +"""); + } + + public override async Task Like_with_non_string_column_using_double_cast(bool async) + { + await base.Like_with_non_string_column_using_double_cast(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST("b"."Int" AS TEXT) LIKE '%5%' +"""); + } + + #endregion Like + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs new file mode 100644 index 00000000000..42e7a74f234 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/Translations/TemporalTranslationsSqliteTest.cs @@ -0,0 +1,766 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using Microsoft.EntityFrameworkCore.TestModels.BasicTypesModel; + +namespace Microsoft.EntityFrameworkCore.Query.Translations; + +public class TemporalTranslationsSqliteTest : TemporalTranslationsTestBase +{ + public TemporalTranslationsSqliteTest(BasicTypesQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + #region DateTime + + public override async Task DateTime_Now(bool async) + { + await base.DateTime_Now(async); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime'), '0'), '.') <> @myDatetime +"""); + } + + public override async Task DateTime_UtcNow(bool async) + { + await base.DateTime_UtcNow(async); + + AssertSql( + """ +@myDatetime='2015-04-10T00:00:00.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now'), '0'), '.') <> @myDatetime +"""); + } + + public override async Task DateTime_Today(bool async) + { + await base.DateTime_Today(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTime" = rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', 'now', 'localtime', 'start of day'), '0'), '.') +"""); + } + + public override async Task DateTime_Date(bool async) + { + await base.DateTime_Date(async); + + AssertSql( + """ +@myDatetime='1998-05-04T00:00:00.0000000' (DbType = DateTime) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE rtrim(rtrim(strftime('%Y-%m-%d %H:%M:%f', "b"."DateTime", 'start of day'), '0'), '.') = @myDatetime +"""); + } + + public override async Task DateTime_AddYear(bool async) + { + await base.DateTime_AddYear(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%Y', "b"."DateTime", CAST(1 AS TEXT) || ' years') AS INTEGER) = 1999 +"""); + } + + public override async Task DateTime_Year(bool async) + { + await base.DateTime_Year(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%Y', "b"."DateTime") AS INTEGER) = 1998 +"""); + } + + public override async Task DateTime_Month(bool async) + { + await base.DateTime_Month(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%m', "b"."DateTime") AS INTEGER) = 5 +"""); + } + + public override async Task DateTime_DayOfYear(bool async) + { + await base.DateTime_DayOfYear(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%j', "b"."DateTime") AS INTEGER) = 124 +"""); + } + + public override async Task DateTime_Day(bool async) + { + await base.DateTime_Day(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%d', "b"."DateTime") AS INTEGER) = 4 +"""); + } + + public override async Task DateTime_Hour(bool async) + { + await base.DateTime_Hour(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%H', "b"."DateTime") AS INTEGER) = 15 +"""); + } + + public override async Task DateTime_Minute(bool async) + { + await base.DateTime_Minute(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%M', "b"."DateTime") AS INTEGER) = 30 +"""); + } + + public override async Task DateTime_Second(bool async) + { + await base.DateTime_Second(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%S', "b"."DateTime") AS INTEGER) = 10 +"""); + } + + public override async Task DateTime_Millisecond(bool async) + { + await base.DateTime_Millisecond(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE (CAST(strftime('%f', "b"."DateTime") AS REAL) * 1000.0) % 1000.0 = 123.0 +"""); + } + + public override async Task DateTime_TimeOfDay(bool async) + { + await base.DateTime_TimeOfDay(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE rtrim(rtrim(strftime('%H:%M:%f', "b"."DateTime"), '0'), '.') = '00:00:00' +"""); + } + + public override Task DateTime_subtract_and_TotalDays(bool async) + => AssertTranslationFailed(() => base.DateTime_subtract_and_TotalDays(async)); + + #endregion DateTime + + #region DateOnly + + public override async Task DateOnly_Year(bool async) + { + await base.DateOnly_Year(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%Y', "b"."DateOnly") AS INTEGER) = 1990 +"""); + } + + public override async Task DateOnly_Month(bool async) + { + await base.DateOnly_Month(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%m', "b"."DateOnly") AS INTEGER) = 11 +"""); + } + + public override async Task DateOnly_Day(bool async) + { + await base.DateOnly_Day(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%d', "b"."DateOnly") AS INTEGER) = 10 +"""); + } + + public override async Task DateOnly_DayOfYear(bool async) + { + await base.DateOnly_DayOfYear(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%j', "b"."DateOnly") AS INTEGER) = 314 +"""); + } + + public override async Task DateOnly_DayOfWeek(bool async) + { + await base.DateOnly_DayOfWeek(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%w', "b"."DateOnly") AS INTEGER) = 6 +"""); + } + + public override async Task DateOnly_AddYears(bool async) + { + await base.DateOnly_AddYears(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE date("b"."DateOnly", CAST(3 AS TEXT) || ' years') = '1993-11-10' +"""); + } + + public override async Task DateOnly_AddMonths(bool async) + { + await base.DateOnly_AddMonths(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE date("b"."DateOnly", CAST(3 AS TEXT) || ' months') = '1991-02-10' +"""); + } + + public override async Task DateOnly_AddDays(bool async) + { + await base.DateOnly_AddDays(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE date("b"."DateOnly", CAST(3 AS TEXT) || ' days') = '1990-11-13' +"""); + } + + public override async Task DateOnly_FromDateTime(bool async) + { + await base.DateOnly_FromDateTime(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE date("b"."DateTime") = '1998-05-04' +"""); + } + + public override async Task DateOnly_FromDateTime_compared_to_property(bool async) + { + await base.DateOnly_FromDateTime_compared_to_property(async); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE date("b"."DateTime") = "b"."DateOnly" +"""); + } + + public override async Task DateOnly_FromDateTime_compared_to_constant_and_parameter(bool async) + { + await base.DateOnly_FromDateTime_compared_to_constant_and_parameter(async); + + AssertSql( + """ +@dateOnly='10/11/0002' (DbType = Date) + +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" +FROM "BasicTypesEntities" AS "b" +WHERE date("b"."DateTime") IN (@dateOnly, '1998-05-04') +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_DateOnly_AddYears_Year(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(m => m.DateOnly.AddYears(3).Year == 1993)); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE CAST(strftime('%Y', "b"."DateOnly", CAST(3 AS TEXT) || ' years') AS INTEGER) = 1993 +"""); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Where_DateOnly_AddYears_AddMonths(bool async) + { + await AssertQuery( + async, + ss => ss.Set().Where(m => m.DateOnly.AddYears(3).AddMonths(3) == new DateOnly(1994, 2, 10))); + + AssertSql( + """ +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" +FROM "BasicTypesEntities" AS "b" +WHERE date("b"."DateOnly", CAST(3 AS TEXT) || ' years', CAST(3 AS TEXT) || ' months') = '1994-02-10' +"""); + } + + #endregion DateOnly + + #region TimeOnly + + public override async Task TimeOnly_Hour(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_Hour(async)); + + AssertSql(); + } + + public override async Task TimeOnly_Minute(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_Minute(async)); + + AssertSql(); + } + + public override async Task TimeOnly_Second(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_Second(async)); + + AssertSql(); + } + + public override async Task TimeOnly_Millisecond(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_Millisecond(async)); + + AssertSql(); + } + + public override async Task TimeOnly_Microsecond(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_Microsecond(async)); + + AssertSql(); + } + + public override async Task TimeOnly_Nanosecond(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_Nanosecond(async)); + + AssertSql(); + } + + public override async Task TimeOnly_AddHours(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_AddHours(async)); + + AssertSql(); + } + + public override async Task TimeOnly_AddMinutes(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_AddMinutes(async)); + + AssertSql(); + } + + public override async Task TimeOnly_Add_TimeSpan(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_Add_TimeSpan(async)); + + AssertSql(); + } + + public override async Task TimeOnly_IsBetween(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_IsBetween(async)); + + AssertSql(); + } + + public override async Task TimeOnly_subtract_TimeOnly(bool async) + { + // TimeSpan. Issue #18844. + await AssertTranslationFailed(() => base.TimeOnly_subtract_TimeOnly(async)); + + AssertSql(); + } + + public override async Task TimeOnly_FromDateTime_compared_to_property(bool async) + { + // TimeOnly/DateOnly is not supported. Issue #25103. + await AssertTranslationFailed(() => base.TimeOnly_FromDateTime_compared_to_property(async)); + + AssertSql(); + } + + public override async Task TimeOnly_FromDateTime_compared_to_parameter(bool async) + { + // TimeOnly/DateOnly is not supported. Issue #25103. + await AssertTranslationFailed(() => base.TimeOnly_FromDateTime_compared_to_parameter(async)); + + AssertSql(); + } + + public override async Task TimeOnly_FromDateTime_compared_to_constant(bool async) + { + // TimeOnly/DateOnly is not supported. Issue #25103. + await AssertTranslationFailed(() => base.TimeOnly_FromDateTime_compared_to_constant(async)); + + AssertSql(); + } + + public override async Task TimeOnly_FromTimeSpan_compared_to_property(bool async) + { + // TimeOnly/DateOnly is not supported. Issue #25103. + await AssertTranslationFailed(() => base.TimeOnly_FromTimeSpan_compared_to_property(async)); + + AssertSql(); + } + + public override async Task TimeOnly_FromTimeSpan_compared_to_parameter(bool async) + { + // TimeOnly/DateOnly is not supported. Issue #25103. + await AssertTranslationFailed(() => base.TimeOnly_FromTimeSpan_compared_to_parameter(async)); + + AssertSql(); + } + + public override async Task Order_by_TimeOnly_FromTimeSpan(bool async) + { + // TimeOnly/DateOnly is not supported. Issue #25103. + await AssertTranslationFailed(() => base.Order_by_TimeOnly_FromTimeSpan(async)); + + AssertSql(); + } + + #endregion TimeOnly + + #region DateTimeOffset + + public override async Task DateTimeOffset_Now(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Now(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_UtcNow(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_UtcNow(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Date(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Date(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Year(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Year(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Month(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Month(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_DayOfYear(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_DayOfYear(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Day(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Day(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Hour(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Hour(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Minute(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Minute(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Second(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Second(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Millisecond(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Millisecond(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Microsecond(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Microsecond(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_Nanosecond(bool async) + { + await AssertTranslationFailed(() => base.DateTimeOffset_Nanosecond(async)); + + AssertSql(); + } + + public override async Task DateTimeOffset_TimeOfDay(bool async) + { + await base.DateTimeOffset_TimeOfDay(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task DateTimeOffset_AddYears(bool async) + { + await base.DateTimeOffset_AddYears(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task DateTimeOffset_AddMonths(bool async) + { + await base.DateTimeOffset_AddMonths(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task DateTimeOffset_AddDays(bool async) + { + await base.DateTimeOffset_AddDays(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task DateTimeOffset_AddHours(bool async) + { + await base.DateTimeOffset_AddHours(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task DateTimeOffset_AddMinutes(bool async) + { + await base.DateTimeOffset_AddMinutes(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task DateTimeOffset_AddSeconds(bool async) + { + await base.DateTimeOffset_AddSeconds(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override async Task DateTimeOffset_AddMilliseconds(bool async) + { + await base.DateTimeOffset_AddMilliseconds(async); + + AssertSql( + """ +SELECT "b"."DateTimeOffset" +FROM "BasicTypesEntities" AS "b" +"""); + } + + public override Task DateTimeOffset_ToUnixTimeMilliseconds(bool async) + => AssertTranslationFailed(() => base.DateTimeOffset_ToUnixTimeMilliseconds(async)); + + public override Task DateTimeOffset_ToUnixTimeSecond(bool async) + => AssertTranslationFailed(() => base.DateTimeOffset_ToUnixTimeSecond(async)); + + public override async Task DateTimeOffset_milliseconds_parameter_and_constant(bool async) + { + await base.DateTimeOffset_milliseconds_parameter_and_constant(async); + + AssertSql( + """ +SELECT COUNT(*) +FROM "BasicTypesEntities" AS "b" +WHERE "b"."DateTimeOffset" = '1902-01-02 10:00:00.1234567+01:30' +"""); + } + + #endregion DateTimeOffset + + #region TimeSpan + + // Translate TimeSpan members, #18844 + public override async Task TimeSpan_Hours(bool async) + { + await AssertTranslationFailed(() => base.TimeSpan_Hours(async)); + + AssertSql(); + } + + // Translate TimeSpan members, #18844 + public override async Task TimeSpan_Minutes(bool async) + { + await AssertTranslationFailed(() => base.TimeSpan_Minutes(async)); + + AssertSql(); + } + + public override async Task TimeSpan_Seconds(bool async) + { + await AssertTranslationFailed(() => base.TimeSpan_Seconds(async)); + + AssertSql(); + } + + // Translate TimeSpan members, #18844 + public override async Task TimeSpan_Milliseconds(bool async) + { + await AssertTranslationFailed(() => base.TimeSpan_Milliseconds(async)); + + AssertSql(); + } + + // Translate TimeSpan members, #18844 + public override async Task TimeSpan_Microseconds(bool async) + { + await AssertTranslationFailed(() => base.TimeSpan_Microseconds(async)); + + AssertSql(); + } + + // Translate TimeSpan members, #18844 + public override async Task TimeSpan_Nanoseconds(bool async) + { + await AssertTranslationFailed(() => base.TimeSpan_Nanoseconds(async)); + + AssertSql(); + } + + #endregion TimeSpan + + [ConditionalFact] + public virtual void Check_all_tests_overridden() + => TestHelpers.AssertAllMethodsOverridden(GetType()); + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); +} From 68f6b89e0c89a8db8cf0333d8b2d9486c6680503 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Fri, 13 Dec 2024 09:06:09 +0100 Subject: [PATCH 2/2] Address review comments --- .../Translations/BasicTypesQueryCosmosFixture.cs | 14 ++++++++++++-- .../TestModels/BasicTypesModel/BasicFlagsEnum.cs | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs index bd958a2474c..3f0915cc096 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Translations/BasicTypesQueryCosmosFixture.cs @@ -19,8 +19,18 @@ protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext con { base.OnModelCreating(modelBuilder, context); - modelBuilder.Entity().ToContainer(nameof(BasicTypesEntity)); - modelBuilder.Entity().ToContainer(nameof(NullableBasicTypesEntity)); + modelBuilder.Entity( + builder => + { + builder.ToContainer(nameof(BasicTypesEntity)); + builder.HasPartitionKey(b => b.Id); + }); + modelBuilder.Entity( + builder => + { + builder.ToContainer(nameof(NullableBasicTypesEntity)); + builder.HasPartitionKey(n => n.Id); + }); } public Task NoSyncTest(bool async, Func testCode) diff --git a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs index 304a627bffe..ed479dcf3e8 100644 --- a/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs +++ b/test/EFCore.Specification.Tests/TestModels/BasicTypesModel/BasicFlagsEnum.cs @@ -9,8 +9,10 @@ public enum BasicFlagsEnum Zero = 0, One = 1, Two = 2, + Three = 3, Four = 4, Eight = 8, Sixteen = 16, ThirtyTwo = 32, + OneTwentyEight = 128, }