From 5cb3b37078fc8d8eb47376767c6946c035ede4bf Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Sun, 11 Jan 2026 10:16:15 +0100 Subject: [PATCH 1/2] Fix primitive/complex collection handling on subtypes Fixes #37478 --- ...ingExpressionVisitor.ExpressionVisitors.cs | 109 +++++++++--------- .../Inheritance/InheritanceQueryCosmosTest.cs | 14 +++ .../InheritanceQueryFixtureBase.cs | 1 + .../Inheritance/InheritanceQueryTestBase.cs | 7 ++ .../TestModels/InheritanceModel/Coke.cs | 4 +- .../InheritanceModel/InheritanceData.cs | 1 + ...eteMappingInheritanceQuerySqlServerTest.cs | 18 ++- .../TPCInheritanceJsonQuerySqlServerTest.cs | 34 +++--- .../TPCInheritanceQuerySqlServerTestBase.cs | 38 +++++- ...ritanceTableSplittingQuerySqlServerTest.cs | 34 +++--- .../TPHInheritanceJsonQuerySqlServerTest.cs | 10 +- .../TPHInheritanceQuerySqlServerTest.cs | 18 ++- ...ritanceTableSplittingQuerySqlServerTest.cs | 10 +- .../TPTInheritanceJsonQuerySqlServerTest.cs | 10 +- .../TPTInheritanceQuerySqlServerTest.cs | 25 +++- ...ritanceTableSplittingQuerySqlServerTest.cs | 10 +- 16 files changed, 224 insertions(+), 119 deletions(-) diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs index 8ce5687a98e..da7c7744e98 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs @@ -80,68 +80,73 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp var innerExpression = root.UnwrapTypeConversion(out var convertedType); var structuralTypeReference = UnwrapStructuralTypeReference(innerExpression); - var entityReference = structuralTypeReference as EntityReference; - if (entityReference is not null) + + ITypeBase structuralType; + + switch (structuralTypeReference) { - var entityType = entityReference.EntityType; - if (convertedType != null) - { - entityType = entityType.GetAllBaseTypes().Concat(entityType.GetDerivedTypesInclusive()) - .FirstOrDefault(et => et.ClrType == convertedType); - if (entityType == null) + case EntityReference { EntityType: var entityType } entityReference: + if (convertedType != null) { - return null; + entityType = entityType.GetAllBaseTypes().Concat(entityType.GetDerivedTypesInclusive()) + .FirstOrDefault(et => et.ClrType == convertedType); + if (entityType == null) + { + return null; + } } - } - var navigation = memberIdentity.MemberInfo is not null - ? entityType.FindNavigation(memberIdentity.MemberInfo) - : memberIdentity.Name is not null - ? entityType.FindNavigation(memberIdentity.Name) - : null; - if (navigation is not null) - { - return ExpandNavigation(root, entityReference, navigation, convertedType is not null); - } + // Attempt to bind navigations; these are only relevant to entity types + var navigation = memberIdentity.MemberInfo is not null + ? entityType.FindNavigation(memberIdentity.MemberInfo) + : memberIdentity.Name is not null + ? entityType.FindNavigation(memberIdentity.Name) + : null; + if (navigation is not null) + { + return ExpandNavigation(root, entityReference, navigation, convertedType is not null); + } - var skipNavigation = memberIdentity.MemberInfo is not null - ? entityType.FindSkipNavigation(memberIdentity.MemberInfo) - : memberIdentity.Name is not null - ? entityType.FindSkipNavigation(memberIdentity.Name) - : null; - if (skipNavigation is not null) - { - return ExpandSkipNavigation(root, entityReference, skipNavigation, convertedType is not null); - } + var skipNavigation = memberIdentity.MemberInfo is not null + ? entityType.FindSkipNavigation(memberIdentity.MemberInfo) + : memberIdentity.Name is not null + ? entityType.FindSkipNavigation(memberIdentity.Name) + : null; + if (skipNavigation is not null) + { + return ExpandSkipNavigation(root, entityReference, skipNavigation, convertedType is not null); + } + + structuralType = entityType; + break; + + case ComplexTypeReference { ComplexType: var complexType }: + structuralType = complexType; + break; + + default: + return null; } - var structuralType = entityReference is not null - ? (ITypeBase)entityReference.EntityType - : structuralTypeReference is ComplexTypeReference complexTypeReference - ? complexTypeReference.ComplexType + // Attempt to bind complex and primitive collection properties; this are common to both entity and complex types + var complexProperty = memberIdentity.MemberInfo != null + ? structuralType.FindComplexProperty(memberIdentity.MemberInfo) + : memberIdentity.Name is not null + ? structuralType.FindComplexProperty(memberIdentity.Name) : null; - - if (structuralType is not null) + if (complexProperty is not null) { - var complexProperty = memberIdentity.MemberInfo != null - ? structuralType.FindComplexProperty(memberIdentity.MemberInfo) - : memberIdentity.Name is not null - ? structuralType.FindComplexProperty(memberIdentity.Name) - : null; - if (complexProperty is not null) - { - return new ComplexPropertyReference(root, complexProperty, originalExpression); - } + return new ComplexPropertyReference(root, complexProperty, originalExpression); + } - var property = memberIdentity.MemberInfo != null - ? structuralType.FindProperty(memberIdentity.MemberInfo) - : memberIdentity.Name is not null - ? structuralType.FindProperty(memberIdentity.Name) - : null; - if (property?.IsPrimitiveCollection == true) - { - return new PrimitiveCollectionReference(root, property); - } + var property = memberIdentity.MemberInfo != null + ? structuralType.FindProperty(memberIdentity.MemberInfo) + : memberIdentity.Name is not null + ? structuralType.FindProperty(memberIdentity.Name) + : null; + if (property?.IsPrimitiveCollection == true) + { + return new PrimitiveCollectionReference(root, property); } return null; diff --git a/test/EFCore.Cosmos.FunctionalTests/Query/Inheritance/InheritanceQueryCosmosTest.cs b/test/EFCore.Cosmos.FunctionalTests/Query/Inheritance/InheritanceQueryCosmosTest.cs index 2153cfa33ff..e5b6cb558a6 100644 --- a/test/EFCore.Cosmos.FunctionalTests/Query/Inheritance/InheritanceQueryCosmosTest.cs +++ b/test/EFCore.Cosmos.FunctionalTests/Query/Inheritance/InheritanceQueryCosmosTest.cs @@ -681,6 +681,20 @@ public override Task Using_is_operator_with_of_type_on_multiple_type_with_no_res SELECT VALUE c FROM root c WHERE ((c["Discriminator"] IN ("Eagle", "Kiwi") AND (c["Discriminator"] = "Kiwi")) AND (c["Discriminator"] = "Eagle")) +"""); + }); + + public override Task Primitive_collection_on_subtype(bool async) + => Fixture.NoSyncTest( + async, async a => + { + await base.Primitive_collection_on_subtype(a); + + AssertSql( + """ +SELECT VALUE c +FROM root c +WHERE (c["Discriminator"] IN (0, 1, 2, 3) AND (ARRAY_LENGTH(c["Ints"]) > 0)) """); }); diff --git a/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryFixtureBase.cs index 31ea52d96d1..3ec1ef96ec5 100644 --- a/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryFixtureBase.cs @@ -340,6 +340,7 @@ public InheritanceQueryFixtureBase() Assert.Equal(ee.SugarGrams, aa.SugarGrams); Assert.Equal(ee.CaffeineGrams, aa.CaffeineGrams); Assert.Equal(ee.Carbonation, aa.Carbonation); + Assert.Equal(ee.Ints, aa.Ints); AssertComplexType(ee.ParentComplexType, aa.ParentComplexType); AssertComplexType(ee.ChildComplexType, aa.ChildComplexType); diff --git a/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryTestBase.cs index a882c0ca8f0..427acb31eac 100644 --- a/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/Inheritance/InheritanceQueryTestBase.cs @@ -469,6 +469,13 @@ public virtual Task GetType_in_hierarchy_in_leaf_type_with_sibling2_not_equal(bo async, ss => ss.Set().Where(e => typeof(Kiwi) != e.GetType())); + [ConditionalTheory, MemberData(nameof(IsAsyncData))] + public virtual Task Primitive_collection_on_subtype(bool async) + => AssertQuery( + async, + ss => ss.Set().Where(d => ((Coke)d).Ints.Any()), + ss => ss.Set().Where(d => d is Coke && ((Coke)d).Ints.Any())); + protected InheritanceContext CreateContext() => Fixture.CreateContext(); diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/Coke.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/Coke.cs index aa9bc97b2ce..912663bf104 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/Coke.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/Coke.cs @@ -9,6 +9,8 @@ public class Coke : Drink, ISugary public int CaffeineGrams { get; set; } public int Carbonation { get; set; } - // Samep roperty name as on Tea, to test uniquification + public required int[] Ints { get; set; } + + // Same property name as on Tea, to test uniquification public ComplexType? ChildComplexType { get; set; } } diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs index 8bdd54108b5..aa5cc1b1394 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs @@ -218,6 +218,7 @@ public static IReadOnlyList CreateDrinks(bool useGeneratedKeys) SugarGrams = 6, CaffeineGrams = 4, Carbonation = 5, + Ints = [8, 9], ChildComplexType = new ComplexType { UniqueInt = 100, diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/IncompleteMappingInheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/IncompleteMappingInheritanceQuerySqlServerTest.cs index 63f657a1a7d..6befb89f8d5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/IncompleteMappingInheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/IncompleteMappingInheritanceQuerySqlServerTest.cs @@ -42,7 +42,7 @@ public override async Task Can_query_when_shared_column(bool async) AssertSql( """ -SELECT TOP(2) [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] +SELECT TOP(2) [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE [d].[Discriminator] = 1 """, @@ -94,7 +94,7 @@ public override async Task Can_query_all_types_when_shared_column(bool async) AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE [d].[Discriminator] IN (0, 1, 2, 3) """); @@ -769,6 +769,20 @@ WHERE [a].[Discriminator] IN (N'Eagle', N'Kiwi') AND [a].[Discriminator] <> N'Ki """); } + public override async Task Primitive_collection_on_subtype(bool async) + { + await base.Primitive_collection_on_subtype(async); + + AssertSql( + """ +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] +FROM [Drinks] AS [d] +WHERE [d].[Discriminator] IN (0, 1, 2, 3) AND EXISTS ( + SELECT 1 + FROM OPENJSON([d].[Ints]) AS [i]) +"""); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQuerySqlServerTest.cs index 1b254d3809e..1e8325641cf 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceJsonQuerySqlServerTest.cs @@ -12,7 +12,7 @@ public override async Task Filter_on_complex_type_property_on_derived_type(bool AssertSql( """ -SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType] +SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType] FROM [Coke] AS [c] WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10 """); @@ -24,18 +24,18 @@ public override async Task Filter_on_complex_type_property_on_base_type(bool asy AssertSql( """ -SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator] +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator] FROM ( - SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator] + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator] FROM [Drinks] AS [d] UNION ALL - SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator] + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator] FROM [Coke] AS [c] UNION ALL - SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator] + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator] FROM [Lilt] AS [l] UNION ALL - SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator] + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator] FROM [Tea] AS [t] ) AS [u] WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Int') AS int) = 8 @@ -48,7 +48,7 @@ public override async Task Filter_on_nested_complex_type_property_on_derived_typ AssertSql( """ -SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType] +SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[ChildComplexType] FROM [Coke] AS [c] WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58 """); @@ -60,18 +60,18 @@ public override async Task Filter_on_nested_complex_type_property_on_base_type(b AssertSql( """ -SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator] +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator] FROM ( - SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator] + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator] FROM [Drinks] AS [d] UNION ALL - SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator] + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator] FROM [Coke] AS [c] UNION ALL - SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator] + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator] FROM [Lilt] AS [l] UNION ALL - SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator] + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator] FROM [Tea] AS [t] ) AS [u] WHERE CAST(JSON_VALUE([u].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50 @@ -152,18 +152,18 @@ public override async Task Subquery_over_complex_collection(bool async) AssertSql( """ -SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator] +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType], [u].[ChildComplexType], [u].[ChildComplexType1], [u].[Discriminator] FROM ( - SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator] + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Drink' AS [Discriminator] FROM [Drinks] AS [d] UNION ALL - SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator] + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[ParentComplexType], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Coke' AS [Discriminator] FROM [Coke] AS [c] UNION ALL - SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator] + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType1], N'Lilt' AS [Discriminator] FROM [Lilt] AS [l] UNION ALL - SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator] + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[ParentComplexType], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType] AS [ChildComplexType1], N'Tea' AS [Discriminator] FROM [Tea] AS [t] ) AS [u] WHERE ( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceQuerySqlServerTestBase.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceQuerySqlServerTestBase.cs index 923a1375721..cbd976f32a9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceQuerySqlServerTestBase.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceQuerySqlServerTestBase.cs @@ -150,18 +150,18 @@ public override async Task Can_query_all_types_when_shared_column(bool async) AssertSql( """ -SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] FROM ( - SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] FROM [Drinks] AS [d] UNION ALL - SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] FROM [Coke] AS [c] UNION ALL - SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] FROM [Lilt] AS [l] UNION ALL - SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] FROM [Tea] AS [t] ) AS [u] """); @@ -195,7 +195,7 @@ public override async Task Can_query_when_shared_column(bool async) AssertSql( """ -SELECT TOP(2) [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] +SELECT TOP(2) [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] FROM [Coke] AS [c] """, // @@ -733,6 +733,32 @@ WHERE [u].[Discriminator] <> N'Kiwi' """); } + public override async Task Primitive_collection_on_subtype(bool async) + { + await base.Primitive_collection_on_subtype(async); + + AssertSql( + """ +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] +FROM ( + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] + FROM [Drinks] AS [d] + UNION ALL + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] + FROM [Coke] AS [c] + UNION ALL + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] + FROM [Lilt] AS [l] + UNION ALL + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] + FROM [Tea] AS [t] +) AS [u] +WHERE EXISTS ( + SELECT 1 + FROM OPENJSON([u].[Ints]) AS [i]) +"""); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQuerySqlServerTest.cs index 6b1c8df4509..3588d8cab55 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPCInheritanceTableSplittingQuerySqlServerTest.cs @@ -12,7 +12,7 @@ public override async Task Filter_on_complex_type_property_on_derived_type(bool AssertSql( """ -SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] +SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] FROM [Coke] AS [c] WHERE [c].[ChildComplexType_Int] = 10 """); @@ -24,18 +24,18 @@ public override async Task Filter_on_complex_type_property_on_base_type(bool asy AssertSql( """ -SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] FROM ( - SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] FROM [Drinks] AS [d] UNION ALL - SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] FROM [Coke] AS [c] UNION ALL - SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] FROM [Lilt] AS [l] UNION ALL - SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] FROM [Tea] AS [t] ) AS [u] WHERE [u].[ParentComplexType_Int] = 8 @@ -48,7 +48,7 @@ public override async Task Filter_on_nested_complex_type_property_on_derived_typ AssertSql( """ -SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] +SELECT [c].[Id], [c].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ComplexTypeCollection], [c].[Int], [c].[UniqueInt], [c].[NestedInt], [c].[NestedComplexType_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] FROM [Coke] AS [c] WHERE [c].[ChildComplexType_Nested_NestedInt] = 58 """); @@ -60,18 +60,18 @@ public override async Task Filter_on_nested_complex_type_property_on_base_type(b AssertSql( """ -SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] FROM ( - SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] FROM [Drinks] AS [d] UNION ALL - SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] FROM [Coke] AS [c] UNION ALL - SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] FROM [Lilt] AS [l] UNION ALL - SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] FROM [Tea] AS [t] ) AS [u] WHERE [u].[ParentComplexType_Nested_NestedInt] = 50 @@ -146,18 +146,18 @@ public override async Task Subquery_over_complex_collection(bool async) AssertSql( """ -SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] +SELECT [u].[Id], [u].[SortIndex], [u].[CaffeineGrams], [u].[CokeCO2], [u].[Ints], [u].[SugarGrams], [u].[LiltCO2], [u].[SugarGrams1], [u].[CaffeineGrams1], [u].[HasMilk], [u].[ComplexTypeCollection], [u].[ParentComplexType_Int], [u].[ParentComplexType_UniqueInt], [u].[ParentComplexType_Nested_NestedInt], [u].[ParentComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int], [u].[ChildComplexType_UniqueInt], [u].[ChildComplexType_Nested_NestedInt], [u].[ChildComplexType_Nested_UniqueInt], [u].[ChildComplexType_Int1], [u].[ChildComplexType_UniqueInt1], [u].[ChildComplexType_Nested_NestedInt1], [u].[ChildComplexType_Nested_UniqueInt1], [u].[Discriminator] FROM ( - SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] + SELECT [d].[Id], [d].[SortIndex], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Drink' AS [Discriminator] FROM [Drinks] AS [d] UNION ALL - SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] + SELECT [c].[Id], [c].[SortIndex], [c].[ComplexTypeCollection], [c].[Int] AS [ParentComplexType_Int], [c].[UniqueInt] AS [ParentComplexType_UniqueInt], [c].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [c].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Coke' AS [Discriminator] FROM [Coke] AS [c] UNION ALL - SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] + SELECT [l].[Id], [l].[SortIndex], [l].[ComplexTypeCollection], [l].[Int] AS [ParentComplexType_Int], [l].[UniqueInt] AS [ParentComplexType_UniqueInt], [l].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [l].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], [l].[LiltCO2], [l].[SugarGrams] AS [SugarGrams1], NULL AS [CaffeineGrams1], NULL AS [HasMilk], NULL AS [ChildComplexType_Int1], NULL AS [ChildComplexType_UniqueInt1], NULL AS [ChildComplexType_Nested_NestedInt1], NULL AS [ChildComplexType_Nested_UniqueInt1], N'Lilt' AS [Discriminator] FROM [Lilt] AS [l] UNION ALL - SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] + SELECT [t].[Id], [t].[SortIndex], [t].[ComplexTypeCollection], [t].[Int] AS [ParentComplexType_Int], [t].[UniqueInt] AS [ParentComplexType_UniqueInt], [t].[NestedInt] AS [ParentComplexType_Nested_NestedInt], [t].[NestedComplexType_UniqueInt] AS [ParentComplexType_Nested_UniqueInt], NULL AS [CaffeineGrams], NULL AS [CokeCO2], NULL AS [Ints], NULL AS [SugarGrams], NULL AS [ChildComplexType_Int], NULL AS [ChildComplexType_UniqueInt], NULL AS [ChildComplexType_Nested_NestedInt], NULL AS [ChildComplexType_Nested_UniqueInt], NULL AS [LiltCO2], NULL AS [SugarGrams1], [t].[CaffeineGrams] AS [CaffeineGrams1], [t].[HasMilk], [t].[ChildComplexType_Int] AS [ChildComplexType_Int1], [t].[ChildComplexType_UniqueInt] AS [ChildComplexType_UniqueInt1], [t].[ChildComplexType_Nested_NestedInt] AS [ChildComplexType_Nested_NestedInt1], [t].[ChildComplexType_Nested_UniqueInt] AS [ChildComplexType_Nested_UniqueInt1], N'Tea' AS [Discriminator] FROM [Tea] AS [t] ) AS [u] WHERE ( diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQuerySqlServerTest.cs index c6d71790f21..a87f9602270 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceJsonQuerySqlServerTest.cs @@ -12,7 +12,7 @@ public override async Task Filter_on_complex_type_property_on_derived_type(bool AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType] FROM [Drinks] AS [d] WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Int') AS int) = 10 """); @@ -24,7 +24,7 @@ public override async Task Filter_on_complex_type_property_on_base_type(bool asy AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType] FROM [Drinks] AS [d] WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Int') AS int) = 8 """); @@ -36,7 +36,7 @@ public override async Task Filter_on_nested_complex_type_property_on_derived_typ AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType] FROM [Drinks] AS [d] WHERE [d].[Discriminator] = 1 AND CAST(JSON_VALUE([d].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58 """); @@ -48,7 +48,7 @@ public override async Task Filter_on_nested_complex_type_property_on_base_type(b AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType] FROM [Drinks] AS [d] WHERE CAST(JSON_VALUE([d].[ParentComplexType], '$.Nested.NestedInt') AS int) = 50 """); @@ -106,7 +106,7 @@ public override async Task Subquery_over_complex_collection(bool async) AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [d].[ChildComplexType], [d].[ChildComplexType] FROM [Drinks] AS [d] WHERE ( SELECT COUNT(*) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceQuerySqlServerTest.cs index 35b2336901d..4dfa7237be9 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceQuerySqlServerTest.cs @@ -39,7 +39,7 @@ public override async Task Can_query_when_shared_column(bool async) AssertSql( """ -SELECT TOP(2) [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] +SELECT TOP(2) [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE [d].[Discriminator] = 1 """, @@ -87,7 +87,7 @@ public override async Task Can_query_all_types_when_shared_column(bool async) AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] """); } @@ -740,6 +740,20 @@ WHERE [a].[Discriminator] <> N'Kiwi' """); } + public override async Task Primitive_collection_on_subtype(bool async) + { + await base.Primitive_collection_on_subtype(async); + + AssertSql( + """ +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] +FROM [Drinks] AS [d] +WHERE EXISTS ( + SELECT 1 + FROM OPENJSON([d].[Ints]) AS [i]) +"""); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQuerySqlServerTest.cs index 845d7c93a92..ab86cbf3eff 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPHInheritanceTableSplittingQuerySqlServerTest.cs @@ -14,7 +14,7 @@ public override async Task Filter_on_complex_type_property_on_derived_type(bool AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE [d].[Discriminator] = 1 AND [d].[ChildComplexType_Int] = 10 """); @@ -26,7 +26,7 @@ public override async Task Filter_on_complex_type_property_on_base_type(bool asy AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE [d].[ParentComplexType_Int] = 8 """); @@ -38,7 +38,7 @@ public override async Task Filter_on_nested_complex_type_property_on_derived_typ AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE [d].[Discriminator] = 1 AND [d].[ChildComplexType_Nested_NestedInt] = 58 """); @@ -50,7 +50,7 @@ public override async Task Filter_on_nested_complex_type_property_on_base_type(b AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE [d].[ParentComplexType_Nested_NestedInt] = 50 """); @@ -108,7 +108,7 @@ public override async Task Subquery_over_complex_collection(bool async) AssertSql( """ -SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[Discriminator], [d].[SortIndex], [d].[CaffeineGrams], [d].[CokeCO2], [d].[Ints], [d].[SugarGrams], [d].[LiltCO2], [d].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [d].[ChildComplexType_Int], [d].[ChildComplexType_UniqueInt], [d].[ChildComplexType_Nested_NestedInt], [d].[ChildComplexType_Nested_UniqueInt], [d].[Tea_ChildComplexType_Int], [d].[Tea_ChildComplexType_UniqueInt], [d].[Tea_ChildComplexType_Nested_NestedInt], [d].[Tea_ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] WHERE ( SELECT COUNT(*) diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQuerySqlServerTest.cs index 7266edb881c..3b7844c8fcc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceJsonQuerySqlServerTest.cs @@ -12,7 +12,7 @@ public override async Task Filter_on_complex_type_property_on_derived_type(bool AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType] +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType] FROM [Drinks] AS [d] INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id] WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Int') AS int) = 10 @@ -25,7 +25,7 @@ public override async Task Filter_on_complex_type_property_on_base_type(bool asy AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE WHEN [t].[Id] IS NOT NULL THEN N'Tea' WHEN [l].[Id] IS NOT NULL THEN N'Lilt' WHEN [c].[Id] IS NOT NULL THEN N'Coke' @@ -44,7 +44,7 @@ public override async Task Filter_on_nested_complex_type_property_on_derived_typ AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType] +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType] FROM [Drinks] AS [d] INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id] WHERE CAST(JSON_VALUE([c].[ChildComplexType], '$.Nested.NestedInt') AS int) = 58 @@ -57,7 +57,7 @@ public override async Task Filter_on_nested_complex_type_property_on_base_type(b AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE WHEN [t].[Id] IS NOT NULL THEN N'Tea' WHEN [l].[Id] IS NOT NULL THEN N'Lilt' WHEN [c].[Id] IS NOT NULL THEN N'Coke' @@ -122,7 +122,7 @@ public override async Task Subquery_over_complex_collection(bool async) AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType], [c].[ChildComplexType], [t].[ChildComplexType], CASE WHEN [t].[Id] IS NOT NULL THEN N'Tea' WHEN [l].[Id] IS NOT NULL THEN N'Lilt' WHEN [c].[Id] IS NOT NULL THEN N'Coke' diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceQuerySqlServerTest.cs index cba29dfd9fb..2616affaabc 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceQuerySqlServerTest.cs @@ -158,7 +158,7 @@ public override async Task Can_query_all_types_when_shared_column(bool async) AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE WHEN [t].[Id] IS NOT NULL THEN N'Tea' WHEN [l].[Id] IS NOT NULL THEN N'Lilt' WHEN [c].[Id] IS NOT NULL THEN N'Coke' @@ -202,7 +202,7 @@ public override async Task Can_query_when_shared_column(bool async) AssertSql( """ -SELECT TOP(2) [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] +SELECT TOP(2) [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id] """, @@ -823,6 +823,27 @@ WHERE [k].[Id] IS NULL """); } + public override async Task Primitive_collection_on_subtype(bool async) + { + await base.Primitive_collection_on_subtype(async); + + AssertSql( + """ +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE + WHEN [t].[Id] IS NOT NULL THEN N'Tea' + WHEN [l].[Id] IS NOT NULL THEN N'Lilt' + WHEN [c].[Id] IS NOT NULL THEN N'Coke' +END AS [Discriminator] +FROM [Drinks] AS [d] +LEFT JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id] +LEFT JOIN [Lilt] AS [l] ON [d].[Id] = [l].[Id] +LEFT JOIN [Tea] AS [t] ON [d].[Id] = [t].[Id] +WHERE EXISTS ( + SELECT 1 + FROM OPENJSON([c].[Ints]) AS [i]) +"""); + } + private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQuerySqlServerTest.cs index 1f6d9d29117..38eae00d356 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/Inheritance/TPTInheritanceTableSplittingQuerySqlServerTest.cs @@ -14,7 +14,7 @@ public override async Task Filter_on_complex_type_property_on_derived_type(bool AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id] WHERE [c].[ChildComplexType_Int] = 10 @@ -27,7 +27,7 @@ public override async Task Filter_on_complex_type_property_on_base_type(bool asy AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE WHEN [t].[Id] IS NOT NULL THEN N'Tea' WHEN [l].[Id] IS NOT NULL THEN N'Lilt' WHEN [c].[Id] IS NOT NULL THEN N'Coke' @@ -46,7 +46,7 @@ public override async Task Filter_on_nested_complex_type_property_on_derived_typ AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt] FROM [Drinks] AS [d] INNER JOIN [Coke] AS [c] ON [d].[Id] = [c].[Id] WHERE [c].[ChildComplexType_Nested_NestedInt] = 58 @@ -59,7 +59,7 @@ public override async Task Filter_on_nested_complex_type_property_on_base_type(b AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE WHEN [t].[Id] IS NOT NULL THEN N'Tea' WHEN [l].[Id] IS NOT NULL THEN N'Lilt' WHEN [c].[Id] IS NOT NULL THEN N'Coke' @@ -124,7 +124,7 @@ public override async Task Subquery_over_complex_collection(bool async) AssertSql( """ -SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE +SELECT [d].[Id], [d].[SortIndex], [c].[CaffeineGrams], [c].[CokeCO2], [c].[Ints], [c].[SugarGrams], [l].[LiltCO2], [l].[SugarGrams], [t].[CaffeineGrams], [t].[HasMilk], [d].[ComplexTypeCollection], [d].[ParentComplexType_Int], [d].[ParentComplexType_UniqueInt], [d].[ParentComplexType_Nested_NestedInt], [d].[ParentComplexType_Nested_UniqueInt], [c].[ChildComplexType_Int], [c].[ChildComplexType_UniqueInt], [c].[ChildComplexType_Nested_NestedInt], [c].[ChildComplexType_Nested_UniqueInt], [t].[ChildComplexType_Int], [t].[ChildComplexType_UniqueInt], [t].[ChildComplexType_Nested_NestedInt], [t].[ChildComplexType_Nested_UniqueInt], CASE WHEN [t].[Id] IS NOT NULL THEN N'Tea' WHEN [l].[Id] IS NOT NULL THEN N'Lilt' WHEN [c].[Id] IS NOT NULL THEN N'Coke' From 79c7e5eb69397ac4bbe309668bb7e8393cb5c690 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Sun, 11 Jan 2026 12:58:09 +0100 Subject: [PATCH 2/2] Update src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../NavigationExpandingExpressionVisitor.ExpressionVisitors.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs index da7c7744e98..6412fd4ec26 100644 --- a/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs +++ b/src/EFCore/Query/Internal/NavigationExpandingExpressionVisitor.ExpressionVisitors.cs @@ -128,7 +128,7 @@ protected override Expression VisitMethodCall(MethodCallExpression methodCallExp return null; } - // Attempt to bind complex and primitive collection properties; this are common to both entity and complex types + // Attempt to bind complex and primitive collection properties; these are common to both entity and complex types var complexProperty = memberIdentity.MemberInfo != null ? structuralType.FindComplexProperty(memberIdentity.MemberInfo) : memberIdentity.Name is not null