diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs index 07509cb166c..a4a96f1c8b7 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCRelationshipsQuerySqlServerTest.cs @@ -57,7 +57,6 @@ FROM [DerivedCollectionsOnBase] AS [d3] ORDER BY [t1].[Id], [t1].[BaseInheritanceRelationshipEntityId], [t1].[Id1], [t1].[Id00], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance(bool async) { await base.Include_collection_without_inheritance(async); @@ -86,13 +85,12 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance_reverse(bool async) { await base.Include_collection_without_inheritance_reverse(async); AssertSql( - @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name] + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] @@ -100,22 +98,21 @@ FROM [BaseEntities] AS [b] UNION ALL SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d0].[OwnedReferenceOnDerived_Name], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); +LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance_with_filter(bool async) { await base.Include_collection_without_inheritance_with_filter(async); @@ -145,13 +142,12 @@ WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance_with_filter_reverse(bool async) { await base.Include_collection_without_inheritance_with_filter_reverse(async); AssertSql( - @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name] + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] @@ -159,23 +155,22 @@ FROM [BaseEntities] AS [b] UNION ALL SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d0].[OwnedReferenceOnDerived_Name], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] +LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance(bool async) { await base.Include_collection_with_inheritance(async); @@ -210,13 +205,12 @@ FROM [DerivedCollectionsOnBase] AS [d3] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived1(bool async) { await base.Include_collection_with_inheritance_on_derived1(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] @@ -227,17 +221,16 @@ FROM [BaseCollectionsOnBase] AS [b] UNION ALL SELECT [d1].[Id], [d1].[BaseParentId], [d1].[Name], [d1].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] FROM [DerivedCollectionsOnBase] AS [d1] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived2(bool async) { await base.Include_collection_with_inheritance_on_derived2(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[Id], [t].[Name], [t].[ParentId], [t].[DerivedInheritanceRelationshipEntityId], [t].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[Id], [t0].[Name], [t0].[ParentId], [t0].[DerivedInheritanceRelationshipEntityId], [t0].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] @@ -248,11 +241,10 @@ FROM [BaseCollectionsOnDerived] AS [b] UNION ALL SELECT [d1].[Id], [d1].[Name], [d1].[ParentId], [d1].[DerivedInheritanceRelationshipEntityId], N'DerivedCollectionOnDerived' AS [Discriminator] FROM [DerivedCollectionsOnDerived] AS [d1] -) AS [t] ON [d].[Id] = [t].[ParentId] +) AS [t0] ON [d].[Id] = [t0].[ParentId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived3(bool async) { await base.Include_collection_with_inheritance_on_derived3(async); @@ -267,7 +259,6 @@ FROM [DerivedEntities] AS [d] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived_reverse(bool async) { await base.Include_collection_with_inheritance_on_derived_reverse(async); @@ -288,13 +279,12 @@ FROM [DerivedCollectionsOnDerived] AS [d] ORDER BY [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_reverse(bool async) { await base.Include_collection_with_inheritance_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] FROM ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b] @@ -315,15 +305,14 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t0].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_with_filter(bool async) { await base.Include_collection_with_inheritance_with_filter(async); @@ -359,13 +348,12 @@ WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_with_filter_reverse(bool async) { await base.Include_collection_with_inheritance_with_filter_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] FROM ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b] @@ -386,16 +374,15 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t0].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_without_inheritance(bool async) { await base.Include_reference_without_inheritance(async); @@ -424,7 +411,6 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] ORDER BY [t].[Id], [r].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_without_inheritance_on_derived1(bool async) { await base.Include_reference_without_inheritance_on_derived1(async); @@ -439,7 +425,6 @@ FROM [DerivedEntities] AS [d] ORDER BY [d].[Id], [r].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d0].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_without_inheritance_on_derived2(bool async) { await base.Include_reference_without_inheritance_on_derived2(async); @@ -454,7 +439,6 @@ FROM [DerivedEntities] AS [d] ORDER BY [d].[Id], [r].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d0].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_without_inheritance_on_derived_reverse(bool async) { await base.Include_reference_without_inheritance_on_derived_reverse(async); @@ -469,13 +453,12 @@ FROM [ReferencesOnDerived] AS [r] ORDER BY [r].[Id], [d].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d0].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_without_inheritance_reverse(bool async) { await base.Include_reference_without_inheritance_reverse(async); AssertSql( - @"SELECT [r].[Id], [r].[Name], [r].[ParentId], [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name] + @"SELECT [r].[Id], [r].[Name], [r].[ParentId], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] FROM [ReferencesOnBase] AS [r] LEFT JOIN ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] @@ -483,22 +466,21 @@ FROM [BaseEntities] AS [b] UNION ALL SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d] -) AS [t] ON [r].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [r].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d0].[OwnedReferenceOnDerived_Name], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -ORDER BY [r].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); +LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] +ORDER BY [r].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_without_inheritance_with_filter(bool async) { await base.Include_reference_without_inheritance_with_filter(async); @@ -528,13 +510,12 @@ WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [r].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_without_inheritance_with_filter_reverse(bool async) { await base.Include_reference_without_inheritance_with_filter_reverse(async); AssertSql( - @"SELECT [r].[Id], [r].[Name], [r].[ParentId], [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name] + @"SELECT [r].[Id], [r].[Name], [r].[ParentId], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] FROM [ReferencesOnBase] AS [r] LEFT JOIN ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] @@ -542,29 +523,28 @@ FROM [BaseEntities] AS [b] UNION ALL SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d] -) AS [t] ON [r].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [r].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d0].[OwnedReferenceOnDerived_Name], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] +LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] WHERE [r].[Name] <> N'Bar' OR [r].[Name] IS NULL -ORDER BY [r].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [r].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance(bool async) { await base.Include_reference_with_inheritance(async); - AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] + AssertSql( + @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] FROM ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] FROM [BaseEntities] AS [b] @@ -585,21 +565,20 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived1(bool async) { await base.Include_reference_with_inheritance_on_derived1(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[BaseParentId], [t].[Name], [t].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] @@ -607,20 +586,19 @@ FROM [BaseReferencesOnBase] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived2(bool async) { await base.Include_reference_with_inheritance_on_derived2(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[BaseParentId], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId], [t].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedInheritanceRelationshipEntityId], [t0].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedInheritanceRelationshipEntityId], N'BaseReferenceOnDerived' AS [Discriminator] @@ -628,14 +606,13 @@ FROM [BaseReferencesOnDerived] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], [d0].[DerivedInheritanceRelationshipEntityId], N'DerivedReferenceOnDerived' AS [Discriminator] FROM [DerivedReferencesOnDerived] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived4(bool async) { await base.Include_reference_with_inheritance_on_derived4(async); @@ -650,7 +627,6 @@ FROM [DerivedEntities] AS [d] ORDER BY [d].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived_reverse(bool async) { await base.Include_reference_with_inheritance_on_derived_reverse(async); @@ -671,13 +647,12 @@ FROM [DerivedReferencesOnDerived] AS [d] ORDER BY [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived_with_filter1(bool async) { await base.Include_reference_with_inheritance_on_derived_with_filter1(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[BaseParentId], [t].[Name], [t].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] @@ -685,21 +660,20 @@ FROM [BaseReferencesOnBase] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] WHERE [d].[Name] <> N'Bar' OR [d].[Name] IS NULL -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived_with_filter2(bool async) { await base.Include_reference_with_inheritance_on_derived_with_filter2(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[BaseParentId], [t].[Name], [t].[DerivedInheritanceRelationshipEntityId], [t].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedInheritanceRelationshipEntityId], [t0].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedInheritanceRelationshipEntityId], N'BaseReferenceOnDerived' AS [Discriminator] @@ -707,15 +681,14 @@ FROM [BaseReferencesOnDerived] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], [d0].[DerivedInheritanceRelationshipEntityId], N'DerivedReferenceOnDerived' AS [Discriminator] FROM [DerivedReferencesOnDerived] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] WHERE [d].[Name] <> N'Bar' OR [d].[Name] IS NULL -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived_with_filter4(bool async) { await base.Include_reference_with_inheritance_on_derived_with_filter4(async); @@ -731,7 +704,6 @@ WHERE [d].[Name] <> N'Bar' OR [d].[Name] IS NULL ORDER BY [d].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_on_derived_with_filter_reverse(bool async) { await base.Include_reference_with_inheritance_on_derived_with_filter_reverse(async); @@ -753,13 +725,12 @@ WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_reverse(bool async) { await base.Include_reference_with_inheritance_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] FROM ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] FROM [BaseReferencesOnBase] AS [b] @@ -780,21 +751,20 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t0].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_with_filter(bool async) { await base.Include_reference_with_inheritance_with_filter(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] + @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] FROM ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] FROM [BaseEntities] AS [b] @@ -815,22 +785,21 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_reference_with_inheritance_with_filter_reverse(bool async) { await base.Include_reference_with_inheritance_with_filter_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] FROM ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] FROM [BaseReferencesOnBase] AS [b] @@ -851,16 +820,15 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t0].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_self_reference_with_inheritance(bool async) { await base.Include_self_reference_with_inheritance(async); @@ -892,13 +860,12 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] ORDER BY [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o1].[BaseInheritanceRelationshipEntityId], [o1].[Id], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [o2].[BaseInheritanceRelationshipEntityId], [o2].[Id], [d4].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_self_reference_with_inheritance_reverse(bool async) { await base.Include_self_reference_with_inheritance_reverse(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o1].[BaseInheritanceRelationshipEntityId], [o1].[Id], [o1].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[Name], [t].[BaseId], [t].[Discriminator], [o2].[BaseInheritanceRelationshipEntityId], [o2].[Id], [o2].[Name], [o0].[Id], [o0].[Name], [d4].[DerivedInheritanceRelationshipEntityId], [d4].[Id], [d4].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o1].[BaseInheritanceRelationshipEntityId], [o1].[Id], [o1].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o2].[BaseInheritanceRelationshipEntityId], [o2].[Id], [o2].[Name], [o0].[Id], [o0].[Name], [d4].[DerivedInheritanceRelationshipEntityId], [d4].[Id], [d4].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] @@ -906,25 +873,24 @@ FROM [BaseEntities] AS [b] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t] ON [d].[BaseId] = [t].[Id] +) AS [t0] ON [d].[BaseId] = [t0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [OwnedReferences] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [OwnedReferences] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END LEFT JOIN [OwnedCollections] AS [o1] ON [d].[Id] = [o1].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [d].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -LEFT JOIN [OwnedCollections] AS [o2] ON [t].[Id] = [o2].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d4] ON [t].[Id] = [d4].[DerivedInheritanceRelationshipEntityId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o1].[BaseInheritanceRelationshipEntityId], [o1].[Id], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [o2].[BaseInheritanceRelationshipEntityId], [o2].[Id], [d4].[DerivedInheritanceRelationshipEntityId]"); +LEFT JOIN [OwnedCollections] AS [o2] ON [t0].[Id] = [o2].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d4] ON [t0].[Id] = [d4].[DerivedInheritanceRelationshipEntityId] +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o1].[BaseInheritanceRelationshipEntityId], [o1].[Id], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [o2].[BaseInheritanceRelationshipEntityId], [o2].[Id], [d4].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_collection_reference_on_non_entity_base(bool async) { await base.Nested_include_collection_reference_on_non_entity_base(async); @@ -940,13 +906,12 @@ FROM [PrincipalEntities] AS [p] ORDER BY [r].[Id], [t].[Id]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_collection(bool async) { await base.Nested_include_with_inheritance_collection_collection(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name], [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t1].[Id0], [t1].[Name0], [t1].[ParentCollectionId], [t1].[ParentReferenceId], [t1].[Discriminator0] + @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name], [t2].[Id], [t2].[BaseParentId], [t2].[Name], [t2].[DerivedProperty], [t2].[Discriminator], [t2].[Id0], [t2].[Name0], [t2].[ParentCollectionId], [t2].[ParentReferenceId], [t2].[Discriminator0] FROM ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] FROM [BaseEntities] AS [b] @@ -966,32 +931,31 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] LEFT JOIN ( - SELECT [t2].[Id], [t2].[BaseParentId], [t2].[Name], [t2].[DerivedProperty], [t2].[Discriminator], [t3].[Id] AS [Id0], [t3].[Name] AS [Name0], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator] AS [Discriminator0] + SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t3].[Id] AS [Id0], [t3].[Name] AS [Name0], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator] AS [Discriminator0] FROM ( SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b0] UNION ALL SELECT [d3].[Id], [d3].[BaseParentId], [d3].[Name], [d3].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] FROM [DerivedCollectionsOnBase] AS [d3] - ) AS [t2] + ) AS [t1] LEFT JOIN ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] FROM [NestedCollections] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] FROM [NestedCollectionsDerived] AS [n0] - ) AS [t3] ON [t2].[Id] = [t3].[ParentCollectionId] -) AS [t1] ON [t].[Id] = [t1].[BaseParentId] -ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [t1].[Id]"); + ) AS [t3] ON [t1].[Id] = [t3].[ParentCollectionId] +) AS [t2] ON [t].[Id] = [t2].[BaseParentId] +ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [t2].[Id]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_collection_reverse(bool async) { await base.Nested_include_with_inheritance_collection_collection_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[BaseId], [t1].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[BaseId], [t2].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name] FROM ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] FROM [NestedCollections] AS [n] @@ -1012,28 +976,27 @@ FROM [BaseEntities] AS [b0] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t1].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t1].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +LEFT JOIN [OwnedCollections] AS [o0] ON [t2].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t2].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_reference(bool async) { await base.Nested_include_with_inheritance_collection_reference(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name], [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t1].[Id0], [t1].[Name0], [t1].[ParentCollectionId], [t1].[ParentReferenceId], [t1].[Discriminator0] + @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name], [t2].[Id], [t2].[BaseParentId], [t2].[Name], [t2].[DerivedProperty], [t2].[Discriminator], [t2].[Id0], [t2].[Name0], [t2].[ParentCollectionId], [t2].[ParentReferenceId], [t2].[Discriminator0] FROM ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] FROM [BaseEntities] AS [b] @@ -1053,32 +1016,31 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] LEFT JOIN ( - SELECT [t2].[Id], [t2].[BaseParentId], [t2].[Name], [t2].[DerivedProperty], [t2].[Discriminator], [t3].[Id] AS [Id0], [t3].[Name] AS [Name0], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator] AS [Discriminator0] + SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t3].[Id] AS [Id0], [t3].[Name] AS [Name0], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator] AS [Discriminator0] FROM ( SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b0] UNION ALL SELECT [d3].[Id], [d3].[BaseParentId], [d3].[Name], [d3].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] FROM [DerivedCollectionsOnBase] AS [d3] - ) AS [t2] + ) AS [t1] LEFT JOIN ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] FROM [NestedReferences] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedReferenceDerived' AS [Discriminator] FROM [NestedReferencesDerived] AS [n0] - ) AS [t3] ON [t2].[Id] = [t3].[ParentCollectionId] -) AS [t1] ON [t].[Id] = [t1].[BaseParentId] -ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [t1].[Id]"); + ) AS [t3] ON [t1].[Id] = [t3].[ParentCollectionId] +) AS [t2] ON [t].[Id] = [t2].[BaseParentId] +ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [t2].[Id]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_reference_reverse(bool async) { await base.Nested_include_with_inheritance_collection_reference_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[BaseId], [t1].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[BaseId], [t2].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name] FROM ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] FROM [NestedReferences] AS [n] @@ -1099,28 +1061,27 @@ FROM [BaseEntities] AS [b0] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t1].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t1].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +LEFT JOIN [OwnedCollections] AS [o0] ON [t2].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t2].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_collection(bool async) { await base.Nested_include_with_inheritance_reference_collection(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[ParentCollectionId], [t2].[ParentReferenceId], [t2].[Discriminator] + @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t3].[Id], [t3].[Name], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator] FROM ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] FROM [BaseEntities] AS [b] @@ -1141,8 +1102,8 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] @@ -1152,17 +1113,16 @@ FROM [NestedCollections] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] FROM [NestedCollectionsDerived] AS [n0] -) AS [t2] ON [t0].[Id] = [t2].[ParentReferenceId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id]"); +) AS [t3] ON [t0].[Id] = [t3].[ParentReferenceId] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_collection_on_base(bool async) { await base.Nested_include_with_inheritance_reference_collection_on_base(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[BaseParentId], [t].[Name], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[ParentCollectionId], [t0].[ParentReferenceId], [t0].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[ParentCollectionId], [t1].[ParentReferenceId], [t1].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] @@ -1170,7 +1130,7 @@ FROM [BaseReferencesOnBase] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] @@ -1180,17 +1140,16 @@ FROM [NestedCollections] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] FROM [NestedCollectionsDerived] AS [n0] -) AS [t0] ON [t].[Id] = [t0].[ParentReferenceId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id]"); +) AS [t1] ON [t0].[Id] = [t1].[ParentReferenceId] +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_collection_reverse(bool async) { await base.Nested_include_with_inheritance_reference_collection_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[BaseId], [t1].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[BaseId], [t2].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name] FROM ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] FROM [NestedCollections] AS [n] @@ -1211,28 +1170,27 @@ FROM [BaseEntities] AS [b0] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t1].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t1].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +LEFT JOIN [OwnedCollections] AS [o0] ON [t2].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t2].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_reference(bool async) { await base.Nested_include_with_inheritance_reference_reference(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t1].[Name], [t1].[ParentCollectionId], [t1].[ParentReferenceId], [t1].[Discriminator] + @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t2].[Name], [t2].[ParentCollectionId], [t2].[ParentReferenceId], [t2].[Discriminator] FROM ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] FROM [BaseEntities] AS [b] @@ -1253,28 +1211,27 @@ FROM [NestedReferences] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedReferenceDerived' AS [Discriminator] FROM [NestedReferencesDerived] AS [n0] -) AS [t1] ON [t0].[Id] = [t1].[ParentReferenceId] +) AS [t2] ON [t0].[Id] = [t2].[ParentReferenceId] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END LEFT JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_reference_on_base(bool async) { await base.Nested_include_with_inheritance_reference_reference_on_base(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[BaseParentId], [t].[Name], [t].[Discriminator], [t0].[Name], [t0].[ParentCollectionId], [t0].[ParentReferenceId], [t0].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t1].[Name], [t1].[ParentCollectionId], [t1].[ParentReferenceId], [t1].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] @@ -1282,27 +1239,26 @@ FROM [BaseReferencesOnBase] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] FROM [NestedReferences] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedReferenceDerived' AS [Discriminator] FROM [NestedReferencesDerived] AS [n0] -) AS [t0] ON [t].[Id] = [t0].[ParentReferenceId] +) AS [t1] ON [t0].[Id] = [t1].[ParentReferenceId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -ORDER BY [d].[Id], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); +ORDER BY [d].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d1].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_reference_reverse(bool async) { await base.Nested_include_with_inheritance_reference_reference_reverse(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[BaseId], [t1].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[BaseId], [t2].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [o].[Id], [o].[Name], [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name] FROM ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] FROM [NestedReferences] AS [n] @@ -1323,22 +1279,21 @@ FROM [BaseEntities] AS [b0] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -LEFT JOIN [OwnedCollections] AS [o0] ON [t1].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t1].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); +LEFT JOIN [OwnedCollections] AS [o0] ON [t2].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +LEFT JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t2].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d3].[DerivedInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Collection_projection_on_base_type(bool async) { await base.Collection_projection_on_base_type(async); @@ -1346,10 +1301,10 @@ public override async Task Collection_projection_on_base_type(bool async) AssertSql( @"SELECT [t].[Id], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN ( @@ -1362,7 +1317,6 @@ FROM [DerivedCollectionsOnBase] AS [d0] ORDER BY [t].[Id]"); } - [ConditionalTheory] public override async Task Include_on_derived_type_with_queryable_Cast(bool async) { await base.Include_on_derived_type_with_queryable_Cast(async); @@ -1392,7 +1346,6 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_split(bool async) { await base.Include_collection_with_inheritance_split(async); @@ -1416,13 +1369,13 @@ WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1436,13 +1389,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1456,13 +1409,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1484,13 +1437,12 @@ FROM [DerivedCollectionsOnBase] AS [d2] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_reverse_split(bool async) { await base.Include_collection_with_inheritance_reverse_split(async); AssertSql( - @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o].[Id], [o].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o].[Id], [o].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] FROM ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b] @@ -1511,24 +1463,24 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] FROM ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1537,25 +1489,25 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END INNER JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", - // - @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", + // + @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] FROM ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1564,14 +1516,13 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t0].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_with_filter_split(bool async) { await base.Include_collection_with_inheritance_with_filter_split(async); @@ -1596,13 +1547,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id], [d].[Name] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1617,13 +1568,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id], [d].[Name] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1638,13 +1589,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id], [d].[Name] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1667,13 +1618,12 @@ WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_with_filter_reverse_split(bool async) { await base.Include_collection_with_inheritance_with_filter_reverse_split(async); AssertSql( - @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o].[Id], [o].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o].[Id], [o].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] FROM ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b] @@ -1694,25 +1644,25 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] FROM ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId], [b].[Name] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId], [d].[Name] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1721,26 +1671,26 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END INNER JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", - // - @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", + // + @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] FROM ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId], [b].[Name] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId], [d].[Name] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] ) AS [t0] ON [t].[BaseParentId] = [t0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1749,15 +1699,14 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t0].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t0].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t0].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]"); +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance_split(bool async) { await base.Include_collection_without_inheritance_split(async); @@ -1781,13 +1730,13 @@ WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1801,13 +1750,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1821,13 +1770,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1843,13 +1792,12 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance_reverse_split(bool async) { await base.Include_collection_without_inheritance_reverse_split(async); AssertSql( - @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o].[Id], [o].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name] + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o].[Id], [o].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] @@ -1857,62 +1805,61 @@ FROM [BaseEntities] AS [b] UNION ALL SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d0].[OwnedReferenceOnDerived_Name], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] +INNER JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]"); +INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance_with_filter_split(bool async) { await base.Include_collection_without_inheritance_with_filter_split(async); @@ -1937,13 +1884,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id], [d].[Name] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1958,13 +1905,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id], [d].[Name] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -1979,13 +1926,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id], [b].[Name] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id], [d].[Name] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2002,13 +1949,12 @@ WHERE [t].[Name] <> N'Bar' OR [t].[Name] IS NULL ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_without_inheritance_with_filter_reverse_split(bool async) { await base.Include_collection_without_inheritance_with_filter_reverse_split(async); AssertSql( - @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [o].[Id], [o].[Name], [t0].[OwnedReferenceOnDerived_Id], [t0].[OwnedReferenceOnDerived_Name] + @"SELECT [c].[Id], [c].[Name], [c].[ParentId], [t0].[Id], [t0].[Name], [t0].[BaseId], [t0].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o].[Id], [o].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] @@ -2016,65 +1962,64 @@ FROM [BaseEntities] AS [b] UNION ALL SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d0].[OwnedReferenceOnDerived_Name], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +INNER JOIN [OwnedCollections] AS [o0] ON [t0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] FROM [CollectionsOnBase] AS [c] LEFT JOIN ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] -) AS [t] ON [c].[ParentId] = [t].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t0] ON [c].[ParentId] = [t0].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t0].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d0].[Id], [d0].[OwnedReferenceOnDerived_Id], [d1].[Id] AS [Id0] FROM [DerivedEntities] AS [d0] INNER JOIN [DerivedEntities] AS [d1] ON [d0].[Id] = [d1].[Id] WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t0] ON [t].[Id] = CASE - WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] +) AS [t1] ON [t0].[Id] = CASE + WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] END -INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] +INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t0].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] WHERE [c].[Name] <> N'Bar' OR [c].[Name] IS NULL -ORDER BY [c].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]"); +ORDER BY [c].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived1_split(bool async) { await base.Include_collection_with_inheritance_on_derived1_split(async); @@ -2084,20 +2029,20 @@ public override async Task Include_collection_with_inheritance_on_derived1_split FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [d].[Id] = [d0].[DerivedInheritanceRelationshipEntityId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [t].[Id], [t].[BaseParentId], [t].[Name], [t].[DerivedProperty], [t].[Discriminator], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN ( @@ -2106,11 +2051,10 @@ FROM [BaseCollectionsOnBase] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], [d0].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] FROM [DerivedCollectionsOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived2_split(bool async) { await base.Include_collection_with_inheritance_on_derived2_split(async); @@ -2119,20 +2063,20 @@ public override async Task Include_collection_with_inheritance_on_derived2_split FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [d0].[DerivedInheritanceRelationshipEntityId], [d0].[Id], [d0].[Name], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d0] ON [d].[Id] = [d0].[DerivedInheritanceRelationshipEntityId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [t].[Id], [t].[Name], [t].[ParentId], [t].[DerivedInheritanceRelationshipEntityId], [t].[Discriminator], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [t0].[Id], [t0].[Name], [t0].[ParentId], [t0].[DerivedInheritanceRelationshipEntityId], [t0].[Discriminator], [d].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN ( @@ -2141,11 +2085,10 @@ FROM [BaseCollectionsOnDerived] AS [b] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[ParentId], [d0].[DerivedInheritanceRelationshipEntityId], N'DerivedCollectionOnDerived' AS [Discriminator] FROM [DerivedCollectionsOnDerived] AS [d0] -) AS [t] ON [d].[Id] = [t].[ParentId] +) AS [t0] ON [d].[Id] = [t0].[ParentId] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived3_split(bool async) { await base.Include_collection_with_inheritance_on_derived3_split(async); @@ -2175,7 +2118,6 @@ FROM [DerivedEntities] AS [d] ORDER BY [d].[Id], [o].[BaseInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Include_collection_with_inheritance_on_derived_reverse_split(bool async) { await base.Include_collection_with_inheritance_on_derived_reverse_split(async); @@ -2192,26 +2134,26 @@ FROM [DerivedCollectionsOnDerived] AS [d] LEFT JOIN [DerivedEntities] AS [d0] ON [t].[ParentId] = [d0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [d0].[Id] = [o].[BaseInheritanceRelationshipEntityId] ORDER BY [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM ( - SELECT [b].[Id], [b].[Name], [b].[ParentId], NULL AS [DerivedInheritanceRelationshipEntityId], N'BaseCollectionOnDerived' AS [Discriminator] + SELECT [b].[Id], [b].[ParentId] FROM [BaseCollectionsOnDerived] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[ParentId], [d].[DerivedInheritanceRelationshipEntityId], N'DerivedCollectionOnDerived' AS [Discriminator] + SELECT [d].[Id], [d].[ParentId] FROM [DerivedCollectionsOnDerived] AS [d] ) AS [t] LEFT JOIN [DerivedEntities] AS [d0] ON [t].[ParentId] = [d0].[Id] LEFT JOIN [OwnedReferences] AS [o] ON [d0].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN [OwnedCollections] AS [o0] ON [d0].[Id] = [o0].[BaseInheritanceRelationshipEntityId] ORDER BY [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId] + // + @"SELECT [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM ( - SELECT [b].[Id], [b].[Name], [b].[ParentId], NULL AS [DerivedInheritanceRelationshipEntityId], N'BaseCollectionOnDerived' AS [Discriminator] + SELECT [b].[Id], [b].[ParentId] FROM [BaseCollectionsOnDerived] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[ParentId], [d].[DerivedInheritanceRelationshipEntityId], N'DerivedCollectionOnDerived' AS [Discriminator] + SELECT [d].[Id], [d].[ParentId] FROM [DerivedCollectionsOnDerived] AS [d] ) AS [t] LEFT JOIN [DerivedEntities] AS [d0] ON [t].[ParentId] = [d0].[Id] @@ -2220,13 +2162,12 @@ FROM [DerivedCollectionsOnDerived] AS [d] ORDER BY [t].[Id], [d0].[Id], [o].[BaseInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_collection_split(bool async) { await base.Nested_include_with_inheritance_reference_collection_split(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0], [o].[Id], [o].[Name], [t1].[OwnedReferenceOnDerived_Id], [t1].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] + @"SELECT [t].[Id], [t].[Name], [t].[BaseId], [t].[Discriminator], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o].[Id], [o].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] FROM ( SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] FROM [BaseEntities] AS [b] @@ -2247,24 +2188,24 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN ( - SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b0].[Id], [b0].[BaseParentId] FROM [BaseReferencesOnBase] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d0].[Id], [d0].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d0] ) AS [t0] ON [t].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2273,25 +2214,25 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", - // - @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", + // + @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN ( - SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b0].[Id], [b0].[BaseParentId] FROM [BaseReferencesOnBase] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d0].[Id], [d0].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d0] ) AS [t0] ON [t].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2300,25 +2241,25 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]", - // - @"SELECT [t2].[Id], [t2].[Name], [t2].[ParentCollectionId], [t2].[ParentReferenceId], [t2].[Discriminator], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", + // + @"SELECT [t3].[Id], [t3].[Name], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator], [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN ( - SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b0].[Id], [b0].[BaseParentId] FROM [BaseReferencesOnBase] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d0].[Id], [d0].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d0] ) AS [t0] ON [t].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2327,8 +2268,8 @@ LEFT JOIN ( FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t1] ON [t].[Id] = CASE - WHEN [t1].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t1].[Id] +) AS [t2] ON [t].[Id] = CASE + WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] END INNER JOIN ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] @@ -2336,17 +2277,16 @@ FROM [NestedCollections] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] FROM [NestedCollectionsDerived] AS [n0] -) AS [t2] ON [t0].[Id] = [t2].[ParentReferenceId] -ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t1].[Id], [t1].[Id0]"); +) AS [t3] ON [t0].[Id] = [t3].[ParentReferenceId] +ORDER BY [t].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_collection_on_base_split(bool async) { await base.Nested_include_with_inheritance_reference_collection_on_base_split(async); AssertSql( - @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [o].[Id], [o].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t].[BaseParentId], [t].[Name], [t].[Discriminator] + @"SELECT [d].[Id], [d].[Name], [d].[BaseId], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId], [o].[Id], [o].[Name], [d].[OwnedReferenceOnDerived_Id], [d].[OwnedReferenceOnDerived_Name], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator] FROM [DerivedEntities] AS [d] LEFT JOIN ( SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] @@ -2354,45 +2294,45 @@ FROM [BaseReferencesOnBase] AS [b] UNION ALL SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId] +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseReferencesOnBase] AS [b] UNION ALL - SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d0].[Id], [d0].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN [OwnedCollections] AS [o0] ON [d].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId] +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId]", + // + @"SELECT [d1].[DerivedInheritanceRelationshipEntityId], [d1].[Id], [d1].[Name], [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseReferencesOnBase] AS [b] UNION ALL - SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d0].[Id], [d0].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d1] ON [d].[Id] = [d1].[DerivedInheritanceRelationshipEntityId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId]", - // - @"SELECT [t0].[Id], [t0].[Name], [t0].[ParentCollectionId], [t0].[ParentReferenceId], [t0].[Discriminator], [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId] +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId]", + // + @"SELECT [t1].[Id], [t1].[Name], [t1].[ParentCollectionId], [t1].[ParentReferenceId], [t1].[Discriminator], [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId] FROM [DerivedEntities] AS [d] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseReferencesOnBase] AS [b] UNION ALL - SELECT [d0].[Id], [d0].[BaseParentId], [d0].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d0].[Id], [d0].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d0] -) AS [t] ON [d].[Id] = [t].[BaseParentId] +) AS [t0] ON [d].[Id] = [t0].[BaseParentId] LEFT JOIN [OwnedReferences] AS [o] ON [d].[Id] = [o].[BaseInheritanceRelationshipEntityId] INNER JOIN ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] @@ -2400,17 +2340,16 @@ FROM [NestedCollections] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] FROM [NestedCollectionsDerived] AS [n0] -) AS [t0] ON [t].[Id] = [t0].[ParentReferenceId] -ORDER BY [d].[Id], [t].[Id], [o].[BaseInheritanceRelationshipEntityId]"); +) AS [t1] ON [t0].[Id] = [t1].[ParentReferenceId] +ORDER BY [d].[Id], [t0].[Id], [o].[BaseInheritanceRelationshipEntityId]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_reference_collection_reverse_split(bool async) { await base.Nested_include_with_inheritance_reference_collection_reverse_split(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[BaseId], [t1].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o].[Id], [o].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[BaseId], [t2].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o].[Id], [o].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name] FROM ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] FROM [NestedCollections] AS [n] @@ -2431,88 +2370,87 @@ FROM [BaseEntities] AS [b0] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0] FROM ( - SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] + SELECT [n].[Id], [n].[ParentReferenceId] FROM [NestedCollections] AS [n] UNION ALL - SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] + SELECT [n0].[Id], [n0].[ParentReferenceId] FROM [NestedCollectionsDerived] AS [n0] ) AS [t] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseReferencesOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d] ) AS [t0] ON [t].[ParentReferenceId] = [t0].[Id] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -INNER JOIN [OwnedCollections] AS [o0] ON [t1].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", - // - @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] +INNER JOIN [OwnedCollections] AS [o0] ON [t2].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]", + // + @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0] FROM ( - SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] + SELECT [n].[Id], [n].[ParentReferenceId] FROM [NestedCollections] AS [n] UNION ALL - SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] + SELECT [n0].[Id], [n0].[ParentReferenceId] FROM [NestedCollectionsDerived] AS [n0] ) AS [t] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], N'BaseReferenceOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseReferencesOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], N'DerivedReferenceOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedReferencesOnBase] AS [d] ) AS [t0] ON [t].[ParentReferenceId] = [t0].[Id] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t1].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]"); +INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t2].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_reference_split(bool async) { await base.Nested_include_with_inheritance_collection_reference_split(async); @@ -2536,13 +2474,13 @@ WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2556,13 +2494,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2576,13 +2514,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t1].[Id0], [t1].[Name0], [t1].[ParentCollectionId], [t1].[ParentReferenceId], [t1].[Discriminator0] AS [Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [t2].[Id], [t2].[BaseParentId], [t2].[Name], [t2].[DerivedProperty], [t2].[Discriminator], [t2].[Id0], [t2].[Name0], [t2].[ParentCollectionId], [t2].[ParentReferenceId], [t2].[Discriminator0] AS [Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2595,32 +2533,31 @@ WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN ( - SELECT [t2].[Id], [t2].[BaseParentId], [t2].[Name], [t2].[DerivedProperty], [t2].[Discriminator], [t3].[Id] AS [Id0], [t3].[Name] AS [Name0], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator] AS [Discriminator0] + SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t3].[Id] AS [Id0], [t3].[Name] AS [Name0], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator] AS [Discriminator0] FROM ( SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] FROM [BaseCollectionsOnBase] AS [b0] UNION ALL SELECT [d2].[Id], [d2].[BaseParentId], [d2].[Name], [d2].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] FROM [DerivedCollectionsOnBase] AS [d2] - ) AS [t2] + ) AS [t1] LEFT JOIN ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] FROM [NestedReferences] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedReferenceDerived' AS [Discriminator] FROM [NestedReferencesDerived] AS [n0] - ) AS [t3] ON [t2].[Id] = [t3].[ParentCollectionId] -) AS [t1] ON [t].[Id] = [t1].[BaseParentId] + ) AS [t3] ON [t1].[Id] = [t3].[ParentCollectionId] +) AS [t2] ON [t].[Id] = [t2].[BaseParentId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_reference_reverse_split(bool async) { await base.Nested_include_with_inheritance_collection_reference_reverse_split(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[BaseId], [t1].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o].[Id], [o].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[BaseId], [t2].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o].[Id], [o].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name] FROM ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] FROM [NestedReferences] AS [n] @@ -2641,88 +2578,87 @@ FROM [BaseEntities] AS [b0] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0] FROM ( - SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] + SELECT [n].[Id], [n].[ParentCollectionId] FROM [NestedReferences] AS [n] UNION ALL - SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedReferenceDerived' AS [Discriminator] + SELECT [n0].[Id], [n0].[ParentCollectionId] FROM [NestedReferencesDerived] AS [n0] ) AS [t] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t0] ON [t].[ParentCollectionId] = [t0].[Id] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -INNER JOIN [OwnedCollections] AS [o0] ON [t1].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", - // - @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] +INNER JOIN [OwnedCollections] AS [o0] ON [t2].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]", + // + @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0] FROM ( - SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedReferenceBase' AS [Discriminator] + SELECT [n].[Id], [n].[ParentCollectionId] FROM [NestedReferences] AS [n] UNION ALL - SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedReferenceDerived' AS [Discriminator] + SELECT [n0].[Id], [n0].[ParentCollectionId] FROM [NestedReferencesDerived] AS [n0] ) AS [t] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t0] ON [t].[ParentCollectionId] = [t0].[Id] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t1].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]"); +INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t2].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_collection_split(bool async) { await base.Nested_include_with_inheritance_collection_collection_split(async); @@ -2746,13 +2682,13 @@ WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2766,13 +2702,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2786,13 +2722,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [t1].[Id], [t1].[BaseParentId], [t1].[Name], [t1].[DerivedProperty], [t1].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2812,13 +2748,13 @@ UNION ALL FROM [DerivedCollectionsOnBase] AS [d2] ) AS [t1] ON [t].[Id] = [t1].[BaseParentId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [t1].[Id]", - // - @"SELECT [t2].[Id], [t2].[Name], [t2].[ParentCollectionId], [t2].[ParentReferenceId], [t2].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [t1].[Id] + // + @"SELECT [t3].[Id], [t3].[Name], [t3].[ParentCollectionId], [t3].[ParentReferenceId], [t3].[Discriminator], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [t1].[Id] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -2831,10 +2767,10 @@ WHERE [d0].[OwnedReferenceOnDerived_Id] IS NOT NULL WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END INNER JOIN ( - SELECT [b0].[Id], [b0].[BaseParentId], [b0].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b0].[Id], [b0].[BaseParentId] FROM [BaseCollectionsOnBase] AS [b0] UNION ALL - SELECT [d2].[Id], [d2].[BaseParentId], [d2].[Name], [d2].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d2].[Id], [d2].[BaseParentId] FROM [DerivedCollectionsOnBase] AS [d2] ) AS [t1] ON [t].[Id] = [t1].[BaseParentId] INNER JOIN ( @@ -2843,17 +2779,16 @@ FROM [NestedCollections] AS [n] UNION ALL SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] FROM [NestedCollectionsDerived] AS [n0] -) AS [t2] ON [t1].[Id] = [t2].[ParentCollectionId] +) AS [t3] ON [t1].[Id] = [t3].[ParentCollectionId] ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0], [t1].[Id]"); } - [ConditionalTheory] public override async Task Nested_include_with_inheritance_collection_collection_reverse_split(bool async) { await base.Nested_include_with_inheritance_collection_collection_reverse_split(async); AssertSql( - @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t1].[Id], [t1].[Name], [t1].[BaseId], [t1].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0], [o].[Id], [o].[Name], [t2].[OwnedReferenceOnDerived_Id], [t2].[OwnedReferenceOnDerived_Name] + @"SELECT [t].[Id], [t].[Name], [t].[ParentCollectionId], [t].[ParentReferenceId], [t].[Discriminator], [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t2].[Id], [t2].[Name], [t2].[BaseId], [t2].[Discriminator], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0], [o].[Id], [o].[Name], [t4].[OwnedReferenceOnDerived_Id], [t4].[OwnedReferenceOnDerived_Name] FROM ( SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] FROM [NestedCollections] AS [n] @@ -2874,88 +2809,87 @@ FROM [BaseEntities] AS [b0] UNION ALL SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d1].[OwnedReferenceOnDerived_Name], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]", + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0] FROM ( - SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] + SELECT [n].[Id], [n].[ParentCollectionId] FROM [NestedCollections] AS [n] UNION ALL - SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] + SELECT [n0].[Id], [n0].[ParentCollectionId] FROM [NestedCollectionsDerived] AS [n0] ) AS [t] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t0] ON [t].[ParentCollectionId] = [t0].[Id] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -INNER JOIN [OwnedCollections] AS [o0] ON [t1].[Id] = [o0].[BaseInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]", - // - @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0] +INNER JOIN [OwnedCollections] AS [o0] ON [t2].[Id] = [o0].[BaseInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]", + // + @"SELECT [d3].[DerivedInheritanceRelationshipEntityId], [d3].[Id], [d3].[Name], [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0] FROM ( - SELECT [n].[Id], [n].[Name], [n].[ParentCollectionId], [n].[ParentReferenceId], N'NestedCollectionBase' AS [Discriminator] + SELECT [n].[Id], [n].[ParentCollectionId] FROM [NestedCollections] AS [n] UNION ALL - SELECT [n0].[Id], [n0].[Name], [n0].[ParentCollectionId], [n0].[ParentReferenceId], N'NestedCollectionDerived' AS [Discriminator] + SELECT [n0].[Id], [n0].[ParentCollectionId] FROM [NestedCollectionsDerived] AS [n0] ) AS [t] LEFT JOIN ( - SELECT [b].[Id], [b].[BaseParentId], [b].[Name], NULL AS [DerivedProperty], N'BaseCollectionOnBase' AS [Discriminator] + SELECT [b].[Id], [b].[BaseParentId] FROM [BaseCollectionsOnBase] AS [b] UNION ALL - SELECT [d].[Id], [d].[BaseParentId], [d].[Name], [d].[DerivedProperty], N'DerivedCollectionOnBase' AS [Discriminator] + SELECT [d].[Id], [d].[BaseParentId] FROM [DerivedCollectionsOnBase] AS [d] ) AS [t0] ON [t].[ParentCollectionId] = [t0].[Id] LEFT JOIN ( - SELECT [b0].[Id], [b0].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b0].[Id] FROM [BaseEntities] AS [b0] UNION ALL - SELECT [d0].[Id], [d0].[Name], [d0].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d0].[Id] FROM [DerivedEntities] AS [d0] -) AS [t1] ON [t0].[BaseParentId] = [t1].[Id] -LEFT JOIN [OwnedReferences] AS [o] ON [t1].[Id] = [o].[BaseInheritanceRelationshipEntityId] +) AS [t2] ON [t0].[BaseParentId] = [t2].[Id] +LEFT JOIN [OwnedReferences] AS [o] ON [t2].[Id] = [o].[BaseInheritanceRelationshipEntityId] LEFT JOIN ( SELECT [d1].[Id], [d1].[OwnedReferenceOnDerived_Id], [d2].[Id] AS [Id0] FROM [DerivedEntities] AS [d1] INNER JOIN [DerivedEntities] AS [d2] ON [d1].[Id] = [d2].[Id] WHERE [d1].[OwnedReferenceOnDerived_Id] IS NOT NULL -) AS [t2] ON [t1].[Id] = CASE - WHEN [t2].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t2].[Id] +) AS [t4] ON [t2].[Id] = CASE + WHEN [t4].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t4].[Id] END -INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t1].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] -ORDER BY [t].[Id], [t0].[Id], [t1].[Id], [o].[BaseInheritanceRelationshipEntityId], [t2].[Id], [t2].[Id0]"); +INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d3] ON [t2].[Id] = [d3].[DerivedInheritanceRelationshipEntityId] +ORDER BY [t].[Id], [t0].[Id], [t2].[Id], [o].[BaseInheritanceRelationshipEntityId], [t4].[Id], [t4].[Id0]"); } - [ConditionalTheory] public override async Task Nested_include_collection_reference_on_non_entity_base_split(bool async) { await base.Nested_include_collection_reference_on_non_entity_base_split(async); @@ -2975,7 +2909,6 @@ FROM [PrincipalEntities] AS [p] ORDER BY [r].[Id]"); } - [ConditionalTheory] public override async Task Collection_projection_on_base_type_split(bool async) { await base.Collection_projection_on_base_type_split(async); @@ -2983,20 +2916,20 @@ public override async Task Collection_projection_on_base_type_split(bool async) AssertSql( @"SELECT [t].[Id] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] ORDER BY [t].[Id]", - // - @"SELECT [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t].[Id] + // + @"SELECT [t0].[Id], [t0].[BaseParentId], [t0].[Name], [t0].[DerivedProperty], [t0].[Discriminator], [t].[Id] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] INNER JOIN ( @@ -3009,7 +2942,6 @@ FROM [DerivedCollectionsOnBase] AS [d0] ORDER BY [t].[Id]"); } - [ConditionalTheory] public override async Task Include_on_derived_type_with_queryable_Cast_split(bool async) { await base.Include_on_derived_type_with_queryable_Cast_split(async); @@ -3034,13 +2966,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] END WHERE [t].[Id] >= 4 ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [o0].[BaseInheritanceRelationshipEntityId], [o0].[Id], [o0].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -3055,13 +2987,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] INNER JOIN [OwnedCollections] AS [o0] ON [t].[Id] = [o0].[BaseInheritanceRelationshipEntityId] WHERE [t].[Id] >= 4 ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[DerivedInheritanceRelationshipEntityId], [d2].[Id], [d2].[Name], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId] @@ -3076,13 +3008,13 @@ WHEN [t0].[OwnedReferenceOnDerived_Id] IS NOT NULL THEN [t0].[Id] INNER JOIN [DerivedEntities_OwnedCollectionOnDerived] AS [d2] ON [t].[Id] = [d2].[DerivedInheritanceRelationshipEntityId] WHERE [t].[Id] >= 4 ORDER BY [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0]", - // - @"SELECT [d2].[Id], [d2].[Name], [d2].[ParentId], [d2].[DerivedInheritanceRelationshipEntityId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] + // + @"SELECT [d2].[Id], [d2].[Name], [d2].[ParentId], [d2].[DerivedInheritanceRelationshipEntityId], [t].[Id], [o].[BaseInheritanceRelationshipEntityId], [t0].[Id], [t0].[Id0] FROM ( - SELECT [b].[Id], [b].[Name], NULL AS [BaseId], N'BaseInheritanceRelationshipEntity' AS [Discriminator] + SELECT [b].[Id] FROM [BaseEntities] AS [b] UNION ALL - SELECT [d].[Id], [d].[Name], [d].[BaseId], N'DerivedInheritanceRelationshipEntity' AS [Discriminator] + SELECT [d].[Id] FROM [DerivedEntities] AS [d] ) AS [t] LEFT JOIN [OwnedReferences] AS [o] ON [t].[Id] = [o].[BaseInheritanceRelationshipEntityId]