diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsCollectionsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsCollectionsQueryInMemoryTest.cs new file mode 100644 index 00000000000..f833238cef3 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsCollectionsQueryInMemoryTest.cs @@ -0,0 +1,16 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsQueryInMemoryTest : ComplexNavigationsCollectionsQueryTestBase + { + public ComplexNavigationsCollectionsQueryInMemoryTest(ComplexNavigationsQueryInMemoryFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + } +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest.cs new file mode 100644 index 00000000000..55838cf5347 --- /dev/null +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest : + ComplexNavigationsCollectionsSharedTypeQueryTestBase + { + // ReSharper disable once UnusedParameter.Local + public ComplexNavigationsCollectionsSharedTypeQueryInMemoryTest( + ComplexNavigationsSharedTypeQueryInMemoryFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + //TestLoggerFactory.TestOutputHelper = testOutputHelper; + } + } +} diff --git a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs index b3e81983136..bbc28576b6b 100644 --- a/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs +++ b/test/EFCore.InMemory.FunctionalTests/Query/ComplexNavigationsQueryInMemoryTest.cs @@ -1,8 +1,6 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System.Threading.Tasks; -using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsQueryRelationalTestBase.cs new file mode 100644 index 00000000000..bbafd88b9c3 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsQueryRelationalTestBase.cs @@ -0,0 +1,14 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class ComplexNavigationsCollectionsQueryRelationalTestBase : ComplexNavigationsCollectionsQueryTestBase + where TFixture : ComplexNavigationsQueryFixtureBase, new() + { + protected ComplexNavigationsCollectionsQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase.cs new file mode 100644 index 00000000000..0009e0994e9 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase.cs @@ -0,0 +1,14 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase : ComplexNavigationsCollectionsSharedTypeQueryTestBase + where TFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase, new() + { + protected ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSplitQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSplitQueryRelationalTestBase.cs new file mode 100644 index 00000000000..53e11d95335 --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSplitQueryRelationalTestBase.cs @@ -0,0 +1,130 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq.Expressions; +using System.Reflection; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class ComplexNavigationsCollectionsSplitQueryRelationalTestBase : ComplexNavigationsCollectionsQueryTestBase + where TFixture : ComplexNavigationsQueryFixtureBase, new() + { + protected ComplexNavigationsCollectionsSplitQueryRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) + => new SplitQueryRewritingExpressionVisitor().Visit(serverQueryExpression); + + private class SplitQueryRewritingExpressionVisitor : ExpressionVisitor + { + private readonly MethodInfo _asSplitQueryMethod + = typeof(RelationalQueryableExtensions).GetMethod(nameof(RelationalQueryableExtensions.AsSplitQuery)); + + protected override Expression VisitExtension(Expression extensionExpression) + { + if (extensionExpression is QueryRootExpression rootExpression) + { + var splitMethod = _asSplitQueryMethod.MakeGenericMethod(rootExpression.EntityType.ClrType); + + return Expression.Call(splitMethod, rootExpression); + } + + return base.VisitExtension(extensionExpression); + } + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) + { + return base.Complex_query_with_let_collection_projection_FirstOrDefault(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) + { + return base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Filtered_include_outer_parameter_used_inside_filter(bool async) + { + return base.Filtered_include_outer_parameter_used_inside_filter(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Include_inside_subquery(bool async) + { + return base.Include_inside_subquery(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Lift_projection_mapping_when_pushing_down_subquery(bool async) + { + return base.Lift_projection_mapping_when_pushing_down_subquery(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) + { + return base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Null_check_in_Dto_projection_should_not_be_removed(bool async) + { + return base.Null_check_in_Dto_projection_should_not_be_removed(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Project_collection_navigation_composed(bool async) + { + return base.Project_collection_navigation_composed(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Project_collection_navigation_nested_with_take(bool async) + { + return base.Project_collection_navigation_nested_with_take(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Select_nav_prop_collection_one_to_many_required(bool async) + { + return base.Select_nav_prop_collection_one_to_many_required(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Select_subquery_single_nested_subquery(bool async) + { + return base.Select_subquery_single_nested_subquery(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Select_subquery_single_nested_subquery2(bool async) + { + return base.Select_subquery_single_nested_subquery2(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) + { + return base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Skip_Take_Select_collection_Skip_Take(bool async) + { + return base.Skip_Take_Select_collection_Skip_Take(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Take_Select_collection_Take(bool async) + { + return base.Take_Select_collection_Take(async); + } + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase.cs new file mode 100644 index 00000000000..272d93f7dad --- /dev/null +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase.cs @@ -0,0 +1,136 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq.Expressions; +using System.Reflection; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase : ComplexNavigationsCollectionsSharedTypeQueryTestBase + where TFixture : ComplexNavigationsSharedTypeQueryRelationalFixtureBase, new() + { + protected ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase(TFixture fixture) + : base(fixture) + { + } + + protected override Expression RewriteServerQueryExpression(Expression serverQueryExpression) + => new SplitQueryRewritingExpressionVisitor().Visit(serverQueryExpression); + + private class SplitQueryRewritingExpressionVisitor : ExpressionVisitor + { + private readonly MethodInfo _asSplitQueryMethod + = typeof(RelationalQueryableExtensions).GetMethod(nameof(RelationalQueryableExtensions.AsSplitQuery)); + + protected override Expression VisitExtension(Expression extensionExpression) + { + if (extensionExpression is QueryRootExpression rootExpression) + { + var splitMethod = _asSplitQueryMethod.MakeGenericMethod(rootExpression.EntityType.ClrType); + + return Expression.Call(splitMethod, rootExpression); + } + + return base.VisitExtension(extensionExpression); + } + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) + { + return base.Complex_query_with_let_collection_projection_FirstOrDefault(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) + { + return base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Filtered_include_outer_parameter_used_inside_filter(bool async) + { + return base.Filtered_include_outer_parameter_used_inside_filter(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Include_inside_subquery(bool async) + { + return base.Include_inside_subquery(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Lift_projection_mapping_when_pushing_down_subquery(bool async) + { + return base.Lift_projection_mapping_when_pushing_down_subquery(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) + { + return base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Null_check_in_Dto_projection_should_not_be_removed(bool async) + { + return base.Null_check_in_Dto_projection_should_not_be_removed(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Project_collection_navigation_composed(bool async) + { + return base.Project_collection_navigation_composed(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Project_collection_navigation_nested_with_take(bool async) + { + return base.Project_collection_navigation_nested_with_take(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Select_nav_prop_collection_one_to_many_required(bool async) + { + return base.Select_nav_prop_collection_one_to_many_required(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Select_subquery_single_nested_subquery(bool async) + { + return base.Select_subquery_single_nested_subquery(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Select_subquery_single_nested_subquery2(bool async) + { + return base.Select_subquery_single_nested_subquery2(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) + { + return base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Skip_Take_Select_collection_Skip_Take(bool async) + { + return base.Skip_Take_Select_collection_Skip_Take(async); + } + + [ConditionalTheory(Skip = "Split query not fully supported yet.")] + public override Task Take_Select_collection_Take(bool async) + { + return base.Take_Select_collection_Take(async); + } + + [ConditionalTheory(Skip = "Split query bug")] + public override Task Include_reference_collection_order_by_reference_navigation(bool async) + { + return base.Include_reference_collection_order_by_reference_navigation(async); + } + } +} diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs index b2bee15ca63..31da9f7c326 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsQueryRelationalTestBase.cs @@ -19,495 +19,6 @@ protected ComplexNavigationsQueryRelationalTestBase(TFixture fixture) { } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_Where_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Where(l2 => l2.Id > 5)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(l2 => l2.Id > 5)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_OrderBy_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_ThenInclude_OrderBy_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.OrderBy(x => x.Name)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.OrderBy(x => x.Name)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_ThenInclude_OrderBy_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)) - .ThenInclude(l2 => l2.OneToMany_Optional2.OrderByDescending(x => x.Name)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name)), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.OrderByDescending(x => x.Name)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Take_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Skip_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Skip(1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Skip_Take_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Skip(1).Take(3)))); - } - - [ConditionalFact] - public virtual void Filtered_include_Skip_without_OrderBy_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Skip(1)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_Take_without_OrderBy_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Take(1)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_on_ThenInclude_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToOne_Optional_FK1", - x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_reference_navigation_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include( - l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToOne_Optional_FK1", - x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_different_filtered_include_same_level_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) - .Include(l1 => l1.OneToMany_Required1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), - new ExpectedFilteredInclude( - e => e.OneToMany_Required1, - includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_different_filtered_include_different_level_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) - .ThenInclude(l2 => l2.OneToMany_Required2.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), - new ExpectedFilteredInclude( - e => e.OneToMany_Required2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Take(3)) - .AsSplitQuery()))).Message; - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice_multi_level_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo")).ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar")).ThenInclude(l2 => l2.OneToOne_Required_FK2) - .AsSplitQuery()))).Message; - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToOne_Required_FK2) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), - new ExpectedInclude(e => e.OneToMany_Optional2), - new ExpectedInclude(e => e.OneToOne_Required_FK2))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task - Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Required_FK2) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional1"), - new ExpectedInclude(e => e.OneToOne_Required_FK2, "OneToMany_Optional1"))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation1_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation2_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .Include(l1 => l1.OneToMany_Optional1) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), - new ExpectedInclude(e => e.OneToOne_Optional_PK2, "OneToMany_Optional1"), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional3, - "OneToMany_Optional1.OneToOne_Optional_PK2", - includeFilter: x => x.Where(x => x.Id > 1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_complex_three_level_with_middle_having_filter1_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Required3) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), - new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_complex_three_level_with_middle_having_filter2_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .ThenInclude(l3 => l3.OneToMany_Required3) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), - new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); - } - - [ConditionalFact] - public virtual void Filtered_include_variable_used_inside_filter_split() - { - using var ctx = CreateContext(); - var prm = "Foo"; - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != prm).OrderBy(x => x.Id).Take(3)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_context_accessed_inside_filter_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count() > 7).OrderBy(x => x.Id).Take(3)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_context_accessed_inside_filter_correlated_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count(xx => xx.Id != x.Id) > 1).OrderBy(x => x.Id).Take(3)) - .AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_include_parameter_used_inside_filter_throws_split(bool async) - { - await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Select(l1 => ss.Set().Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l2.Id))).AsSplitQuery())); - } - - [ConditionalFact(Skip = "Issue#21234")] - public virtual void Filtered_include_outer_parameter_used_inside_filter_split() - { - // TODO: needs #18191 for result verification - using var ctx = CreateContext(); - var query = ctx.LevelOne.AsSplitQuery().Select( - l1 => new - { - l1.Id, - FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), - FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() - }); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_is_considered_loaded_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.AsTracking().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Id).Take(1)).AsSplitQuery(); - var result = query.ToList(); - foreach (var resultElement in result) - { - var entry = ctx.Entry(resultElement); - Assert.True(entry.Navigation("OneToMany_Optional1").IsLoaded); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_with_Distinct_throws_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Distinct()).AsSplitQuery()))).Message; - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_calling_methods_directly_on_parameter_throws_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.AsQueryable().Where(xx => xx.Id != 42)) - .AsSplitQuery()))).Message; - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Projecting_collection_with_FirstOrDefault_split_throws(bool async) diff --git a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedQueryTypeRelationalTestBase.cs b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedQueryTypeRelationalTestBase.cs index e5012931e94..5ff13d1bfb1 100644 --- a/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedQueryTypeRelationalTestBase.cs +++ b/test/EFCore.Relational.Specification.Tests/Query/ComplexNavigationsSharedQueryTypeRelationalTestBase.cs @@ -1,12 +1,8 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; -using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; using Microsoft.EntityFrameworkCore.TestUtilities; -using Xunit; namespace Microsoft.EntityFrameworkCore.Query { @@ -18,495 +14,6 @@ protected ComplexNavigationsSharedQueryTypeRelationalTestBase(TFixture fixture) { } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_Where_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Where(l2 => l2.Id > 5)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(l2 => l2.Id > 5)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_OrderBy_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_ThenInclude_OrderBy_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.OrderBy(x => x.Name)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.OrderBy(x => x.Name)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_ThenInclude_OrderBy_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)) - .ThenInclude(l2 => l2.OneToMany_Optional2.OrderByDescending(x => x.Name)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name)), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.OrderByDescending(x => x.Name)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Take_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Skip_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Skip(1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Skip_Take_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1).Take(3)).AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Skip(1).Take(3)))); - } - - [ConditionalFact] - public virtual void Filtered_include_Skip_without_OrderBy_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Skip(1)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_Take_without_OrderBy_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Take(1)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_on_ThenInclude_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToOne_Optional_FK1", - x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_reference_navigation_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include( - l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToOne_Optional_FK1", - x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_different_filtered_include_same_level_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) - .Include(l1 => l1.OneToMany_Required1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), - new ExpectedFilteredInclude( - e => e.OneToMany_Required1, - includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_different_filtered_include_different_level_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) - .ThenInclude(l2 => l2.OneToMany_Required2.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)), - new ExpectedFilteredInclude( - e => e.OneToMany_Required2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Take(3)) - .AsSplitQuery()))).Message; - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice_multi_level_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo")).ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar")).ThenInclude(l2 => l2.OneToOne_Required_FK2) - .AsSplitQuery()))).Message; - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToOne_Required_FK2) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), - new ExpectedInclude(e => e.OneToMany_Optional2), - new ExpectedInclude(e => e.OneToOne_Required_FK2))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task - Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Required_FK2) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)), - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional1"), - new ExpectedInclude(e => e.OneToOne_Required_FK2, "OneToMany_Optional1"))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation1_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation2_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .Include(l1 => l1.OneToMany_Optional1) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), - new ExpectedInclude(e => e.OneToOne_Optional_PK2, "OneToMany_Optional1"), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional3, - "OneToMany_Optional1.OneToOne_Optional_PK2", - includeFilter: x => x.Where(x => x.Id > 1)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_complex_three_level_with_middle_having_filter1_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Required3) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), - new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_complex_three_level_with_middle_having_filter2_split(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .ThenInclude(l3 => l3.OneToMany_Required3) - .AsSplitQuery(), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)), - new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); - } - - [ConditionalFact] - public virtual void Filtered_include_variable_used_inside_filter_split() - { - using var ctx = CreateContext(); - var prm = "Foo"; - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != prm).OrderBy(x => x.Id).Take(3)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_context_accessed_inside_filter_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count() > 7).OrderBy(x => x.Id).Take(3)).AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_context_accessed_inside_filter_correlated_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count(xx => xx.Id != x.Id) > 1).OrderBy(x => x.Id).Take(3)) - .AsSplitQuery(); - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_include_parameter_used_inside_filter_throws_split(bool async) - { - await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Select(l1 => ss.Set().Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l2.Id))).AsSplitQuery())); - } - - [ConditionalFact(Skip = "Issue#21234")] - public virtual void Filtered_include_outer_parameter_used_inside_filter_split() - { - // TODO: needs #18191 for result verification - using var ctx = CreateContext(); - var query = ctx.LevelOne.AsSplitQuery().Select( - l1 => new - { - l1.Id, - FullInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2).ToList(), - FilteredInclude = ctx.LevelTwo.Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() - }); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Filtered_include_is_considered_loaded_split() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.AsTracking().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Id).Take(1)).AsSplitQuery(); - var result = query.ToList(); - foreach (var resultElement in result) - { - var entry = ctx.Entry(resultElement); - Assert.True(entry.Navigation("OneToMany_Optional1").IsLoaded); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_with_Distinct_throws_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Distinct()).AsSplitQuery()))).Message; - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_calling_methods_directly_on_parameter_throws_split(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.AsQueryable().Where(xx => xx.Id != 42)) - .AsSplitQuery()))).Message; - } - public override Task Complex_query_with_optional_navigations_and_client_side_evaluation(bool async) { return AssertTranslationFailed(() => base.Complex_query_with_optional_navigations_and_client_side_evaluation(async)); diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsQueryTestBase.cs new file mode 100644 index 00000000000..173a8a1c980 --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsQueryTestBase.cs @@ -0,0 +1,1991 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Linq.Expressions; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.TestModels.ComplexNavigationsModel; +using Microsoft.EntityFrameworkCore.TestUtilities; +using Xunit; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsQueryTestBase : QueryTestBase + where TFixture : ComplexNavigationsQueryFixtureBase, new() + { + protected ComplexNavigationsContext CreateContext() + => Fixture.CreateContext(); + + public ComplexNavigationsCollectionsQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + protected override Expression RewriteExpectedQueryExpression(Expression expectedQueryExpression) + => new ExpectedQueryRewritingVisitor(Fixture.GetShadowPropertyMappings()).Visit(expectedQueryExpression); + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Select_nav_prop_collection_one_to_many_required(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(e => e.Id).Select(e => e.OneToMany_Required1.Select(i => i.Id)), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection(e, a)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task + Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) + { + return AssertQuery( + async, + ss => from l4 in ss.Set().SelectMany( + l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) + join l2 in ss.Set().SelectMany( + l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2 + .DefaultIfEmpty()) + on l4.Id equals l2.Id + join l3 in ss.Set().SelectMany( + l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) + on l2.Id equals l3.Id into grouping + from l3 in grouping.DefaultIfEmpty() + where l4.OneToMany_Optional_Inverse4.Name != "Foo" + orderby l2.OneToOne_Optional_FK2.Id + select new + { + Entity = l4, + Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), + Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name + }, + ss => from l4 in ss.Set().SelectMany( + l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) + join l2 in ss.Set().SelectMany( + l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2 + .DefaultIfEmpty()) + on l4.Id equals l2.Id + join l3 in ss.Set().SelectMany( + l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) + on l2.Id equals l3.Id into grouping + from l3 in grouping.DefaultIfEmpty() + where l4.OneToMany_Optional_Inverse4.Name != "Foo" + orderby l2.OneToOne_Optional_FK2.MaybeScalar(x => x.Id) + select new + { + Entity = l4, + Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), + Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name + }, + elementSorter: e => e.Entity.Id, + elementAsserter: (e, a) => + { + AssertEqual(e.Entity, a.Entity); + AssertCollection(e.Collection, a.Collection); + Assert.Equal(e.Property, a.Property); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_navigation(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + select l1.OneToMany_Optional1, + elementSorter: e => e != null ? e.Count : 0, + elementAsserter: (e, a) => AssertCollection(e, a)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_navigation_nested(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + select l1.OneToOne_Optional_FK1.OneToMany_Optional2, + ss => from l1 in ss.Set() + select l1.OneToOne_Optional_FK1.OneToMany_Optional2 ?? new List(), + elementSorter: e => e.Count, + elementAsserter: (e, a) => AssertCollection(e, a)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_navigation_nested_with_take(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + select l1.OneToOne_Optional_FK1.OneToMany_Optional2.Take(50), + ss => from l1 in ss.Set() + select (l1.OneToOne_Optional_FK1.OneToMany_Optional2 ?? new List()).Take(50), + elementSorter: e => e?.Count() ?? 0, + elementAsserter: (e, a) => AssertCollection(e, a)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_navigation_using_ef_property(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + select EF.Property>( + EF.Property( + l1, + "OneToOne_Optional_FK1"), + "OneToMany_Optional2"), + elementSorter: e => e?.Count ?? 0, + elementAsserter: (e, a) => AssertCollection(e ?? new List(), a)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_navigation_nested_anonymous(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + select new { l1.Id, l1.OneToOne_Optional_FK1.OneToMany_Optional2 }, + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + AssertCollection(e.OneToMany_Optional2 ?? new List(), a.OneToMany_Optional2); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_navigation_composed(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + where l1.Id < 3 + select new { l1.Id, collection = l1.OneToMany_Optional1.Where(l2 => l2.Name != "Foo").ToList() }, + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + AssertCollection(e.collection, a.collection); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_and_root_entity(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + select new { l1, l1.OneToMany_Optional1 }, + elementSorter: e => e.l1.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.l1.Id, a.l1.Id); + AssertCollection(e.OneToMany_Optional1, a.OneToMany_Optional1); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_collection_and_include(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set().Include(l => l.OneToMany_Optional1) + select new { l1, l1.OneToMany_Optional1 }, + elementSorter: e => e.l1.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.l1.Id, a.l1.Id); + AssertCollection(e.OneToMany_Optional1, a.OneToMany_Optional1); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Project_navigation_and_collection(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + select new { l1.OneToOne_Optional_FK1, l1.OneToOne_Optional_FK1.OneToMany_Optional2 }, + elementSorter: e => e.OneToOne_Optional_FK1?.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.OneToOne_Optional_FK1?.Id, a.OneToOne_Optional_FK1?.Id); + AssertCollection(e.OneToMany_Optional2 ?? new List(), a.OneToMany_Optional2); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_inside_subquery(bool async) + { + // can't use AssertQuery here, see #18191 + return AssertQuery( + async, + ss => ss.Set() + .Where(l1 => l1.Id < 3) + .OrderBy(l1 => l1.Id) + .Select(l1 => new { subquery = ss.Set().Include(l => l.OneToMany_Optional2).Where(l => l.Id > 0).ToList() }), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection(e.subquery, a.subquery)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(l1 => l1.Id).Select( + l1 => new + { + Level2s = l1.OneToMany_Optional1.Select( + l2 => new + { + Level3 = l2.OneToOne_Required_FK2 == null + ? null + : new { l2.OneToOne_Required_FK2.Name } + }).ToList() + }), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection( + e.Level2s, + a.Level2s, + elementSorter: ee => ee?.Level3.Name)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Null_check_in_Dto_projection_should_not_be_removed(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(l1 => l1.Id).Select( + l1 => new + { + Level2s = l1.OneToMany_Optional1.Select( + l2 => new + { + Level3 = l2.OneToOne_Required_FK2 == null + ? null + : new ProjectedDto { Value = l2.OneToOne_Required_FK2.Name } + }).ToList() + }), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection( + e.Level2s, + a.Level2s, + elementSorter: ee => ee.Level3?.Value, + elementAsserter: (ee, aa) => Assert.Equal(ee.Level3?.Value, aa.Level3?.Value))); + } + + private class ProjectedDto + { + public T Value { get; set; } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set().SelectMany(l1 => l1.OneToMany_Optional1).Select(l2 => new { l2.Id, l2.OneToMany_Optional2 }), + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + AssertCollection(e.OneToMany_Optional2, a.OneToMany_Optional2); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set().SelectMany(l1 => l1.OneToMany_Optional1).SelectMany(l2 => l2.OneToMany_Optional2) + .Select(l2 => new { l2.Id, l2.OneToMany_Optional3 }), + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + AssertCollection(e.OneToMany_Optional3, a.OneToMany_Optional3); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_navigation_property_with_include_and_followed_by_select_collection_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .SelectMany(l1 => l1.OneToMany_Optional1) + .Include(l2 => l2.OneToMany_Required2) + .Select(l2 => new { l2, l2.OneToMany_Optional2 }), + elementSorter: e => e.l2.Id, + elementAsserter: (e, a) => + { + AssertEqual(e.l2, a.l2); + AssertCollection(e.l2.OneToMany_Required2, a.l2.OneToMany_Required2); + AssertCollection(e.OneToMany_Optional2, a.OneToMany_Optional2); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Lift_projection_mapping_when_pushing_down_subquery(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Take(25) + .Select( + l1 => new + { + l1.Id, + c1 = l1.OneToMany_Required1.Select(l2 => new { l2.Id }).FirstOrDefault(), + c2 = l1.OneToMany_Required1.Select(l2 => new { l2.Id }) + }), + elementSorter: t => t.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + Assert.Equal(e.c1?.Id, a.c1?.Id); + AssertCollection(e.c2, a.c2, elementSorter: i => i.Id, elementAsserter: (ie, ia) => Assert.Equal(ie.Id, ia.Id)); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Select_subquery_single_nested_subquery(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(l1 => l1.Id).Select( + l1 => new + { + Level2 = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select( + l2 => new { Level3s = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select(l3 => new { l3.Id }).ToList() }) + .FirstOrDefault() + }), + assertOrder: true, + elementAsserter: (e, a) => + { + if (e.Level2 == null) + { + Assert.Null(a.Level2); + } + else + { + AssertCollection(e.Level2.Level3s, a.Level2.Level3s, ordered: true); + } + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Select_subquery_single_nested_subquery2(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(l1 => l1.Id).Select( + l1 => new + { + Level2s = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select( + l2 => new + { + Level3 = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select( + l3 => new + { + Level4s = l3.OneToMany_Optional3.OrderBy(l4 => l4.Id).Select(l4 => new { l4.Id }) + .ToList() + }).FirstOrDefault() + }) + }), + assertOrder: true, + elementAsserter: (e, a) => + { + AssertCollection( + e.Level2s, a.Level2s, ordered: true, elementAsserter: + (e2, a2) => + { + if (e2.Level3 == null) + { + Assert.Null(a2.Level3); + } + else + { + AssertCollection(e2.Level3.Level4s, a2.Level3.Level4s, ordered: true); + } + }); + }); + } + + [ConditionalTheory(Skip = "issue #23302")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Queryable_in_subquery_works_when_final_projection_is_List(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + orderby l1.Id + let inner = (from l2 in l1.OneToMany_Optional1 + where l2.Name != "Foo" + let innerL1s = from innerL1 in ss.Set() + where innerL1.OneToMany_Optional1.Any(innerL2 => innerL2.Id == l2.Id) + select innerL1.Name + select innerL1s).FirstOrDefault() + select inner.ToList(), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection(e, a)); + } + + [ConditionalTheory(Skip = "issue #23303")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + orderby l1.Id + let inner = (from l2 in l1.OneToMany_Optional1 + where l2.Name != "Foo" + let innerL1s = from innerL1 in ss.Set() + where innerL1.OneToMany_Optional1.Any(innerL2 => innerL2.Id == l2.Id) + select innerL1.Name + select innerL1s.ToList()).FirstOrDefault() + select inner.ToList(), + assertOrder: true, + elementAsserter: (e, a) => AssertCollection(e, a)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set() + orderby l1.Id + let inner = (from l2 in l1.OneToMany_Optional1 + where l2.Name != "Foo" + let innerL1s = from innerL1 in ss.Set() + where innerL1.OneToMany_Optional1.Any(innerL2 => innerL2.Id == l2.Id) + select innerL1.Name + select innerL1s.ToList()).FirstOrDefault() + select inner, + assertOrder: true, + elementAsserter: (e, a) => AssertCollection(e, a)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) + { + return AssertQuery( + async, + ss => from l4 in ss.Set().SelectMany(l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) + join l2 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2.DefaultIfEmpty()) on l4.Id equals l2.Id + join l3 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) on l2.Id equals l3.Id into grouping + from l3 in grouping.DefaultIfEmpty() + where l4.OneToMany_Optional_Inverse4.Name != "Foo" + orderby l2.OneToOne_Optional_FK2.Id + select new { Entity = l4, Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name }, + ss => from l4 in ss.Set().SelectMany(l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) + join l2 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2.DefaultIfEmpty()) on l4.Id equals l2.Id + join l3 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) on l2.Id equals l3.Id into grouping + from l3 in grouping.DefaultIfEmpty() + where l4.OneToMany_Optional_Inverse4.Name != "Foo" + orderby l2.OneToOne_Optional_FK2.MaybeScalar(e => e.Id) + select new { Entity = l4, Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name }, + assertOrder: true, + elementAsserter: (e, a) => + { + AssertEqual(e.Entity, a.Entity); + AssertCollection(e.Collection, a.Collection); + AssertEqual(e.Property, a.Property); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Take_Select_collection_Take(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(l1 => l1.Id).Take(1) + .Select(l1 => new + { + Id = l1.Id, + Name = l1.Name, + Level2s = l1.OneToMany_Required1.OrderBy(l2 => l2.Id).Take(3) + .Select(l2 => new + { + Id = l2.Id, + Name = l2.Name, + Level1Id = EF.Property(l2, "OneToMany_Required_Inverse2Id"), + Level2Id = l2.Level1_Required_Id, + Level2 = l2.OneToOne_Required_FK_Inverse2 + }) + }), + assertOrder: true, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + Assert.Equal(e.Name, a.Name); + AssertCollection(e.Level2s, a.Level2s, ordered: true, + elementAsserter: (ee, aa) => + { + Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.Name, aa.Name); + Assert.Equal(ee.Level1Id, aa.Level1Id); + Assert.Equal(ee.Level2Id, aa.Level2Id); + AssertEqual(ee.Level2, aa.Level2); + }); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Skip_Take_Select_collection_Skip_Take(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(l1 => l1.Id).Skip(1).Take(1) + .Select(l1 => new + { + Id = l1.Id, + Name = l1.Name, + Level2s = l1.OneToMany_Required1.OrderBy(l2 => l2.Id).Skip(1).Take(3) + .Select(l2 => new + { + Id = l2.Id, + Name = l2.Name, + Level1Id = EF.Property(l2, "OneToMany_Required_Inverse2Id"), + Level2Id = l2.Level1_Required_Id, + Level2 = l2.OneToOne_Required_FK_Inverse2 + }) + }), + assertOrder: true, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + Assert.Equal(e.Name, a.Name); + AssertCollection(e.Level2s, a.Level2s, ordered: true, + elementAsserter: (ee, aa) => + { + Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.Name, aa.Name); + Assert.Equal(ee.Level1Id, aa.Level1Id); + Assert.Equal(ee.Level2Id, aa.Level2Id); + AssertEqual(ee.Level2, aa.Level2); + }); + }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToMany_Optional1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional1") + }; + + return AssertQuery( + async, + ss => ss.Set().Include(e => e.OneToMany_Optional1).ThenInclude(e => e.OneToMany_Optional2), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times( + bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToMany_Optional1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional1"), + new ExpectedInclude(l3 => l3.OneToMany_Required_Inverse3, "OneToMany_Optional1.OneToMany_Optional2"), + new ExpectedInclude( + l2 => l2.OneToMany_Optional2, "OneToMany_Optional1.OneToMany_Optional2.OneToMany_Required_Inverse3") + }; + + return AssertQuery( + async, + ss => ss.Set().Include(e => e.OneToMany_Optional1).ThenInclude(e => e.OneToMany_Optional2) + .ThenInclude(e => e.OneToMany_Required_Inverse3.OneToMany_Optional2), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_complex_includes(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToMany_Optional1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToMany_Optional1") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Optional_FK1) + .ThenInclude(e => e.OneToMany_Optional2) + .Include(e => e.OneToMany_Optional1) + .ThenInclude(e => e.OneToOne_Optional_FK2), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_complex_includes_self_ref(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_Self1), + new ExpectedInclude(l2 => l2.OneToMany_Optional_Self1, "OneToOne_Optional_Self1"), + new ExpectedInclude(l1 => l1.OneToMany_Optional_Self1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_Self1, "OneToMany_Optional_Self1") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Optional_Self1) + .ThenInclude(e => e.OneToMany_Optional_Self1) + .Include(e => e.OneToMany_Optional_Self1) + .ThenInclude(e => e.OneToOne_Optional_Self1), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_reference_and_collection_order_by(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Optional_FK1.OneToMany_Optional2) + .OrderBy(e => e.Name), + assertOrder: true, + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_reference_ThenInclude_collection_order_by(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Optional_FK1) + .ThenInclude(e => e.OneToMany_Optional2) + .OrderBy(e => e.Name), + assertOrder: true, + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_then_reference(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToMany_Optional1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToMany_Optional1"), + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToMany_Optional1) + .ThenInclude(e => e.OneToOne_Optional_FK2), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_conditional_order_by(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToMany_Optional1) + .OrderBy(e => e.Name.EndsWith("03") ? 1 : 2) + .Select(e => e), + elementSorter: e => e.Id, + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(ee => ee.OneToMany_Optional1))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_complex_include_select(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToMany_Optional1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToMany_Optional1") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Optional_FK1) + .ThenInclude(e => e.OneToMany_Optional2) + .Include(e => e.OneToMany_Optional1) + .ThenInclude(e => e.OneToOne_Optional_FK2), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_nested_with_optional_navigation(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l1 => l1.OneToMany_Required2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Required_FK3, "OneToOne_Optional_FK1.OneToMany_Required2") + }; + + return AssertQuery( + async, + ss => from l1 in ss.Set() + .Include(e => e.OneToOne_Optional_FK1.OneToMany_Required2) + .ThenInclude(e => e.OneToOne_Required_FK3) + where l1.OneToOne_Optional_FK1.Name != "L2 09" + select l1, + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Complex_multi_include_with_order_by_and_paging(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Required_FK1), + new ExpectedInclude(l1 => l1.OneToMany_Optional2, "OneToOne_Required_FK1"), + new ExpectedInclude(l1 => l1.OneToMany_Required2, "OneToOne_Required_FK1") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Optional2) + .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Required2) + .OrderBy(t => t.Name) + .Skip(0).Take(10), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Required_FK1), + new ExpectedInclude(l2 => l2.OneToMany_Required2, "OneToOne_Required_FK1") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Optional_FK1).ThenInclude(e => e.OneToMany_Optional2) + .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Required2) + .OrderBy(t => t.Name) + .Skip(0).Take(10), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToOne_Required_FK2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToOne_Optional_FK1.OneToOne_Required_FK2") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Optional_FK1.OneToOne_Required_FK2).ThenInclude(e => e.OneToMany_Optional3) + .OrderBy(t => t.Name) + .Skip(0).Take(10), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_include_with_multiple_optional_navigations(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Required_FK1), + new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Required_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Required_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK1") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Optional2) + .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToOne_Optional_FK2) + .Include(e => e.OneToOne_Optional_FK1).ThenInclude(e => e.OneToOne_Optional_FK2) + .Where(e => e.OneToOne_Required_FK1.OneToOne_Optional_PK2.Name != "Foo") + .OrderBy(e => e.Id), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_with_Include1(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .SelectMany(l1 => l1.OneToMany_Optional1) + .Include(l2 => l2.OneToMany_Optional2), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Orderby_SelectMany_with_Include1(bool async) + { + return AssertQuery( + async, + ss => ss.Set().OrderBy(l1 => l1.Id) + .SelectMany(l1 => l1.OneToMany_Optional1) + .Include(l2 => l2.OneToMany_Optional2), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_with_Include2(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .SelectMany(l1 => l1.OneToMany_Optional1) + .Include(l2 => l2.OneToOne_Required_FK2), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToOne_Required_FK2))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_with_Include_ThenInclude(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l2 => l2.OneToOne_Required_FK2), + new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToOne_Required_FK2") + }; + + return AssertQuery( + async, + ss => ss.Set() + .SelectMany(l1 => l1.OneToMany_Optional1) + .Include(l2 => l2.OneToOne_Required_FK2) + .ThenInclude(l3 => l3.OneToMany_Optional3), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_SelectMany_with_Include(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l3 => l3.OneToOne_Required_FK3), new ExpectedInclude(l3 => l3.OneToMany_Optional3) + }; + + return AssertQuery( + async, + ss => ss.Set() + .SelectMany(l1 => l1.OneToMany_Optional1) + .SelectMany(l2 => l2.OneToMany_Optional2) + .Include(l3 => l3.OneToOne_Required_FK3) + .Include(l3 => l3.OneToMany_Optional3), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Required_navigation_with_Include(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Select(l3 => l3.OneToOne_Required_FK_Inverse3) + .Include(l2 => l2.OneToMany_Required_Inverse2), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Required_Inverse2))); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Required_navigation_with_Include_ThenInclude(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l3 => l3.OneToMany_Required_Inverse3), + new ExpectedInclude(l2 => l2.OneToMany_Optional_Inverse2, "OneToMany_Required_Inverse3") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Select(l4 => l4.OneToOne_Required_FK_Inverse4) + .Include(l3 => l3.OneToMany_Required_Inverse3) + .ThenInclude(l2 => l2.OneToMany_Optional_Inverse2), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Optional_navigation_with_Include_ThenInclude(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l2 => l2.OneToMany_Optional2), + new ExpectedInclude(l3 => l3.OneToOne_Optional_FK3, "OneToMany_Optional2") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Select(l1 => l1.OneToOne_Optional_FK1) + .Include(l2 => l2.OneToMany_Optional2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_optional_navigation_with_Include(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Select(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) + .Include(l3 => l3.OneToMany_Optional3), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Multiple_optional_navigation_with_string_based_Include(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Select(l1 => l1.OneToOne_Optional_FK1) + .Select(l2 => l2.OneToOne_Optional_PK2) + .Include("OneToMany_Optional3"), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Optional_navigation_with_order_by_and_Include(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Select(l1 => l1.OneToOne_Optional_FK1) + .OrderBy(l2 => l2.Name) + .Include(l2 => l2.OneToMany_Optional2), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Optional_navigation_with_Include_and_order(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Select(l1 => l1.OneToOne_Optional_FK1) + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => l2.Name), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_with_order_by_and_Include(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .SelectMany(l1 => l1.OneToMany_Optional1) + .OrderBy(l2 => l2.Name) + .Include(l2 => l2.OneToMany_Optional2), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_with_Include_and_order_by(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .SelectMany(l1 => l1.OneToMany_Optional1) + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => l2.Name), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_with_navigation_and_Distinct(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set().Include(l => l.OneToMany_Optional1) + from l2 in l1.OneToMany_Optional1.Distinct() + where l2 != null + select l1, + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l1 => l1.OneToMany_Optional1))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) + { + return AssertQuery( + async, + ss => from l1 in ss.Set().Include(l => l.OneToMany_Optional1) + from l2 in l1.OneToMany_Optional1.Select(x => new { x.Id, x.Name, FK = EF.Property(x, "OneToMany_Optional_Inverse2Id") }).Distinct() + select l1, + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l1 => l1.OneToMany_Optional1))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_multiple_orderbys_member(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => l2.Name) + .ThenBy(l2 => l2.Level1_Required_Id), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_multiple_orderbys_property(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => EF.Property(l2, "Level1_Required_Id")) + .ThenBy(l2 => l2.Name), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_multiple_orderbys_methodcall(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => Math.Abs(l2.Level1_Required_Id)) + .ThenBy(l2 => l2.Name), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_multiple_orderbys_complex(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => Math.Abs(l2.Level1_Required_Id) + 7) + .ThenBy(l2 => l2.Name), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_multiple_orderbys_complex_repeated(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => -l2.Level1_Required_Id) + .ThenBy(l2 => -l2.Level1_Required_Id).ThenBy(l2 => l2.Name), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), + assertOrder: true); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_multiple_orderbys_complex_repeated_checked(bool async) + { + checked + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l2 => l2.OneToMany_Optional2) + .OrderBy(l2 => -l2.Level1_Required_Id) + .ThenBy(l2 => -l2.Level1_Required_Id).ThenBy(l2 => l2.Name), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), + assertOrder: true); + } + } + + [ConditionalTheory(Skip = "Issue#12088")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_groupby_in_subquery(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .GroupBy(g => g.Name) + .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional1))); + } + + [ConditionalTheory(Skip = "Issue#12088")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_groupby_in_subquery_and_filter_before_groupby(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .Where(l1 => l1.Id > 3) + .GroupBy(g => g.Name) + .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional1))); + } + + [ConditionalTheory(Skip = "Issue#12088")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_collection_with_groupby_in_subquery_and_filter_after_groupby(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .GroupBy(g => g.Name) + .Where(g => g.Key != "Foo") + .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional1))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_reference_collection_order_by_reference_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2) + .OrderBy(l1 => (int?)l1.OneToOne_Optional_FK1.Id), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(e => e.OneToOne_Optional_FK1), + new ExpectedInclude(e => e.OneToMany_Optional2, "OneToOne_Optional_FK1")), + assertOrder: true); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_after_SelectMany_and_reference_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) + .Include(l3 => l3.OneToMany_Optional3), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_after_multiple_SelectMany_and_reference_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set().SelectMany(l1 => l1.OneToMany_Required1).SelectMany(l2 => l2.OneToMany_Optional2) + .Select(l3 => l3.OneToOne_Required_FK3).Include(l4 => l4.OneToMany_Required_Self4), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l4 => l4.OneToMany_Required_Self4))); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_after_SelectMany_and_multiple_reference_navigations(bool async) + { + return AssertQuery( + async, + ss => ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) + .Select(l3 => l3.OneToOne_Required_FK3).Include(l4 => l4.OneToMany_Optional_Self4), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l4 => l4.OneToMany_Optional_Self4))); + } + + [ConditionalTheory(Skip = "Issue#16752")] + [MemberData(nameof(IsAsyncData))] + public virtual Task Include_after_SelectMany_and_reference_navigation_with_another_SelectMany_with_Distinct(bool async) + { + return AssertQuery( + async, + ss => from lOuter in ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) + .Include(l3 => l3.OneToMany_Optional3) + from lInner in lOuter.OneToMany_Optional3.Distinct() + where lInner != null + select lOuter, + ss => from lOuter in ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) + where lOuter != null + from lInner in lOuter.OneToMany_Optional3.Distinct() + where lInner != null + select lOuter, + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); + } + + [ConditionalFact(Skip = "Issue#16752")] + public virtual void Include15() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) + .Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); + + var result = query.ToList(); + } + + [ConditionalFact(Skip = "Issue#16752")] + public virtual void Include16() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Distinct() + .Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); + + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection1() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection2() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection3() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToOne_Optional_FK1).ThenInclude(l2 => l2.OneToMany_Optional2); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection4() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).Select(l1 => l1.OneToMany_Optional1); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection5() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .Select(l1 => l1.OneToMany_Optional1); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection6() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) + .Select(l1 => l1.OneToMany_Optional1); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection6_1() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection6_2() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) + .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) + .ThenInclude(l3 => l3.OneToMany_Optional3) + .Select(l1 => l1.OneToMany_Optional1); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection6_3() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) + .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) + .ThenInclude(l3 => l3.OneToMany_Optional3); + + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection6_4() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) + .Select(l1 => l1.OneToMany_Optional1.Select(l2 => l2.OneToOne_Optional_PK2)); + + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void IncludeCollection7() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .Select(l1 => new { l1, l1.OneToMany_Optional1 }); + var result = query.ToList(); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task IncludeCollection8(bool async) + { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.OneToMany_Optional1), + new ExpectedInclude(e => e.OneToOne_Optional_PK2, "OneToMany_Optional1"), + new ExpectedInclude(e => e.OneToOne_Optional_FK3, "OneToMany_Optional1.OneToOne_Optional_PK2") + }; + + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToOne_Optional_PK2) + .ThenInclude(l3 => l3.OneToOne_Optional_FK3) + .Where(l1 => l1.OneToMany_Optional1.Where(l2 => l2.OneToOne_Optional_PK2.Name != "Foo").Count() > 0), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Including_reference_navigation_and_projecting_collection_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(e => e.OneToOne_Required_FK1) + .ThenInclude(e => e.OneToOne_Optional_FK2) + .Select( + e => new Level1 + { + Id = e.Id, + OneToOne_Required_FK1 = e.OneToOne_Required_FK1, + OneToMany_Required1 = e.OneToMany_Required1 + })); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task LeftJoin_with_Any_on_outer_source_and_projecting_collection_from_inner(bool async) + { + var validIds = new List { "L1 01", "L1 02" }; + + return AssertQuery( + async, + ss => from l1 in ss.Set().Where(l1 => validIds.Any(e => e == l1.Name)) + join l2 in ss.Set() + on l1.Id equals l2.Level1_Required_Id into l2s + from l2 in l2s.DefaultIfEmpty() + select new Level2 { Id = l2 == null ? 0 : l2.Id, OneToMany_Required2 = l2 == null ? null : l2.OneToMany_Required2 }); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_basic_Where(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Where(l2 => l2.Id > 5)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(l2 => l2.Id > 5)))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_OrderBy(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.OrderBy(x => x.Name), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_ThenInclude_OrderBy(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2.OrderBy(x => x.Name)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(e => e.OneToMany_Optional1), + new ExpectedFilteredInclude( + e => e.OneToMany_Optional2, + "OneToMany_Optional1", + includeFilter: x => x.OrderBy(x => x.Name), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_ThenInclude_OrderBy(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)) + .ThenInclude(l2 => l2.OneToMany_Optional2.OrderByDescending(x => x.Name)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.OrderBy(x => x.Name), + assertOrder: true), + new ExpectedFilteredInclude( + e => e.OneToMany_Optional2, + "OneToMany_Optional1", + includeFilter: x => x.OrderByDescending(x => x.Name), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_basic_OrderBy_Take(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Take(3)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.OrderBy(x => x.Name).Take(3), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_basic_OrderBy_Skip(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.OrderBy(x => x.Name).Skip(1), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_basic_OrderBy_Skip_Take(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1).Take(3)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.OrderBy(x => x.Name).Skip(1).Take(3), + assertOrder: true))); + } + + [ConditionalFact] + public virtual void Filtered_include_Skip_without_OrderBy() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Skip(1)); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void Filtered_include_Take_without_OrderBy() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Take(1)); + var result = query.ToList(); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_on_ThenInclude(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(e => e.OneToOne_Optional_FK1), + new ExpectedFilteredInclude( + e => e.OneToMany_Optional2, + "OneToOne_Optional_FK1", + x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_after_reference_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include( + l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1) + .Take(3)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(e => e.OneToOne_Optional_FK1), + new ExpectedFilteredInclude( + e => e.OneToMany_Optional2, + "OneToOne_Optional_FK1", + x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_after_different_filtered_include_same_level(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) + .Include(l1 => l1.OneToMany_Required1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3), + assertOrder: true), + new ExpectedFilteredInclude( + e => e.OneToMany_Required1, + includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_after_different_filtered_include_different_level(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) + .ThenInclude(l2 => l2.OneToMany_Required2.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3), + assertOrder: true), + new ExpectedFilteredInclude( + e => e.OneToMany_Required2, + "OneToMany_Optional1", + includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice(bool async) + { + var message = (await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Take(3))))) + .Message; + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice_multi_level(bool async) + { + var message = (await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo")).ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar")) + .ThenInclude(l2 => l2.OneToOne_Required_FK2)))) + .Message; + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToOne_Required_FK2), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2), + assertOrder: true), + new ExpectedInclude(e => e.OneToMany_Optional2), + new ExpectedInclude(e => e.OneToOne_Required_FK2))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( + bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) + .ThenInclude(l2 => l2.OneToMany_Optional2) + .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Required_FK2), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2), + assertOrder: true), + new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional1"), + new ExpectedInclude(e => e.OneToOne_Required_FK2, "OneToMany_Optional1"))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation2(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) + .Include(l1 => l1.OneToMany_Optional1), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3), + assertOrder: true))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedFilteredInclude( + e => e.OneToMany_Optional1, + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1), + assertOrder: true), + new ExpectedInclude(e => e.OneToOne_Optional_PK2, "OneToMany_Optional1"), + new ExpectedFilteredInclude( + e => e.OneToMany_Optional3, + "OneToMany_Optional1.OneToOne_Optional_PK2", + includeFilter: x => x.Where(x => x.Id > 1)))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Required3), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(e => e.OneToMany_Optional1), + new ExpectedFilteredInclude( + e => e.OneToMany_Optional2, + "OneToMany_Optional1", + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1), + assertOrder: true), + new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), + new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + { + return AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) + .ThenInclude(l3 => l3.OneToMany_Optional3) + .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2) + .ThenInclude(l3 => l3.OneToMany_Required3), + elementAsserter: (e, a) => AssertInclude( + e, a, + new ExpectedInclude(e => e.OneToMany_Optional1), + new ExpectedFilteredInclude( + e => e.OneToMany_Optional2, + "OneToMany_Optional1", + includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1), + assertOrder: true), + new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), + new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); + } + + [ConditionalFact] + public virtual void Filtered_include_variable_used_inside_filter() + { + using var ctx = CreateContext(); + var prm = "Foo"; + var query = ctx.LevelOne + .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != prm).OrderBy(x => x.Id).Take(3)); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void Filtered_include_context_accessed_inside_filter() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne + .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count() > 7).OrderBy(x => x.Id).Take(3)); + var result = query.ToList(); + } + + [ConditionalFact] + public virtual void Filtered_include_context_accessed_inside_filter_correlated() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne + .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count(xx => xx.Id != x.Id) > 1).OrderBy(x => x.Id).Take(3)); + var result = query.ToList(); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Filtered_include_include_parameter_used_inside_filter_throws(bool async) + { + await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => ss.Set() + .Select(l1 => ss.Set().Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l2.Id))))); + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual Task Filtered_include_outer_parameter_used_inside_filter(bool async) + { + return AssertQuery( + async, + ss => ss.Set().Select( + l1 => new + { + l1.Id, + FullInclude = ss.Set().Include(l2 => l2.OneToMany_Optional2).ToList(), + FilteredInclude = ss.Set().Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() + }), + elementSorter: e => e.Id, + elementAsserter: (e, a) => + { + Assert.Equal(e.Id, a.Id); + AssertInclude(e.FullInclude, a.FullInclude, new ExpectedInclude(x => x.OneToMany_Optional2)); + AssertInclude( + e.FilteredInclude, + a.FilteredInclude, + new ExpectedFilteredInclude( + x => x.OneToMany_Optional2, + includeFilter: x => x.Where(x => x.Id != e.Id))); + }); + } + + [ConditionalFact] + public virtual void Filtered_include_is_considered_loaded() + { + using var ctx = CreateContext(); + var query = ctx.LevelOne.AsTracking().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Id).Take(1)); + var result = query.ToList(); + foreach (var resultElement in result) + { + var entry = ctx.Entry(resultElement); + Assert.True(entry.Navigation("OneToMany_Optional1").IsLoaded); + } + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Filtered_include_with_Distinct_throws(bool async) + { + var message = (await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Distinct())))).Message; + } + + [ConditionalTheory] + [MemberData(nameof(IsAsyncData))] + public virtual async Task Filtered_include_calling_methods_directly_on_parameter_throws(bool async) + { + var message = (await Assert.ThrowsAsync( + () => AssertQuery( + async, + ss => ss.Set() + .Include(l1 => l1.OneToMany_Optional1) + .ThenInclude(l2 => l2.AsQueryable().Where(xx => xx.Id != 42))))).Message; + } + } +} diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsSharedTypeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsSharedTypeQueryTestBase.cs new file mode 100644 index 00000000000..2c646969944 --- /dev/null +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsCollectionsSharedTypeQueryTestBase.cs @@ -0,0 +1,82 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public abstract class ComplexNavigationsCollectionsSharedTypeQueryTestBase : ComplexNavigationsCollectionsQueryTestBase + where TFixture : ComplexNavigationsSharedTypeQueryFixtureBase, new() + { + protected ComplexNavigationsCollectionsSharedTypeQueryTestBase(TFixture fixture) + : base(fixture) + { + } + + public override Task Multiple_complex_includes_self_ref(bool async) + { + return Task.CompletedTask; + } + + [ConditionalTheory(Skip = "issue #13560")] + public override Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) + { + return base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Include_collection_with_multiple_orderbys_complex(bool async) + { + return base.Include_collection_with_multiple_orderbys_complex(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Include_collection_with_multiple_orderbys_complex_repeated(bool async) + { + return base.Include_collection_with_multiple_orderbys_complex_repeated(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Include_collection_with_multiple_orderbys_complex_repeated_checked(bool async) + { + return base.Include_collection_with_multiple_orderbys_complex_repeated_checked(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Include_collection_with_multiple_orderbys_member(bool async) + { + return base.Include_collection_with_multiple_orderbys_member(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Include_collection_with_multiple_orderbys_methodcall(bool async) + { + return base.Include_collection_with_multiple_orderbys_methodcall(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Include_collection_with_multiple_orderbys_property(bool async) + { + return base.Include_collection_with_multiple_orderbys_property(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Include_inside_subquery(bool async) + { + return base.Include_inside_subquery(async); + } + + [ConditionalTheory(Skip = "Issue#16752")] + public override Task Filtered_include_outer_parameter_used_inside_filter(bool async) + { + return base.Filtered_include_outer_parameter_used_inside_filter(async); + } + + public override Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) + { + // Navigations used are not mapped in shared type. + return Task.CompletedTask; + } + } +} diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs index 1537dfb2394..27339c17c4a 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsQueryTestBase.cs @@ -164,43 +164,6 @@ public virtual Task Key_equality_two_conditions_on_same_navigation2(bool async) || l.OneToOne_Required_FK_Inverse2.Id == 2)); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToMany_Optional1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional1") - }; - - return AssertQuery( - async, - ss => ss.Set().Include(e => e.OneToMany_Optional1).ThenInclude(e => e.OneToMany_Optional2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times( - bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToMany_Optional1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToMany_Optional1"), - new ExpectedInclude(l3 => l3.OneToMany_Required_Inverse3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude( - l2 => l2.OneToMany_Optional2, "OneToMany_Optional1.OneToMany_Optional2.OneToMany_Required_Inverse3") - }; - - return AssertQuery( - async, - ss => ss.Set().Include(e => e.OneToMany_Optional1).ThenInclude(e => e.OneToMany_Optional2) - .ThenInclude(e => e.OneToMany_Required_Inverse3.OneToMany_Optional2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - [ConditionalFact] public virtual void Multi_level_include_with_short_circuiting() { @@ -656,107 +619,6 @@ join e4 in ss.Set() on e1.Name equals e4.OneToOne_Required_FK_Inverse4.O e => (e.Id4, e.Name4, e.Id1, e.Name1)); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_complex_includes(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToMany_Optional1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToMany_Optional1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Optional_FK1) - .ThenInclude(e => e.OneToMany_Optional2) - .Include(e => e.OneToMany_Optional1) - .ThenInclude(e => e.OneToOne_Optional_FK2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_complex_includes_self_ref(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_Self1), - new ExpectedInclude(l2 => l2.OneToMany_Optional_Self1, "OneToOne_Optional_Self1"), - new ExpectedInclude(l1 => l1.OneToMany_Optional_Self1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_Self1, "OneToMany_Optional_Self1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Optional_Self1) - .ThenInclude(e => e.OneToMany_Optional_Self1) - .Include(e => e.OneToMany_Optional_Self1) - .ThenInclude(e => e.OneToOne_Optional_Self1), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_reference_and_collection_order_by(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Optional_FK1.OneToMany_Optional2) - .OrderBy(e => e.Name), - assertOrder: true, - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_reference_ThenInclude_collection_order_by(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Optional_FK1) - .ThenInclude(e => e.OneToMany_Optional2) - .OrderBy(e => e.Name), - assertOrder: true, - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_then_reference(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToMany_Optional1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToMany_Optional1"), - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToMany_Optional1) - .ThenInclude(e => e.OneToOne_Optional_FK2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Include_reference_and_project_into_anonymous_type(bool async) @@ -772,53 +634,6 @@ public virtual Task Include_reference_and_project_into_anonymous_type(bool async }); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_conditional_order_by(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToMany_Optional1) - .OrderBy(e => e.Name.EndsWith("03") ? 1 : 2) - .Select(e => e), - elementSorter: e => e.Id, - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(ee => ee.OneToMany_Optional1))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_complex_include_select(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToMany_Optional1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToMany_Optional1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Optional_FK1) - .ThenInclude(e => e.OneToMany_Optional2) - .Include(e => e.OneToMany_Optional1) - .ThenInclude(e => e.OneToOne_Optional_FK2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_nav_prop_collection_one_to_many_required(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(e => e.Id).Select(e => e.OneToMany_Required1.Select(i => i.Id)), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e, a)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Select_nav_prop_reference_optional1(bool async) @@ -1349,27 +1164,6 @@ public virtual Task Include_with_optional_navigation(bool async) elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1))); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_nested_with_optional_navigation(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l1 => l1.OneToMany_Required2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Required_FK3, "OneToOne_Optional_FK1.OneToMany_Required2") - }; - - return AssertQuery( - async, - ss => from l1 in ss.Set() - .Include(e => e.OneToOne_Optional_FK1.OneToMany_Required2) - .ThenInclude(e => e.OneToOne_Required_FK3) - where l1.OneToOne_Optional_FK1.Name != "L2 09" - select l1, - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Join_flattening_bug_4539(bool async) @@ -1520,94 +1314,6 @@ public virtual Task Where_navigation_property_to_collection_of_original_entity_t l2 => l2.OneToMany_Required_Inverse2.OneToMany_Optional1.MaybeScalar(x => x.Count()) > 0)); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Complex_multi_include_with_order_by_and_paging(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Required_FK1), - new ExpectedInclude(l1 => l1.OneToMany_Optional2, "OneToOne_Required_FK1"), - new ExpectedInclude(l1 => l1.OneToMany_Required2, "OneToOne_Required_FK1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Optional2) - .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Required2) - .OrderBy(t => t.Name) - .Skip(0).Take(10), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Required_FK1), - new ExpectedInclude(l2 => l2.OneToMany_Required2, "OneToOne_Required_FK1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Optional_FK1).ThenInclude(e => e.OneToMany_Optional2) - .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Required2) - .OrderBy(t => t.Name) - .Skip(0).Take(10), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToOne_Required_FK2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToOne_Optional_FK1.OneToOne_Required_FK2") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Optional_FK1.OneToOne_Required_FK2).ThenInclude(e => e.OneToMany_Optional3) - .OrderBy(t => t.Name) - .Skip(0).Take(10), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_include_with_multiple_optional_navigations(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Required_FK1), - new ExpectedInclude(l2 => l2.OneToMany_Optional2, "OneToOne_Required_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Required_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToMany_Optional2) - .Include(e => e.OneToOne_Required_FK1).ThenInclude(e => e.OneToOne_Optional_FK2) - .Include(e => e.OneToOne_Optional_FK1).ThenInclude(e => e.OneToOne_Optional_FK2) - .Where(e => e.OneToOne_Required_FK1.OneToOne_Optional_PK2.Name != "Foo") - .OrderBy(e => e.Id), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes), - assertOrder: true); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Correlated_subquery_doesnt_project_unnecessary_columns_in_top_level(bool async) @@ -1813,80 +1519,6 @@ public virtual Task Where_predicate_on_optional_reference_navigation(bool async) .Select(l1 => l1.Name)); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_Include1(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .SelectMany(l1 => l1.OneToMany_Optional1) - .Include(l2 => l2.OneToMany_Optional2), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Orderby_SelectMany_with_Include1(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(l1 => l1.Id) - .SelectMany(l1 => l1.OneToMany_Optional1) - .Include(l2 => l2.OneToMany_Optional2), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_Include2(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .SelectMany(l1 => l1.OneToMany_Optional1) - .Include(l2 => l2.OneToOne_Required_FK2), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToOne_Required_FK2))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_Include_ThenInclude(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l2 => l2.OneToOne_Required_FK2), - new ExpectedInclude(l3 => l3.OneToMany_Optional3, "OneToOne_Required_FK2") - }; - - return AssertQuery( - async, - ss => ss.Set() - .SelectMany(l1 => l1.OneToMany_Optional1) - .Include(l2 => l2.OneToOne_Required_FK2) - .ThenInclude(l3 => l3.OneToMany_Optional3), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_SelectMany_with_Include(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l3 => l3.OneToOne_Required_FK3), new ExpectedInclude(l3 => l3.OneToMany_Optional3) - }; - - return AssertQuery( - async, - ss => ss.Set() - .SelectMany(l1 => l1.OneToMany_Optional1) - .SelectMany(l2 => l2.OneToMany_Optional2) - .Include(l3 => l3.OneToOne_Required_FK3) - .Include(l3 => l3.OneToMany_Optional3), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task SelectMany_with_string_based_Include1(bool async) @@ -1932,38 +1564,7 @@ public virtual Task Multiple_SelectMany_with_string_based_Include(bool async) [ConditionalTheory(Skip = "Issue#16752")] [MemberData(nameof(IsAsyncData))] - public virtual Task Required_navigation_with_Include(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Select(l3 => l3.OneToOne_Required_FK_Inverse3) - .Include(l2 => l2.OneToMany_Required_Inverse2), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Required_Inverse2))); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Required_navigation_with_Include_ThenInclude(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l3 => l3.OneToMany_Required_Inverse3), - new ExpectedInclude(l2 => l2.OneToMany_Optional_Inverse2, "OneToMany_Required_Inverse3") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Select(l4 => l4.OneToOne_Required_FK_Inverse4) - .Include(l3 => l3.OneToMany_Required_Inverse3) - .ThenInclude(l2 => l2.OneToMany_Optional_Inverse2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_required_navigations_with_Include(bool async) + public virtual Task Multiple_required_navigations_with_Include(bool async) { return AssertQuery( async, @@ -2023,106 +1624,6 @@ public virtual Task Optional_navigation_with_Include(bool async) elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2))); } - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Optional_navigation_with_Include_ThenInclude(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l2 => l2.OneToMany_Optional2), - new ExpectedInclude(l3 => l3.OneToOne_Optional_FK3, "OneToMany_Optional2") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Select(l1 => l1.OneToOne_Optional_FK1) - .Include(l2 => l2.OneToMany_Optional2) - .ThenInclude(l3 => l3.OneToOne_Optional_FK3), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_optional_navigation_with_Include(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Select(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) - .Include(l3 => l3.OneToMany_Optional3), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_optional_navigation_with_string_based_Include(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Select(l1 => l1.OneToOne_Optional_FK1) - .Select(l2 => l2.OneToOne_Optional_PK2) - .Include("OneToMany_Optional3"), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Optional_navigation_with_order_by_and_Include(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Select(l1 => l1.OneToOne_Optional_FK1) - .OrderBy(l2 => l2.Name) - .Include(l2 => l2.OneToMany_Optional2), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), - assertOrder: true); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Optional_navigation_with_Include_and_order(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Select(l1 => l1.OneToOne_Optional_FK1) - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => l2.Name), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), - assertOrder: true); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_order_by_and_Include(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .SelectMany(l1 => l1.OneToMany_Optional1) - .OrderBy(l2 => l2.Name) - .Include(l2 => l2.OneToMany_Optional2), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), - assertOrder: true); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_Include_and_order_by(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .SelectMany(l1 => l1.OneToMany_Optional1) - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => l2.Name), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l2 => l2.OneToMany_Optional2)), - assertOrder: true); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task SelectMany_with_navigation_and_explicit_DefaultIfEmpty(bool async) @@ -2136,31 +1637,6 @@ from l2 in l1.OneToMany_Optional1.DefaultIfEmpty() select l1); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_navigation_and_Distinct(bool async) - { - return AssertQuery( - async, - ss => from l1 in ss.Set().Include(l => l.OneToMany_Optional1) - from l2 in l1.OneToMany_Optional1.Distinct() - where l2 != null - select l1, - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l1 => l1.OneToMany_Optional1))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) - { - return AssertQuery( - async, - ss => from l1 in ss.Set().Include(l => l.OneToMany_Optional1) - from l2 in l1.OneToMany_Optional1.Select(x => new { x.Id, x.Name, FK = EF.Property(x, "OneToMany_Optional_Inverse2Id") }).Distinct() - select l1, - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l1 => l1.OneToMany_Optional1))); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task SelectMany_with_navigation_filter_and_explicit_DefaultIfEmpty(bool async) @@ -2371,58 +1847,6 @@ public virtual Task select l3.OneToOne_Required_FK_Inverse3.OneToOne_Required_PK_Inverse2); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task - Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) - { - return AssertQuery( - async, - ss => from l4 in ss.Set().SelectMany( - l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) - join l2 in ss.Set().SelectMany( - l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2 - .DefaultIfEmpty()) - on l4.Id equals l2.Id - join l3 in ss.Set().SelectMany( - l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) - on l2.Id equals l3.Id into grouping - from l3 in grouping.DefaultIfEmpty() - where l4.OneToMany_Optional_Inverse4.Name != "Foo" - orderby l2.OneToOne_Optional_FK2.Id - select new - { - Entity = l4, - Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), - Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name - }, - ss => from l4 in ss.Set().SelectMany( - l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) - join l2 in ss.Set().SelectMany( - l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2 - .DefaultIfEmpty()) - on l4.Id equals l2.Id - join l3 in ss.Set().SelectMany( - l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) - on l2.Id equals l3.Id into grouping - from l3 in grouping.DefaultIfEmpty() - where l4.OneToMany_Optional_Inverse4.Name != "Foo" - orderby l2.OneToOne_Optional_FK2.MaybeScalar(x => x.Id) - select new - { - Entity = l4, - Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), - Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name - }, - elementSorter: e => e.Entity.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.Entity, a.Entity); - AssertCollection(e.Collection, a.Collection); - Assert.Equal(e.Property, a.Property); - }); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual Task Multiple_SelectMany_with_navigation_and_explicit_DefaultIfEmpty(bool async) @@ -3355,2159 +2779,934 @@ orderby l3.Id [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_navigation(bool async) + public virtual Task Project_collection_navigation_count(bool async) { return AssertQuery( async, ss => from l1 in ss.Set() - select l1.OneToMany_Optional1, - elementSorter: e => e != null ? e.Count : 0, - elementAsserter: (e, a) => AssertCollection(e, a)); + select new { l1.Id, l1.OneToOne_Optional_FK1.OneToMany_Optional2.Count }, + ss => from l1 in ss.Set() + select new { l1.Id, Count = l1.OneToOne_Optional_FK1.OneToMany_Optional2.MaybeScalar(x => x.Count) ?? 0 }, + elementSorter: e => e.Id); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_navigation_nested(bool async) + public virtual Task Select_optional_navigation_property_string_concat(bool async) { return AssertQuery( async, ss => from l1 in ss.Set() - select l1.OneToOne_Optional_FK1.OneToMany_Optional2, - ss => from l1 in ss.Set() - select l1.OneToOne_Optional_FK1.OneToMany_Optional2 ?? new List(), - elementSorter: e => e.Count, - elementAsserter: (e, a) => AssertCollection(e, a)); + from l2 in l1.OneToMany_Optional1.Where(l => l.Id > 5).OrderByDescending(l => l.Name).DefaultIfEmpty() + select l1.Name + " " + (l2 != null ? l2.Name : "NULL")); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_navigation_nested_with_take(bool async) + [ConditionalFact] + public virtual void Entries_for_detached_entities_are_removed() { - return AssertQuery( - async, - ss => from l1 in ss.Set() - select l1.OneToOne_Optional_FK1.OneToMany_Optional2.Take(50), - ss => from l1 in ss.Set() - select (l1.OneToOne_Optional_FK1.OneToMany_Optional2 ?? new List()).Take(50), - elementSorter: e => e?.Count() ?? 0, - elementAsserter: (e, a) => AssertCollection(e, a)); + using var context = CreateContext(); + context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.TrackAll; + var entity = QueryAsserter.SetSourceCreator(context).Set().OrderBy(l2 => l2.Id).First(); + var entry = context.ChangeTracker.Entries().Single(); + Assert.Same(entity, entry.Entity); + + entry.State = EntityState.Detached; + + Assert.Empty(context.ChangeTracker.Entries()); + + context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; } - [ConditionalTheory] + [ConditionalTheory(Skip = "Issue#12088")] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_navigation_using_ef_property(bool async) + public virtual Task Include_reference_with_groupby_in_subquery(bool async) { return AssertQuery( async, - ss => from l1 in ss.Set() - select EF.Property>( - EF.Property( - l1, - "OneToOne_Optional_FK1"), - "OneToMany_Optional2"), - elementSorter: e => e?.Count ?? 0, - elementAsserter: (e, a) => AssertCollection(e ?? new List(), a)); + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1) + .GroupBy(g => g.Name) + .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1))); } - [ConditionalTheory] + [ConditionalTheory(Skip = "Issue#12088")] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_navigation_nested_anonymous(bool async) + public virtual Task Multi_include_with_groupby_in_subquery(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.OneToOne_Optional_FK1), + new ExpectedInclude(e => e.OneToMany_Optional2, "OneToOne_Optional_FK1") + }; + return AssertQuery( async, - ss => from l1 in ss.Set() - select new { l1.Id, l1.OneToOne_Optional_FK1.OneToMany_Optional2 }, - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.Id, a.Id); - AssertCollection(e.OneToMany_Optional2 ?? new List(), a.OneToMany_Optional2); - }); + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2) + .GroupBy(g => g.Name) + .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_navigation_count(bool async) + public virtual Task String_include_multiple_derived_navigation_with_same_name_and_same_type(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.ReferenceSameType), + new ExpectedInclude(e => e.ReferenceSameType) + }; + return AssertQuery( async, - ss => from l1 in ss.Set() - select new { l1.Id, l1.OneToOne_Optional_FK1.OneToMany_Optional2.Count }, - ss => from l1 in ss.Set() - select new { l1.Id, Count = l1.OneToOne_Optional_FK1.OneToMany_Optional2.MaybeScalar(x => x.Count) ?? 0 }, - elementSorter: e => e.Id); + ss => ss.Set().Include("ReferenceSameType"), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_navigation_composed(bool async) + public virtual Task String_include_multiple_derived_navigation_with_same_name_and_different_type(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.ReferenceDifferentType), + new ExpectedInclude(e => e.ReferenceDifferentType) + }; + return AssertQuery( async, - ss => from l1 in ss.Set() - where l1.Id < 3 - select new { l1.Id, collection = l1.OneToMany_Optional1.Where(l2 => l2.Name != "Foo").ToList() }, - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.Id, a.Id); - AssertCollection(e.collection, a.collection); - }); + ss => ss.Set().Include("ReferenceDifferentType"), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_and_root_entity(bool async) + public virtual Task + String_include_multiple_derived_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( + bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.ReferenceDifferentType), + new ExpectedInclude(e => e.ReferenceDifferentType), + new ExpectedInclude(e => e.BaseCollection, "ReferenceDifferentType") + }; + return AssertQuery( async, - ss => from l1 in ss.Set() - select new { l1, l1.OneToMany_Optional1 }, - elementSorter: e => e.l1.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.l1.Id, a.l1.Id); - AssertCollection(e.OneToMany_Optional1, a.OneToMany_Optional1); - }); + ss => ss.Set().Include("ReferenceDifferentType.BaseCollection"), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_collection_and_include(bool async) + public virtual Task String_include_multiple_derived_collection_navigation_with_same_name_and_same_type(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.CollectionSameType), + new ExpectedInclude(e => e.CollectionSameType) + }; + return AssertQuery( async, - ss => from l1 in ss.Set().Include(l => l.OneToMany_Optional1) - select new { l1, l1.OneToMany_Optional1 }, - elementSorter: e => e.l1.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.l1.Id, a.l1.Id); - AssertCollection(e.OneToMany_Optional1, a.OneToMany_Optional1); - }); + ss => ss.Set().Include("CollectionSameType"), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Project_navigation_and_collection(bool async) + public virtual Task String_include_multiple_derived_collection_navigation_with_same_name_and_different_type(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.CollectionDifferentType), + new ExpectedInclude(e => e.CollectionDifferentType) + }; + return AssertQuery( async, - ss => from l1 in ss.Set() - select new { l1.OneToOne_Optional_FK1, l1.OneToOne_Optional_FK1.OneToMany_Optional2 }, - elementSorter: e => e.OneToOne_Optional_FK1?.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.OneToOne_Optional_FK1?.Id, a.OneToOne_Optional_FK1?.Id); - AssertCollection(e.OneToMany_Optional2 ?? new List(), a.OneToMany_Optional2); - }); + ss => ss.Set().Include("CollectionDifferentType"), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_inside_subquery(bool async) + public virtual Task + String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( + bool async) { - // can't use AssertQuery here, see #18191 + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.CollectionDifferentType), + new ExpectedInclude(e => e.CollectionDifferentType), + new ExpectedInclude(e => e.BaseCollection, "CollectionDifferentType") + }; + return AssertQuery( async, - ss => ss.Set() - .Where(l1 => l1.Id < 3) - .OrderBy(l1 => l1.Id) - .Select(l1 => new { subquery = ss.Set().Include(l => l.OneToMany_Optional2).Where(l => l.Id > 0).ToList() }), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e.subquery, a.subquery)); + ss => ss.Set().Include("CollectionDifferentType.BaseCollection"), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Select_optional_navigation_property_string_concat(bool async) + public virtual Task String_include_multiple_derived_navigations_complex(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(e => e.Reference), + new ExpectedInclude(e => e.CollectionDifferentType, "Reference"), + new ExpectedInclude(e => e.CollectionDifferentType, "Reference"), + new ExpectedInclude(e => e.Collection), + new ExpectedInclude(e => e.ReferenceSameType, "Collection"), + new ExpectedInclude(e => e.ReferenceSameType, "Collection") + }; + return AssertQuery( async, - ss => from l1 in ss.Set() - from l2 in l1.OneToMany_Optional1.Where(l => l.Id > 5).OrderByDescending(l => l.Name).DefaultIfEmpty() - select l1.Name + " " + (l2 != null ? l2.Name : "NULL")); + ss => ss.Set().Include("Reference.CollectionDifferentType").Include("Collection.ReferenceSameType"), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_multiple_orderbys_member(bool async) + public virtual Task Nav_rewrite_doesnt_apply_null_protection_for_function_arguments(bool async) { - return AssertQuery( + return AssertQueryScalar( async, - ss => ss.Set() - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => l2.Name) - .ThenBy(l2 => l2.Level1_Required_Id), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), - assertOrder: true); + ss => ss.Set().Where(l1 => l1.OneToOne_Optional_PK1 != null) + .Select(l1 => Math.Max(l1.OneToOne_Optional_PK1.Level1_Required_Id, 7))); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_multiple_orderbys_property(bool async) + public virtual Task Accessing_optional_property_inside_result_operator_subquery(bool async) { + var names = new[] { "Name1", "Name2" }; + return AssertQuery( async, - ss => ss.Set() - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => EF.Property(l2, "Level1_Required_Id")) - .ThenBy(l2 => l2.Name), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), - assertOrder: true); + ss => ss.Set().Where(l1 => names.All(n => l1.OneToOne_Optional_FK1.Name != n))); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_multiple_orderbys_methodcall(bool async) + public virtual Task SelectMany_subquery_with_custom_projection(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => Math.Abs(l2.Level1_Required_Id)) - .ThenBy(l2 => l2.Name), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), - assertOrder: true); + ss => ss.Set().OrderBy(l1 => l1.Id).SelectMany( + l1 => l1.OneToMany_Optional1.Select( + l2 => new { l2.Name })).Take(1)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_multiple_orderbys_complex(bool async) + public virtual Task Include1(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => Math.Abs(l2.Level1_Required_Id) + 7) - .ThenBy(l2 => l2.Name), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), - assertOrder: true); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1), + elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1))); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_multiple_orderbys_complex_repeated(bool async) + public virtual Task Include2(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) + }; + return AssertQuery( async, - ss => ss.Set() - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => -l2.Level1_Required_Id) - .ThenBy(l2 => -l2.Level1_Required_Id).ThenBy(l2 => l2.Name), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), - assertOrder: true); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToOne_Optional_FK1), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_multiple_orderbys_complex_repeated_checked(bool async) + public virtual Task Include3(bool async) { - checked + var expectedIncludes = new IExpectedInclude[] { - return AssertQuery( - async, - ss => ss.Set() - .Include(l2 => l2.OneToMany_Optional2) - .OrderBy(l2 => -l2.Level1_Required_Id) - .ThenBy(l2 => -l2.Level1_Required_Id).ThenBy(l2 => l2.Name), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional2)), - assertOrder: true); - } - } - - [ConditionalFact] - public virtual void Entries_for_detached_entities_are_removed() - { - using var context = CreateContext(); - context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.TrackAll; - var entity = QueryAsserter.SetSourceCreator(context).Set().OrderBy(l2 => l2.Id).First(); - var entry = context.ChangeTracker.Entries().Single(); - Assert.Same(entity, entry.Entity); - - entry.State = EntityState.Detached; - - Assert.Empty(context.ChangeTracker.Entries()); - - context.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; - } + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1) + }; - [ConditionalTheory(Skip = "Issue#12088")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_reference_with_groupby_in_subquery(bool async) - { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1) - .GroupBy(g => g.Name) - .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToOne_Optional_FK1))); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToOne_Optional_PK1), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } - [ConditionalTheory(Skip = "Issue#12088")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_groupby_in_subquery(bool async) + public virtual Task Include4(bool async) { + var expectedIncludes = new IExpectedInclude[] + { + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1") + }; + return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .GroupBy(g => g.Name) - .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional1))); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).ThenInclude(l1 => l1.OneToOne_Optional_PK2), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } - [ConditionalTheory(Skip = "Issue#12088")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Multi_include_with_groupby_in_subquery(bool async) + public virtual Task Include5(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToOne_Optional_FK1") + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1") }; return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2) - .GroupBy(g => g.Name) - .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2), elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } - [ConditionalTheory(Skip = "Issue#12088")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_groupby_in_subquery_and_filter_before_groupby(bool async) + public virtual Task Include6(bool async) { + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2) }; + return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .Where(l1 => l1.Id > 3) - .GroupBy(g => g.Name) - .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional1))); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2).Select(l1 => l1.OneToOne_Optional_FK1), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } - [ConditionalTheory(Skip = "Issue#12088")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Include_collection_with_groupby_in_subquery_and_filter_after_groupby(bool async) + public virtual Task Include7(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .GroupBy(g => g.Name) - .Where(g => g.Key != "Foo") - .Select(g => g.OrderBy(e => e.Id).FirstOrDefault()), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(e => e.OneToMany_Optional1))); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) + .Select(l1 => l1.OneToOne_Optional_PK1)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_include_multiple_derived_navigation_with_same_name_and_same_type(bool async) + public virtual Task Include8(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(e => e.ReferenceSameType), - new ExpectedInclude(e => e.ReferenceSameType) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) }; return AssertQuery( async, - ss => ss.Set().Include("ReferenceSameType"), + ss => ss.Set() + .Where(l2 => l2.OneToOne_Optional_FK_Inverse2.Name != "Fubar") + .Include(l2 => l2.OneToOne_Optional_FK_Inverse2), elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_include_multiple_derived_navigation_with_same_name_and_different_type(bool async) + public virtual Task Include9(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(e => e.ReferenceDifferentType), - new ExpectedInclude(e => e.ReferenceDifferentType) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) }; return AssertQuery( async, - ss => ss.Set().Include("ReferenceDifferentType"), + ss => ss.Set() + .Include(l2 => l2.OneToOne_Optional_FK_Inverse2) + .Where(l2 => l2.OneToOne_Optional_FK_Inverse2.Name != "Fubar"), elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task - String_include_multiple_derived_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( - bool async) + public virtual Task Include10(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.ReferenceDifferentType), - new ExpectedInclude(e => e.ReferenceDifferentType), - new ExpectedInclude(e => e.BaseCollection, "ReferenceDifferentType") + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_PK1"), + new ExpectedInclude(l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_FK1.OneToOne_Optional_FK2") }; return AssertQuery( async, - ss => ss.Set().Include("ReferenceDifferentType.BaseCollection"), + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) + .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_FK2.OneToOne_Optional_PK3), elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_include_multiple_derived_collection_navigation_with_same_name_and_same_type(bool async) + public virtual Task Include11(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.CollectionSameType), - new ExpectedInclude(e => e.CollectionSameType) + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_PK1"), + new ExpectedInclude(l3 => l3.OneToOne_Optional_FK3, "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), + new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_PK1"), + new ExpectedInclude(l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), + new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK1") }; return AssertQuery( async, - ss => ss.Set().Include("CollectionSameType"), + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) + .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) + .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3) + .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_FK2.OneToOne_Optional_PK3) + .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_PK2), elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_include_multiple_derived_collection_navigation_with_same_name_and_different_type(bool async) + public virtual Task Include12(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(e => e.CollectionDifferentType), - new ExpectedInclude(e => e.CollectionDifferentType) - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2) }; return AssertQuery( async, - ss => ss.Set().Include("CollectionDifferentType"), + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) + .Select(l1 => l1.OneToOne_Optional_FK1), elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task - String_include_multiple_derived_collection_navigation_with_same_name_and_different_type_nested_also_includes_partially_matching_navigation_chains( - bool async) + public virtual Task Include13(bool async) { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(e => e.CollectionDifferentType), - new ExpectedInclude(e => e.CollectionDifferentType), - new ExpectedInclude(e => e.BaseCollection, "CollectionDifferentType") - }; + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; return AssertQuery( async, - ss => ss.Set().Include("CollectionDifferentType.BaseCollection"), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); + ss => ss.Set() + .Include(l1 => l1.OneToOne_Optional_FK1) + .Select(l1 => new { one = l1, two = l1 }), + elementAsserter: (e, a) => + { + AssertInclude(e.one, a.one, expectedIncludes); + AssertInclude(e.two, a.two, expectedIncludes); + }, + elementSorter: e => e.one.Id); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task String_include_multiple_derived_navigations_complex(bool async) + public virtual Task Include14(bool async) { var expectedIncludes = new IExpectedInclude[] { - new ExpectedInclude(e => e.Reference), - new ExpectedInclude(e => e.CollectionDifferentType, "Reference"), - new ExpectedInclude(e => e.CollectionDifferentType, "Reference"), - new ExpectedInclude(e => e.Collection), - new ExpectedInclude(e => e.ReferenceSameType, "Collection"), - new ExpectedInclude(e => e.ReferenceSameType, "Collection") - }; - - return AssertQuery( - async, - ss => ss.Set().Include("Reference.CollectionDifferentType").Include("Collection.ReferenceSameType"), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_reference_collection_order_by_reference_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2) - .OrderBy(l1 => (int?)l1.OneToOne_Optional_FK1.Id), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToOne_Optional_FK1")), - assertOrder: true); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Nav_rewrite_doesnt_apply_null_protection_for_function_arguments(bool async) - { - return AssertQueryScalar( - async, - ss => ss.Set().Where(l1 => l1.OneToOne_Optional_PK1 != null) - .Select(l1 => Math.Max(l1.OneToOne_Optional_PK1.Level1_Required_Id, 7))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Accessing_optional_property_inside_result_operator_subquery(bool async) - { - var names = new[] { "Name1", "Name2" }; - - return AssertQuery( - async, - ss => ss.Set().Where(l1 => names.All(n => l1.OneToOne_Optional_FK1.Name != n))); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_after_SelectMany_and_reference_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) - .Include(l3 => l3.OneToMany_Optional3), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_after_multiple_SelectMany_and_reference_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set().SelectMany(l1 => l1.OneToMany_Required1).SelectMany(l2 => l2.OneToMany_Optional2) - .Select(l3 => l3.OneToOne_Required_FK3).Include(l4 => l4.OneToMany_Required_Self4), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l4 => l4.OneToMany_Required_Self4))); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_after_SelectMany_and_multiple_reference_navigations(bool async) - { - return AssertQuery( - async, - ss => ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) - .Select(l3 => l3.OneToOne_Required_FK3).Include(l4 => l4.OneToMany_Optional_Self4), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l4 => l4.OneToMany_Optional_Self4))); - } - - [ConditionalTheory(Skip = "Issue#16752")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_after_SelectMany_and_reference_navigation_with_another_SelectMany_with_Distinct(bool async) - { - return AssertQuery( - async, - ss => from lOuter in ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) - .Include(l3 => l3.OneToMany_Optional3) - from lInner in lOuter.OneToMany_Optional3.Distinct() - where lInner != null - select lOuter, - ss => from lOuter in ss.Set().SelectMany(l1 => l1.OneToMany_Required1).Select(l2 => l2.OneToOne_Optional_FK2) - where lOuter != null - from lInner in lOuter.OneToMany_Optional3.Distinct() - where lInner != null - select lOuter, - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l3 => l3.OneToMany_Optional3))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_subquery_with_custom_projection(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(l1 => l1.Id).SelectMany( - l1 => l1.OneToMany_Optional1.Select( - l2 => new { l2.Name })).Take(1)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(l1 => l1.Id).Select( - l1 => new - { - Level2s = l1.OneToMany_Optional1.Select( - l2 => new - { - Level3 = l2.OneToOne_Required_FK2 == null - ? null - : new { l2.OneToOne_Required_FK2.Name } - }).ToList() - }), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection( - e.Level2s, - a.Level2s, - elementSorter: ee => ee?.Level3.Name)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Null_check_in_Dto_projection_should_not_be_removed(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(l1 => l1.Id).Select( - l1 => new - { - Level2s = l1.OneToMany_Optional1.Select( - l2 => new - { - Level3 = l2.OneToOne_Required_FK2 == null - ? null - : new ProjectedDto { Value = l2.OneToOne_Required_FK2.Name } - }).ToList() - }), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection( - e.Level2s, - a.Level2s, - elementSorter: ee => ee.Level3?.Value, - elementAsserter: (ee, aa) => Assert.Equal(ee.Level3?.Value, aa.Level3?.Value))); - } - - private class ProjectedDto - { - public T Value { get; set; } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set().SelectMany(l1 => l1.OneToMany_Optional1).Select(l2 => new { l2.Id, l2.OneToMany_Optional2 }), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.Id, a.Id); - AssertCollection(e.OneToMany_Optional2, a.OneToMany_Optional2); - }); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Multiple_SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set().SelectMany(l1 => l1.OneToMany_Optional1).SelectMany(l2 => l2.OneToMany_Optional2) - .Select(l2 => new { l2.Id, l2.OneToMany_Optional3 }), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.Id, a.Id); - AssertCollection(e.OneToMany_Optional3, a.OneToMany_Optional3); - }); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_navigation_property_with_include_and_followed_by_select_collection_navigation(bool async) - { - // can't use AssertQuery here, see #18191 - return AssertQuery( - async, - ss => ss.Set() - .SelectMany(l1 => l1.OneToMany_Optional1) - .Include(l2 => l2.OneToMany_Required2) - .Select(l2 => new { l2, l2.OneToMany_Optional2 }), - elementSorter: e => e.l2.Id, - elementAsserter: (e, a) => - { - AssertEqual(e.l2, a.l2); - AssertCollection(e.l2.OneToMany_Required2, a.l2.OneToMany_Required2); - AssertCollection(e.OneToMany_Optional2, a.OneToMany_Optional2); - }); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include1(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1), - elementAsserter: (e, a) => AssertInclude(e, a, new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include2(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) - }; - - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToOne_Optional_FK1), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include3(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1) - }; - - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToOne_Optional_PK1), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include4(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1") - }; - - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).ThenInclude(l1 => l1.OneToOne_Optional_PK2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include5(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1") - }; - - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include6(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2) }; - - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2).Select(l1 => l1.OneToOne_Optional_FK1), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include7(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) - .Select(l1 => l1.OneToOne_Optional_PK1)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include8(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) }; - - return AssertQuery( - async, - ss => ss.Set() - .Where(l2 => l2.OneToOne_Optional_FK_Inverse2.Name != "Fubar") - .Include(l2 => l2.OneToOne_Optional_FK_Inverse2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include9(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK_Inverse2) }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(l2 => l2.OneToOne_Optional_FK_Inverse2) - .Where(l2 => l2.OneToOne_Optional_FK_Inverse2.Name != "Fubar"), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include10(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_PK1"), - new ExpectedInclude(l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_FK1.OneToOne_Optional_FK2") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) - .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_FK2.OneToOne_Optional_PK3), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include11(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_FK1"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_PK1"), - new ExpectedInclude(l3 => l3.OneToOne_Optional_FK3, "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), - new ExpectedInclude(l1 => l1.OneToOne_Optional_PK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_PK1"), - new ExpectedInclude(l3 => l3.OneToOne_Optional_PK3, "OneToOne_Optional_PK1.OneToOne_Optional_FK2"), - new ExpectedInclude(l2 => l2.OneToOne_Optional_PK2, "OneToOne_Optional_PK1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) - .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2) - .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3) - .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_FK2.OneToOne_Optional_PK3) - .Include(l1 => l1.OneToOne_Optional_PK1.OneToOne_Optional_PK2), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include12(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2) }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) - .Select(l1 => l1.OneToOne_Optional_FK1), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include13(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1) - .Select(l1 => new { one = l1, two = l1 }), - elementAsserter: (e, a) => - { - AssertInclude(e.one, a.one, expectedIncludes); - AssertInclude(e.two, a.two, expectedIncludes); - }, - elementSorter: e => e.one.Id); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include14(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), - new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK1") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) - .Select( - l1 => new - { - one = l1, - two = l1.OneToOne_Optional_FK1, - three = l1.OneToOne_Optional_PK1 - }), - elementAsserter: (e, a) => - { - AssertInclude(e.one, a.one, expectedIncludes); - AssertInclude(e.two, a.two, new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2)); - AssertEqual(e.three, a.three); - }, - elementSorter: e => e.one.Id); - } - - [ConditionalFact(Skip = "Issue#16752")] - public virtual void Include15() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) - .Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); - - var result = query.ToList(); - } - - [ConditionalFact(Skip = "Issue#16752")] - public virtual void Include16() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }).Distinct() - .Include(x => x.foo.OneToOne_Optional_FK2).Include(x => x.bar.OneToMany_Optional2); - - var result = query.ToList(); - } - - [ConditionalFact(Skip = "Issue#16752")] - public virtual void Include17() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) - .Include(x => x.foo.OneToOne_Optional_FK2).Distinct(); - - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include18_1(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; - - return AssertQuery( - async, - ss => ss.Set().Include(x => x.OneToOne_Optional_FK1).Distinct(), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include18_1_1(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; - - return AssertQuery( - async, - ss => ss.Set().OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1).Take(10), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include18_2(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; - - return AssertQuery( - async, - ss => ss.Set().Where(x => x.OneToOne_Required_FK1.Name != "Foo").Include(x => x.OneToOne_Optional_FK1).Distinct(), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalFact] - public virtual void Include18_3() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .OrderBy(x => x.OneToOne_Required_FK1.Name) - .Include(x => x.OneToOne_Optional_FK1) - .Select(l1 => new { foo = l1, bar = l1 }).Take(10); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Include18_3_1() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .OrderBy(x => x.OneToOne_Required_FK1.Name) - .Include(x => x.OneToOne_Optional_FK1) - .Select(l1 => new { foo = l1, bar = l1 }) - .Take(10) - .Select(x => new { x.foo, x.bar }); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Include18_3_2() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .OrderBy(x => x.OneToOne_Required_FK1.Name) - .Include(x => x.OneToOne_Optional_FK1) - .Select(l1 => new { outer_foo = new { inner_foo = l1, inner_bar = l1.Name }, outer_bar = l1 }) - .Take(10); - - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include18_3_3(bool async) - { - var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK2) }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(x => x.OneToOne_Optional_FK1.OneToOne_Optional_FK2) - .Select(l1 => l1.OneToOne_Optional_FK1) - .Distinct(), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalFact] - public virtual void Include18_4() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(x => x.OneToOne_Optional_FK1).Select(l1 => new { foo = l1, bar = l1 }).Distinct(); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Include18() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(x => x.OneToOne_Optional_FK1) - .Select(l1 => new { foo = l1, bar = l1.OneToOne_Optional_PK1 }) - .OrderBy(x => x.foo.Id) - .Take(10); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Include19() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(x => x.OneToOne_Optional_FK1) - .Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) - .Distinct(); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection1() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection2() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection3() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToOne_Optional_FK1).ThenInclude(l2 => l2.OneToMany_Optional2); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection4() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).Select(l1 => l1.OneToMany_Optional1); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection5() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .Select(l1 => l1.OneToMany_Optional1); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection6() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .ThenInclude(l3 => l3.OneToOne_Optional_FK3) - .Select(l1 => l1.OneToMany_Optional1); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection6_1() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .ThenInclude(l3 => l3.OneToOne_Optional_FK3); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection6_2() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .ThenInclude(l3 => l3.OneToOne_Optional_FK3) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) - .ThenInclude(l3 => l3.OneToMany_Optional3) - .Select(l1 => l1.OneToMany_Optional1); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection6_3() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .ThenInclude(l3 => l3.OneToOne_Optional_FK3) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) - .ThenInclude(l3 => l3.OneToMany_Optional3); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection6_4() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .ThenInclude(l3 => l3.OneToOne_Optional_FK3) - .Select(l1 => l1.OneToMany_Optional1.Select(l2 => l2.OneToOne_Optional_PK2)); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void IncludeCollection7() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .Select(l1 => new { l1, l1.OneToMany_Optional1 }); - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task IncludeCollection8(bool async) - { - var expectedIncludes = new IExpectedInclude[] - { - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedInclude(e => e.OneToOne_Optional_PK2, "OneToMany_Optional1"), - new ExpectedInclude(e => e.OneToOne_Optional_FK3, "OneToMany_Optional1.OneToOne_Optional_PK2") - }; - - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Optional_PK2) - .ThenInclude(l3 => l3.OneToOne_Optional_FK3) - .Where(l1 => l1.OneToMany_Optional1.Where(l2 => l2.OneToOne_Optional_PK2.Name != "Foo").Count() > 0), - elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_with_all_method_include_gets_ignored(bool async) - { - return AssertAll( - async, - ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToMany_Optional1), - predicate: l1 => l1.Name != "Foo"); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Join_with_navigations_in_the_result_selector1(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Join( - ss.Set(), l1 => l1.Id, l2 => l2.Level1_Required_Id, (o, i) => new { o.OneToOne_Optional_FK1, i })); - } - - [ConditionalFact] - public virtual void Join_with_navigations_in_the_result_selector2() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.Join( - ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, - (o, i) => new { o.OneToOne_Optional_FK1, i.OneToMany_Optional2 }); - var result = query.ToList(); - } - - [ConditionalFact(Skip = "issue #12200")] - public virtual void GroupJoin_with_navigations_in_the_result_selector() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.GroupJoin( - ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, (o, i) => new { o.OneToOne_Optional_FK1, i }); - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Member_pushdown_chain_3_levels_deep() - { - using var ctx = CreateContext(); - var query = from l1 in ctx.LevelOne - orderby l1.Id - where (from l2 in ctx.LevelTwo - orderby l2.Id - where l2.Level1_Optional_Id == l1.Id - select (from l3 in ctx.LevelThree - orderby l3.Id - where l3.Level2_Required_Id == l2.Id - select (from l4 in ctx.LevelFour - where l4.Level3_Required_Id == l3.Id - orderby l4.Id - select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault().Name - != "Foo" - select l1; - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Member_pushdown_chain_3_levels_deep_entity() - { - using var ctx = CreateContext(); - var query = from l1 in ctx.LevelOne - orderby l1.Id - select (from l2 in ctx.LevelTwo - orderby l2.Id - where l2.Level1_Optional_Id == l1.Id - select (from l3 in ctx.LevelThree - orderby l3.Id - where l3.Level2_Required_Id == l2.Id - select (from l4 in ctx.LevelFour - where l4.Level3_Required_Id == l3.Id - orderby l4.Id - select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault(); - - var result = query.ToList(); - } - - [ConditionalFact] - public virtual void Member_pushdown_with_collection_navigation_in_the_middle() - { - using var ctx = CreateContext(); - var query = from l1 in ctx.LevelOne - orderby l1.Id - select (from l2 in ctx.LevelTwo - orderby l2.Id - where l2.Level1_Required_Id == l1.Id - select l2.OneToMany_Optional2.Select( - l3 => (from l4 in ctx.LevelFour - where l4.Level3_Required_Id == l3.Id - orderby l4.Id - select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault().Name; - - var result = query.ToList(); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Member_pushdown_with_multiple_collections(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Select( - l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().OneToMany_Optional2.OrderBy(l3 => l3.Id) - .FirstOrDefault().Name), - ss => ss.Set().Select( - l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().Maybe( - x => x.OneToMany_Optional2.OrderBy(l3 => l3.Id) - .FirstOrDefault().Maybe(xx => xx.Name)))); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Include_multiple_collections_on_same_level(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1).Include(l1 => l1.OneToMany_Required1), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(l1 => l1.OneToMany_Optional1), - new ExpectedInclude(l1 => l1.OneToMany_Required1)), - assertOrder: true); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Null_check_removal_applied_recursively(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Where( - l1 => - (((l1.OneToOne_Optional_FK1 == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) - == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3) - == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) - == "L4 01")); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Null_check_different_structure_does_not_remove_null_checks(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Where( - l1 => - (l1.OneToOne_Optional_FK1 == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2 == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3 == null - ? null - : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) - == "L4 01")); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Union_over_entities_with_different_nullability(bool async) - { - return AssertQueryScalar( - async, - ss => ss.Set() - .GroupJoin(ss.Set(), l1 => l1.Id, l2 => l2.Level1_Optional_Id, (l1, l2s) => new { l1, l2s }) - .SelectMany(g => g.l2s.DefaultIfEmpty(), (g, l2) => new { g.l1, l2 }) - .Concat( - ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) - .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) - .Where(e => e.l1.Equals(null))) - .Select(e => (int?)e.l1.Id), - ss => ss.Set() - .GroupJoin(ss.Set(), l1 => l1.Id, l2 => l2.Level1_Optional_Id, (l1, l2s) => new { l1, l2s }) - .SelectMany(g => g.l2s.DefaultIfEmpty(), (g, l2) => new { g.l1, l2 }) - .Concat( - ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) - .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) - .Where(e => e.l1 == null)) - .Select(e => e.l1.MaybeScalar(x => x.Id))); - } + new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1), + new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2, "OneToOne_Optional_FK1") + }; - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Lift_projection_mapping_when_pushing_down_subquery(bool async) - { return AssertQuery( async, ss => ss.Set() - .Take(25) + .Include(l1 => l1.OneToOne_Optional_FK1).ThenInclude(l2 => l2.OneToOne_Optional_FK2) .Select( l1 => new { - l1.Id, - c1 = l1.OneToMany_Required1.Select(l2 => new { l2.Id }).FirstOrDefault(), - c2 = l1.OneToMany_Required1.Select(l2 => new { l2.Id }) + one = l1, + two = l1.OneToOne_Optional_FK1, + three = l1.OneToOne_Optional_PK1 }), - elementSorter: t => t.Id, elementAsserter: (e, a) => { - Assert.Equal(e.Id, a.Id); - Assert.Equal(e.c1?.Id, a.c1?.Id); - AssertCollection(e.c2, a.c2, elementSorter: i => i.Id, elementAsserter: (ie, ia) => Assert.Equal(ie.Id, ia.Id)); - }); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Including_reference_navigation_and_projecting_collection_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Required_FK1) - .ThenInclude(e => e.OneToOne_Optional_FK2) - .Select( - e => new Level1 - { - Id = e.Id, - OneToOne_Required_FK1 = e.OneToOne_Required_FK1, - OneToMany_Required1 = e.OneToMany_Required1 - })); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Including_reference_navigation_and_projecting_collection_navigation_2(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .Include(e => e.OneToOne_Required_FK1) - .Include(e => e.OneToMany_Required1) - .Select(e => new { e, First = e.OneToMany_Required1.OrderByDescending(e => e.Id).FirstOrDefault() })); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task OrderBy_collection_count_ThenBy_reference_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set() - .OrderBy(l1 => l1.OneToOne_Required_FK1.OneToMany_Required2.Count()) - .ThenBy(l1 => l1.OneToOne_Required_FK1.OneToOne_Required_FK2.Name), - ss => ss.Set() - .OrderBy(l1 => l1.OneToOne_Required_FK1.OneToMany_Required2.MaybeScalar(x => x.Count()) ?? 0) - .ThenBy(l1 => l1.OneToOne_Required_FK1.OneToOne_Required_FK2.Name), - assertOrder: true); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Null_conditional_is_not_applied_explicitly_for_optional_navigation(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Where(l1 => l1.OneToOne_Optional_FK1 != null && l1.OneToOne_Optional_FK1.Name == "L2 01")); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task LeftJoin_with_Any_on_outer_source_and_projecting_collection_from_inner(bool async) - { - var validIds = new List { "L1 01", "L1 02" }; - - return AssertQuery( - async, - ss => from l1 in ss.Set().Where(l1 => validIds.Any(e => e == l1.Name)) - join l2 in ss.Set() - on l1.Id equals l2.Level1_Required_Id into l2s - from l2 in l2s.DefaultIfEmpty() - select new Level2 { Id = l2 == null ? 0 : l2.Id, OneToMany_Required2 = l2 == null ? null : l2.OneToMany_Required2 }); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Sum_with_selector_cast_using_as(bool async) - { - return AssertSum( - async, - ss => ss.Set().Select(s => s.Id as int?)); - } - - [ConditionalTheory(Skip = "Issue#12657")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Sum_with_filter_with_include_selector_cast_using_as(bool async) - { - return AssertQuery( - async, - ss => ss.Set().Where(l1 => l1.Id > l1.OneToMany_Optional1.Select(l2 => l2.Id as int?).Sum())); + AssertInclude(e.one, a.one, expectedIncludes); + AssertInclude(e.two, a.two, new ExpectedInclude(l2 => l2.OneToOne_Optional_FK2)); + AssertEqual(e.three, a.three); + }, + elementSorter: e => e.one.Id); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_with_joined_where_clause_cast_using_as(bool async) + [ConditionalFact(Skip = "Issue#16752")] + public virtual void Include17() { - return AssertQuery( - async, - ss => ss.Set().Where(w => w.Id == w.OneToOne_Optional_FK1.Id as int?)); - } + using var ctx = CreateContext(); + var query = ctx.LevelOne.Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) + .Include(x => x.foo.OneToOne_Optional_FK2).Distinct(); - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Select_subquery_single_nested_subquery(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(l1 => l1.Id).Select( - l1 => new - { - Level2 = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select( - l2 => new { Level3s = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select(l3 => new { l3.Id }).ToList() }) - .FirstOrDefault() - }), - assertOrder: true, - elementAsserter: (e, a) => - { - if (e.Level2 == null) - { - Assert.Null(a.Level2); - } - else - { - AssertCollection(e.Level2.Level3s, a.Level2.Level3s, ordered: true); - } - }); + var result = query.ToList(); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Select_subquery_single_nested_subquery2(bool async) + public virtual Task Include18_1(bool async) { + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; + return AssertQuery( async, - ss => ss.Set().OrderBy(l1 => l1.Id).Select( - l1 => new - { - Level2s = l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).Select( - l2 => new - { - Level3 = l2.OneToMany_Optional2.OrderBy(l3 => l3.Id).Select( - l3 => new - { - Level4s = l3.OneToMany_Optional3.OrderBy(l4 => l4.Id).Select(l4 => new { l4.Id }) - .ToList() - }).FirstOrDefault() - }) - }), - assertOrder: true, - elementAsserter: (e, a) => - { - AssertCollection( - e.Level2s, a.Level2s, ordered: true, elementAsserter: - (e2, a2) => - { - if (e2.Level3 == null) - { - Assert.Null(a2.Level3); - } - else - { - AssertCollection(e2.Level3.Level4s, a2.Level3.Level4s, ordered: true); - } - }); - }); + ss => ss.Set().Include(x => x.OneToOne_Optional_FK1).Distinct(), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(bool async) + public virtual Task Include18_1_1(bool async) { + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; + return AssertQuery( async, - ss => from l1 in ss.Set() - join l2 in ss.Set() on l1.Id equals l2.Level1_Required_Id - join l3 in ss.Set() on l2.Id equals l3.Level2_Required_Id - join l4 in ss.Set() on l3.Id equals l4.Level3_Required_Id - from other in ss.Set().Where(x => x.Id <= l2.Id && x.Name == l4.Name).DefaultIfEmpty() - select l1); + ss => ss.Set().OrderBy(x => x.OneToOne_Required_FK1.Name).Include(x => x.OneToOne_Optional_FK1).Take(10), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } - [ConditionalTheory(Skip = "issue #19095")] + [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async) + public virtual Task Include18_2(bool async) { + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK1) }; + return AssertQuery( async, - ss => ss.Set().SelectMany( - l1 => l1.OneToMany_Optional1.DefaultIfEmpty().SelectMany( - l2 => l2.OneToOne_Required_PK2.OneToMany_Optional3.DefaultIfEmpty() - .Select( - l4 => new - { - l1Name = l1.Name, - l2Name = l2.OneToOne_Required_PK2.Name, - l3Name = l4.OneToOne_Optional_PK_Inverse4.Name - })))); + ss => ss.Set().Where(x => x.OneToOne_Required_FK1.Name != "Foo").Include(x => x.OneToOne_Optional_FK1).Distinct(), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } [ConditionalFact] - public virtual void Contains_over_optional_navigation_with_null_constant() + public virtual void Include18_3() { using var ctx = CreateContext(); - var result = ctx.Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null); - var expected = Fixture.GetExpectedData().Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null); + var query = ctx.LevelOne + .OrderBy(x => x.OneToOne_Required_FK1.Name) + .Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1, bar = l1 }).Take(10); - Assert.Equal(expected, result); + var result = query.ToList(); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Contains_over_optional_navigation_with_null_parameter(bool async) + [ConditionalFact] + public virtual void Include18_3_1() { - return AssertSingleResult( - async, - ss => ss.Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null), - ss => ss.Set().Select(l1 => l1.OneToOne_Optional_FK1).ContainsAsync(null, default)); + using var ctx = CreateContext(); + var query = ctx.LevelOne + .OrderBy(x => x.OneToOne_Required_FK1.Name) + .Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1, bar = l1 }) + .Take(10) + .Select(x => new { x.foo, x.bar }); + + var result = query.ToList(); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Contains_over_optional_navigation_with_null_column(bool async) + [ConditionalFact] + public virtual void Include18_3_2() { - return AssertQuery( - async, - ss => ss.Set().Select( - l1 => new - { - l1.Name, - OptionalName = l1.OneToOne_Optional_FK1.Name, - Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1.Name).Contains(l1.OneToOne_Optional_FK1.Name) - }), - elementSorter: e => (e.Name, e.OptionalName, e.Contains)); + using var ctx = CreateContext(); + var query = ctx.LevelOne + .OrderBy(x => x.OneToOne_Required_FK1.Name) + .Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { outer_foo = new { inner_foo = l1, inner_bar = l1.Name }, outer_bar = l1 }) + .Take(10); + + var result = query.ToList(); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Contains_over_optional_navigation_with_null_entity_reference(bool async) + public virtual Task Include18_3_3(bool async) { + var expectedIncludes = new IExpectedInclude[] { new ExpectedInclude(l1 => l1.OneToOne_Optional_FK2) }; + return AssertQuery( async, - ss => ss.Set().Select( - l1 => new - { - l1.Name, - OptionalName = l1.OneToOne_Optional_FK1.Name, - Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1).Contains(l1.OneToOne_Optional_PK1) - }), - elementSorter: e => (e.Name, e.OptionalName, e.Contains)); + ss => ss.Set() + .Include(x => x.OneToOne_Optional_FK1.OneToOne_Optional_FK2) + .Select(l1 => l1.OneToOne_Optional_FK1) + .Distinct(), + elementAsserter: (e, a) => AssertInclude(e, a, expectedIncludes)); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_Where(bool async) + [ConditionalFact] + public virtual void Include18_4() { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Where(l2 => l2.Id > 5)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(l2 => l2.Id > 5)))); + using var ctx = CreateContext(); + var query = ctx.LevelOne.Include(x => x.OneToOne_Optional_FK1).Select(l1 => new { foo = l1, bar = l1 }).Distinct(); + + var result = query.ToList(); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_OrderBy(bool async) + [ConditionalFact] + public virtual void Include18() { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name), - assertOrder: true))); + using var ctx = CreateContext(); + var query = ctx.LevelOne + .Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1, bar = l1.OneToOne_Optional_PK1 }) + .OrderBy(x => x.foo.Id) + .Take(10); + + var result = query.ToList(); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_ThenInclude_OrderBy(bool async) + [ConditionalFact] + public virtual void Include19() { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2.OrderBy(x => x.Name)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.OrderBy(x => x.Name), - assertOrder: true))); + using var ctx = CreateContext(); + var query = ctx.LevelOne + .Include(x => x.OneToOne_Optional_FK1) + .Select(l1 => new { foo = l1.OneToOne_Optional_FK1, bar = l1.OneToOne_Optional_PK1 }) + .Distinct(); + + var result = query.ToList(); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_ThenInclude_OrderBy(bool async) + public virtual Task Include_with_all_method_include_gets_ignored(bool async) { - return AssertQuery( + return AssertAll( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name)) - .ThenInclude(l2 => l2.OneToMany_Optional2.OrderByDescending(x => x.Name)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name), - assertOrder: true), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.OrderByDescending(x => x.Name), - assertOrder: true))); + ss => ss.Set().Include(l1 => l1.OneToOne_Optional_FK1).Include(l1 => l1.OneToMany_Optional1), + predicate: l1 => l1.Name != "Foo"); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Take(bool async) + public virtual Task Join_with_navigations_in_the_result_selector1(bool async) { return AssertQuery( async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Take(3)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Take(3), - assertOrder: true))); + ss => ss.Set().Join( + ss.Set(), l1 => l1.Id, l2 => l2.Level1_Required_Id, (o, i) => new { o.OneToOne_Optional_FK1, i })); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Skip(bool async) + [ConditionalFact] + public virtual void Join_with_navigations_in_the_result_selector2() { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Skip(1), - assertOrder: true))); + using var ctx = CreateContext(); + var query = ctx.LevelOne.Join( + ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, + (o, i) => new { o.OneToOne_Optional_FK1, i.OneToMany_Optional2 }); + var result = query.ToList(); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_basic_OrderBy_Skip_Take(bool async) + [ConditionalFact(Skip = "issue #12200")] + public virtual void GroupJoin_with_navigations_in_the_result_selector() { - return AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Name).Skip(1).Take(3)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.OrderBy(x => x.Name).Skip(1).Take(3), - assertOrder: true))); + using var ctx = CreateContext(); + var query = ctx.LevelOne.GroupJoin( + ctx.LevelTwo, l1 => l1.Id, l2 => l2.Level1_Required_Id, (o, i) => new { o.OneToOne_Optional_FK1, i }); + var result = query.ToList(); } [ConditionalFact] - public virtual void Filtered_include_Skip_without_OrderBy() + public virtual void Member_pushdown_chain_3_levels_deep() { using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Skip(1)); + var query = from l1 in ctx.LevelOne + orderby l1.Id + where (from l2 in ctx.LevelTwo + orderby l2.Id + where l2.Level1_Optional_Id == l1.Id + select (from l3 in ctx.LevelThree + orderby l3.Id + where l3.Level2_Required_Id == l2.Id + select (from l4 in ctx.LevelFour + where l4.Level3_Required_Id == l3.Id + orderby l4.Id + select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault().Name + != "Foo" + select l1; + var result = query.ToList(); } [ConditionalFact] - public virtual void Filtered_include_Take_without_OrderBy() + public virtual void Member_pushdown_chain_3_levels_deep_entity() { using var ctx = CreateContext(); - var query = ctx.LevelOne.Include(l1 => l1.OneToMany_Optional1.Take(1)); + var query = from l1 in ctx.LevelOne + orderby l1.Id + select (from l2 in ctx.LevelTwo + orderby l2.Id + where l2.Level1_Optional_Id == l1.Id + select (from l3 in ctx.LevelThree + orderby l3.Id + where l3.Level2_Required_Id == l2.Id + select (from l4 in ctx.LevelFour + where l4.Level3_Required_Id == l3.Id + orderby l4.Id + select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault(); + var result = query.ToList(); } - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_on_ThenInclude(bool async) + [ConditionalFact] + public virtual void Member_pushdown_with_collection_navigation_in_the_middle() { - return AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToOne_Optional_FK1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToOne_Optional_FK1", - x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3), - assertOrder: true))); + using var ctx = CreateContext(); + var query = from l1 in ctx.LevelOne + orderby l1.Id + select (from l2 in ctx.LevelTwo + orderby l2.Id + where l2.Level1_Required_Id == l1.Id + select l2.OneToMany_Optional2.Select( + l3 => (from l4 in ctx.LevelFour + where l4.Level3_Required_Id == l3.Id + orderby l4.Id + select l4).FirstOrDefault()).FirstOrDefault()).FirstOrDefault().Name; + + var result = query.ToList(); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_reference_navigation(bool async) + public virtual Task Member_pushdown_with_multiple_collections(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include( - l1 => l1.OneToOne_Optional_FK1.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1) - .Take(3)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToOne_Optional_FK1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToOne_Optional_FK1", - x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Skip(1).Take(3), - assertOrder: true))); + ss => ss.Set().Select( + l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().OneToMany_Optional2.OrderBy(l3 => l3.Id) + .FirstOrDefault().Name), + ss => ss.Set().Select( + l1 => l1.OneToMany_Optional1.OrderBy(l2 => l2.Id).FirstOrDefault().Maybe( + x => x.OneToMany_Optional2.OrderBy(l3 => l3.Id) + .FirstOrDefault().Maybe(xx => xx.Name)))); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_different_filtered_include_same_level(bool async) + public virtual Task Include_multiple_collections_on_same_level(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) - .Include(l1 => l1.OneToMany_Required1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)), + ss => ss.Set().Include(l1 => l1.OneToMany_Optional1).Include(l1 => l1.OneToMany_Required1), elementAsserter: (e, a) => AssertInclude( e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3), - assertOrder: true), - new ExpectedFilteredInclude( - e => e.OneToMany_Required1, - includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1), - assertOrder: true))); + new ExpectedInclude(l1 => l1.OneToMany_Optional1), + new ExpectedInclude(l1 => l1.OneToMany_Required1)), + assertOrder: true); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_after_different_filtered_include_different_level(bool async) + public virtual Task Null_check_removal_applied_recursively(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3)) - .ThenInclude(l2 => l2.OneToMany_Required2.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Name).Take(3), - assertOrder: true), - new ExpectedFilteredInclude( - e => e.OneToMany_Required2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Skip(1), - assertOrder: true))); + ss => ss.Set().Where( + l1 => + (((l1.OneToOne_Optional_FK1 == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2) + == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3) + == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) + == "L4 01")); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice(bool async) + public virtual Task Null_check_different_structure_does_not_remove_null_checks(bool async) { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar").OrderByDescending(x => x.Name).Take(3))))) - .Message; + return AssertQuery( + async, + ss => ss.Set().Where( + l1 => + (l1.OneToOne_Optional_FK1 == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2 == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3 == null + ? null + : l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2.OneToOne_Optional_FK3.Name) + == "L4 01")); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_different_filter_set_on_same_navigation_twice_multi_level(bool async) + public virtual Task Union_over_entities_with_different_nullability(bool async) { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo")).ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Bar")) - .ThenInclude(l2 => l2.OneToOne_Required_FK2)))) - .Message; + return AssertQueryScalar( + async, + ss => ss.Set() + .GroupJoin(ss.Set(), l1 => l1.Id, l2 => l2.Level1_Optional_Id, (l1, l2s) => new { l1, l2s }) + .SelectMany(g => g.l2s.DefaultIfEmpty(), (g, l2) => new { g.l1, l2 }) + .Concat( + ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) + .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) + .Where(e => e.l1.Equals(null))) + .Select(e => (int?)e.l1.Id), + ss => ss.Set() + .GroupJoin(ss.Set(), l1 => l1.Id, l2 => l2.Level1_Optional_Id, (l1, l2s) => new { l1, l2s }) + .SelectMany(g => g.l2s.DefaultIfEmpty(), (g, l2) => new { g.l1, l2 }) + .Concat( + ss.Set().GroupJoin(ss.Set(), l2 => l2.Level1_Optional_Id, l1 => l1.Id, (l2, l1s) => new { l2, l1s }) + .SelectMany(g => g.l1s.DefaultIfEmpty(), (g, l1) => new { l1, g.l2 }) + .Where(e => e.l1 == null)) + .Select(e => e.l1.MaybeScalar(x => x.Id))); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice(bool async) + public virtual Task Including_reference_navigation_and_projecting_collection_navigation_2(bool async) { return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderByDescending(x => x.Id).Take(2), - assertOrder: true))); + .Include(e => e.OneToOne_Required_FK1) + .Include(e => e.OneToMany_Required1) + .Select(e => new { e, First = e.OneToMany_Required1.OrderByDescending(e => e.Id).FirstOrDefault() })); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + public virtual Task OrderBy_collection_count_ThenBy_reference_navigation(bool async) { return AssertQuery( async, ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToOne_Required_FK2), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2), - assertOrder: true), - new ExpectedInclude(e => e.OneToMany_Optional2), - new ExpectedInclude(e => e.OneToOne_Required_FK2))); + .OrderBy(l1 => l1.OneToOne_Required_FK1.OneToMany_Required2.Count()) + .ThenBy(l1 => l1.OneToOne_Required_FK1.OneToOne_Required_FK2.Name), + ss => ss.Set() + .OrderBy(l1 => l1.OneToOne_Required_FK1.OneToMany_Required2.MaybeScalar(x => x.Count()) ?? 0) + .ThenBy(l1 => l1.OneToOne_Required_FK1.OneToOne_Required_FK2.Name), + assertOrder: true); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( - bool async) + public virtual Task Null_conditional_is_not_applied_explicitly_for_optional_navigation(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2)) - .ThenInclude(l2 => l2.OneToMany_Optional2) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToOne_Required_FK2), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(2), - assertOrder: true), - new ExpectedInclude(e => e.OneToMany_Optional2, "OneToMany_Optional1"), - new ExpectedInclude(e => e.OneToOne_Required_FK2, "OneToMany_Optional1"))); + ss => ss.Set().Where(l1 => l1.OneToOne_Optional_FK1 != null && l1.OneToOne_Optional_FK1.Name == "L2 01")); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) + public virtual Task Sum_with_selector_cast_using_as(bool async) { - return AssertQuery( + return AssertSum( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3), - assertOrder: true))); + ss => ss.Set().Select(s => s.Id as int?)); } - [ConditionalTheory] + [ConditionalTheory(Skip = "Issue#12657")] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_on_same_navigation2(bool async) + public virtual Task Sum_with_filter_with_include_selector_cast_using_as(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3)) - .Include(l1 => l1.OneToMany_Optional1), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(3), - assertOrder: true))); + ss => ss.Set().Where(l1 => l1.Id > l1.OneToMany_Optional1.Select(l2 => l2.Id as int?).Sum())); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + public virtual Task Select_with_joined_where_clause_cast_using_as(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToOne_Optional_PK2.OneToMany_Optional3.Where(x => x.Id > 1)), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedFilteredInclude( - e => e.OneToMany_Optional1, - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1), - assertOrder: true), - new ExpectedInclude(e => e.OneToOne_Optional_PK2, "OneToMany_Optional1"), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional3, - "OneToMany_Optional1.OneToOne_Optional_PK2", - includeFilter: x => x.Where(x => x.Id > 1)))); + ss => ss.Set().Where(w => w.Id == w.OneToOne_Optional_FK1.Id as int?)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + public virtual Task SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Required3), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1), - assertOrder: true), - new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); + ss => from l1 in ss.Set() + join l2 in ss.Set() on l1.Id equals l2.Level1_Required_Id + join l3 in ss.Set() on l2.Id equals l3.Level2_Required_Id + join l4 in ss.Set() on l3.Id equals l4.Level3_Required_Id + from other in ss.Set().Where(x => x.Id <= l2.Id && x.Name == l4.Name).DefaultIfEmpty() + select l1); } - [ConditionalTheory] + [ConditionalTheory(Skip = "issue #19095")] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + public virtual Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async) { return AssertQuery( async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.OneToMany_Optional2.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1)) - .ThenInclude(l3 => l3.OneToMany_Optional3) - .Include(l1 => l1.OneToMany_Optional1).ThenInclude(l2 => l2.OneToMany_Optional2) - .ThenInclude(l3 => l3.OneToMany_Required3), - elementAsserter: (e, a) => AssertInclude( - e, a, - new ExpectedInclude(e => e.OneToMany_Optional1), - new ExpectedFilteredInclude( - e => e.OneToMany_Optional2, - "OneToMany_Optional1", - includeFilter: x => x.Where(x => x.Name != "Foo").OrderBy(x => x.Id).Take(1), - assertOrder: true), - new ExpectedInclude(e => e.OneToMany_Optional3, "OneToMany_Optional1.OneToMany_Optional2"), - new ExpectedInclude(e => e.OneToMany_Required3, "OneToMany_Optional1.OneToMany_Optional2"))); - } - - [ConditionalFact] - public virtual void Filtered_include_variable_used_inside_filter() - { - using var ctx = CreateContext(); - var prm = "Foo"; - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => x.Name != prm).OrderBy(x => x.Id).Take(3)); - var result = query.ToList(); + ss => ss.Set().SelectMany( + l1 => l1.OneToMany_Optional1.DefaultIfEmpty().SelectMany( + l2 => l2.OneToOne_Required_PK2.OneToMany_Optional3.DefaultIfEmpty() + .Select( + l4 => new + { + l1Name = l1.Name, + l2Name = l2.OneToOne_Required_PK2.Name, + l3Name = l4.OneToOne_Optional_PK_Inverse4.Name + })))); } [ConditionalFact] - public virtual void Filtered_include_context_accessed_inside_filter() + public virtual void Contains_over_optional_navigation_with_null_constant() { using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count() > 7).OrderBy(x => x.Id).Take(3)); - var result = query.ToList(); - } + var result = ctx.Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null); + var expected = Fixture.GetExpectedData().Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null); - [ConditionalFact] - public virtual void Filtered_include_context_accessed_inside_filter_correlated() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne - .Include(l1 => l1.OneToMany_Optional1.Where(x => ctx.LevelOne.Count(xx => xx.Id != x.Id) > 1).OrderBy(x => x.Id).Take(3)); - var result = query.ToList(); + Assert.Equal(expected, result); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_include_parameter_used_inside_filter_throws(bool async) + public virtual Task Contains_over_optional_navigation_with_null_parameter(bool async) { - await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Select(l1 => ss.Set().Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l2.Id))))); + return AssertSingleResult( + async, + ss => ss.Set().Select(l1 => l1.OneToOne_Optional_FK1).Contains(null), + ss => ss.Set().Select(l1 => l1.OneToOne_Optional_FK1).ContainsAsync(null, default)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual Task Filtered_include_outer_parameter_used_inside_filter(bool async) + public virtual Task Contains_over_optional_navigation_with_null_column(bool async) { return AssertQuery( async, ss => ss.Set().Select( - l1 => new - { - l1.Id, - FullInclude = ss.Set().Include(l2 => l2.OneToMany_Optional2).ToList(), - FilteredInclude = ss.Set().Include(l2 => l2.OneToMany_Optional2.Where(x => x.Id != l1.Id)).ToList() - }), - elementSorter: e => e.Id, - elementAsserter: (e, a) => - { - Assert.Equal(e.Id, a.Id); - AssertInclude(e.FullInclude, a.FullInclude, new ExpectedInclude(x => x.OneToMany_Optional2)); - AssertInclude( - e.FilteredInclude, - a.FilteredInclude, - new ExpectedFilteredInclude( - x => x.OneToMany_Optional2, - includeFilter: x => x.Where(x => x.Id != e.Id))); - }); - } - - [ConditionalFact] - public virtual void Filtered_include_is_considered_loaded() - { - using var ctx = CreateContext(); - var query = ctx.LevelOne.AsTracking().Include(l1 => l1.OneToMany_Optional1.OrderBy(x => x.Id).Take(1)); - var result = query.ToList(); - foreach (var resultElement in result) - { - var entry = ctx.Entry(resultElement); - Assert.True(entry.Navigation("OneToMany_Optional1").IsLoaded); - } - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_with_Distinct_throws(bool async) - { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set().Include(l1 => l1.OneToMany_Optional1.Distinct())))).Message; + l1 => new + { + l1.Name, + OptionalName = l1.OneToOne_Optional_FK1.Name, + Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1.Name).Contains(l1.OneToOne_Optional_FK1.Name) + }), + elementSorter: e => (e.Name, e.OptionalName, e.Contains)); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] - public virtual async Task Filtered_include_calling_methods_directly_on_parameter_throws(bool async) + public virtual Task Contains_over_optional_navigation_with_null_entity_reference(bool async) { - var message = (await Assert.ThrowsAsync( - () => AssertQuery( - async, - ss => ss.Set() - .Include(l1 => l1.OneToMany_Optional1) - .ThenInclude(l2 => l2.AsQueryable().Where(xx => xx.Id != 42))))).Message; + return AssertQuery( + async, + ss => ss.Set().Select( + l1 => new + { + l1.Name, + OptionalName = l1.OneToOne_Optional_FK1.Name, + Contains = ss.Set().Select(x => x.OneToOne_Optional_FK1).Contains(l1.OneToOne_Optional_PK1) + }), + elementSorter: e => (e.Name, e.OptionalName, e.Contains)); } [ConditionalTheory] @@ -5877,63 +4076,6 @@ join l3 in ss.Set() on l2.Id equals l3.Level2_Optional_Id elementSorter: e => (e.Foo, e.Bar, e.Baz)); } - [ConditionalTheory(Skip = "issue #23302")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Queryable_in_subquery_works_when_final_projection_is_List(bool async) - { - return AssertQuery( - async, - ss => from l1 in ss.Set() - orderby l1.Id - let inner = (from l2 in l1.OneToMany_Optional1 - where l2.Name != "Foo" - let innerL1s = from innerL1 in ss.Set() - where innerL1.OneToMany_Optional1.Any(innerL2 => innerL2.Id == l2.Id) - select innerL1.Name - select innerL1s).FirstOrDefault() - select inner.ToList(), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e, a)); - } - - [ConditionalTheory(Skip = "issue #23303")] - [MemberData(nameof(IsAsyncData))] - public virtual Task Complex_query_with_let_collection_projection_FirstOrDefault_with_ToList_on_inner_and_outer(bool async) - { - return AssertQuery( - async, - ss => from l1 in ss.Set() - orderby l1.Id - let inner = (from l2 in l1.OneToMany_Optional1 - where l2.Name != "Foo" - let innerL1s = from innerL1 in ss.Set() - where innerL1.OneToMany_Optional1.Any(innerL2 => innerL2.Id == l2.Id) - select innerL1.Name - select innerL1s.ToList()).FirstOrDefault() - select inner.ToList(), - assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e, a)); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) - { - return AssertQuery( - async, - ss => from l1 in ss.Set() - orderby l1.Id - let inner = (from l2 in l1.OneToMany_Optional1 - where l2.Name != "Foo" - let innerL1s = from innerL1 in ss.Set() - where innerL1.OneToMany_Optional1.Any(innerL2 => innerL2.Id == l2.Id) - select innerL1.Name - select innerL1s.ToList()).FirstOrDefault() - select inner, - assertOrder: true, - elementAsserter: (e, a) => AssertCollection(e, a)); - } - [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public virtual async Task Project_shadow_properties(bool async) @@ -6064,110 +4206,5 @@ await AssertQuery( }, elementSorter: e => e.Id); } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) - { - return AssertQuery( - async, - ss => from l4 in ss.Set().SelectMany(l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) - join l2 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2.DefaultIfEmpty()) on l4.Id equals l2.Id - join l3 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) on l2.Id equals l3.Id into grouping - from l3 in grouping.DefaultIfEmpty() - where l4.OneToMany_Optional_Inverse4.Name != "Foo" - orderby l2.OneToOne_Optional_FK2.Id - select new { Entity = l4, Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name }, - ss => from l4 in ss.Set().SelectMany(l1 => l1.OneToOne_Required_FK1.OneToOne_Optional_FK2.OneToMany_Required3.DefaultIfEmpty()) - join l2 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Optional_FK_Inverse3.OneToMany_Required_Self2.DefaultIfEmpty()) on l4.Id equals l2.Id - join l3 in ss.Set().SelectMany(l4 => l4.OneToOne_Required_FK_Inverse4.OneToOne_Required_FK_Inverse3.OneToMany_Required2.DefaultIfEmpty()) on l2.Id equals l3.Id into grouping - from l3 in grouping.DefaultIfEmpty() - where l4.OneToMany_Optional_Inverse4.Name != "Foo" - orderby l2.OneToOne_Optional_FK2.MaybeScalar(e => e.Id) - select new { Entity = l4, Collection = l2.OneToMany_Optional_Self2.Where(e => e.Id != 42).ToList(), Property = l3.OneToOne_Optional_FK_Inverse3.OneToOne_Required_FK2.Name }, - assertOrder: true, - elementAsserter: (e, a) => - { - AssertEqual(e.Entity, a.Entity); - AssertCollection(e.Collection, a.Collection); - AssertEqual(e.Property, a.Property); - }); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Take_Select_collection_Take(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(l1 => l1.Id).Take(1) - .Select(l1 => new - { - Id = l1.Id, - Name = l1.Name, - Level2s = l1.OneToMany_Required1.OrderBy(l2 => l2.Id).Take(3) - .Select(l2 => new - { - Id = l2.Id, - Name = l2.Name, - Level1Id = EF.Property(l2, "OneToMany_Required_Inverse2Id"), - Level2Id = l2.Level1_Required_Id, - Level2 = l2.OneToOne_Required_FK_Inverse2 - }) - }), - assertOrder: true, - elementAsserter: (e, a) => - { - Assert.Equal(e.Id, a.Id); - Assert.Equal(e.Name, a.Name); - AssertCollection(e.Level2s, a.Level2s, ordered: true, - elementAsserter: (ee, aa) => - { - Assert.Equal(ee.Id, aa.Id); - Assert.Equal(ee.Name, aa.Name); - Assert.Equal(ee.Level1Id, aa.Level1Id); - Assert.Equal(ee.Level2Id, aa.Level2Id); - AssertEqual(ee.Level2, aa.Level2); - }); - }); - } - - [ConditionalTheory] - [MemberData(nameof(IsAsyncData))] - public virtual Task Skip_Take_Select_collection_Skip_Take(bool async) - { - return AssertQuery( - async, - ss => ss.Set().OrderBy(l1 => l1.Id).Skip(1).Take(1) - .Select(l1 => new - { - Id = l1.Id, - Name = l1.Name, - Level2s = l1.OneToMany_Required1.OrderBy(l2 => l2.Id).Skip(1).Take(3) - .Select(l2 => new - { - Id = l2.Id, - Name = l2.Name, - Level1Id = EF.Property(l2, "OneToMany_Required_Inverse2Id"), - Level2Id = l2.Level1_Required_Id, - Level2 = l2.OneToOne_Required_FK_Inverse2 - }) - }), - assertOrder: true, - elementAsserter: (e, a) => - { - Assert.Equal(e.Id, a.Id); - Assert.Equal(e.Name, a.Name); - AssertCollection(e.Level2s, a.Level2s, ordered: true, - elementAsserter: (ee, aa) => - { - Assert.Equal(ee.Id, aa.Id); - Assert.Equal(ee.Name, aa.Name); - Assert.Equal(ee.Level1Id, aa.Level1Id); - Assert.Equal(ee.Level2Id, aa.Level2Id); - AssertEqual(ee.Level2, aa.Level2); - }); - }); - } } } diff --git a/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs index 4ce86a3203b..ef4f5d15e44 100644 --- a/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs +++ b/test/EFCore.Specification.Tests/Query/ComplexNavigationsSharedTypeQueryTestBase.cs @@ -20,11 +20,6 @@ public override Task Join_navigation_self_ref(bool async) return Task.CompletedTask; } - public override Task Multiple_complex_includes_self_ref(bool async) - { - return Task.CompletedTask; - } - public override Task Join_condition_optimizations_applied_correctly_when_anonymous_type_with_multiple_properties(bool async) { return Task.CompletedTask; @@ -61,14 +56,6 @@ public override Task SelectMany_with_nested_navigations_and_additional_joins_out return base.SelectMany_with_nested_navigations_and_additional_joins_outside_of_SelectMany(async); } - [ConditionalTheory(Skip = "issue #13560")] - public override Task - Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) - { - return base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top( - async); - } - [ConditionalTheory(Skip = "Issue#16752")] public override Task Include8(bool async) { @@ -81,42 +68,6 @@ public override Task Include9(bool async) return base.Include9(async); } - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Include_collection_with_multiple_orderbys_complex(bool async) - { - return base.Include_collection_with_multiple_orderbys_complex(async); - } - - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Include_collection_with_multiple_orderbys_complex_repeated(bool async) - { - return base.Include_collection_with_multiple_orderbys_complex_repeated(async); - } - - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Include_collection_with_multiple_orderbys_complex_repeated_checked(bool async) - { - return base.Include_collection_with_multiple_orderbys_complex_repeated_checked(async); - } - - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Include_collection_with_multiple_orderbys_member(bool async) - { - return base.Include_collection_with_multiple_orderbys_member(async); - } - - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Include_collection_with_multiple_orderbys_methodcall(bool async) - { - return base.Include_collection_with_multiple_orderbys_methodcall(async); - } - - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Include_collection_with_multiple_orderbys_property(bool async) - { - return base.Include_collection_with_multiple_orderbys_property(async); - } - [ConditionalTheory(Skip = "Issue#17803")] public override Task Member_pushdown_with_multiple_collections(bool async) { @@ -143,18 +94,6 @@ public override void Member_pushdown_with_collection_navigation_in_the_middle() public override Task Union_over_entities_with_different_nullability(bool async) => Task.CompletedTask; - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Include_inside_subquery(bool async) - { - return base.Include_inside_subquery(async); - } - - [ConditionalTheory(Skip = "Issue#16752")] - public override Task Filtered_include_outer_parameter_used_inside_filter(bool async) - { - return base.Filtered_include_outer_parameter_used_inside_filter(async); - } - [ConditionalTheory(Skip = "Issue#17803")] public override Task Multiple_collection_FirstOrDefault_followed_by_member_access_in_projection(bool async) { @@ -163,11 +102,5 @@ public override Task Multiple_collection_FirstOrDefault_followed_by_member_acces public override Task Project_shadow_properties(bool async) => Task.CompletedTask; - - public override Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) - { - // Navigations used are not mapped in shared type. - return Task.CompletedTask; - } } } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqlServerTest.cs new file mode 100644 index 00000000000..e21022ac324 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqlServerTest.cs @@ -0,0 +1,1828 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Xunit.Abstractions; + +// ReSharper disable InconsistentNaming +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsQuerySqlServerTest : ComplexNavigationsCollectionsQueryRelationalTestBase + { + public ComplexNavigationsCollectionsQuerySqlServerTest( + ComplexNavigationsQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(bool async) + { + await base.Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times(bool async) + { + await base.Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Id00], [t0].[Date0], [t0].[Level1_Optional_Id0], [t0].[Level1_Required_Id0], [t0].[Name00], [t0].[OneToMany_Optional_Inverse2Id0], [t0].[OneToMany_Optional_Self_Inverse2Id0], [t0].[OneToMany_Required_Inverse2Id0], [t0].[OneToMany_Required_Self_Inverse2Id0], [t0].[OneToOne_Optional_PK_Inverse2Id0], [t0].[OneToOne_Optional_Self2Id0], [t0].[Id1], [t0].[Level2_Optional_Id0], [t0].[Level2_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse3Id0], [t0].[OneToMany_Optional_Self_Inverse3Id0], [t0].[OneToMany_Required_Inverse3Id0], [t0].[OneToMany_Required_Self_Inverse3Id0], [t0].[OneToOne_Optional_PK_Inverse3Id0], [t0].[OneToOne_Optional_Self3Id0] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id] AS [Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name] AS [Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id0] AS [Id00], [t].[Date] AS [Date0], [t].[Level1_Optional_Id] AS [Level1_Optional_Id0], [t].[Level1_Required_Id] AS [Level1_Required_Id0], [t].[Name0] AS [Name00], [t].[OneToMany_Optional_Inverse2Id] AS [OneToMany_Optional_Inverse2Id0], [t].[OneToMany_Optional_Self_Inverse2Id] AS [OneToMany_Optional_Self_Inverse2Id0], [t].[OneToMany_Required_Inverse2Id] AS [OneToMany_Required_Inverse2Id0], [t].[OneToMany_Required_Self_Inverse2Id] AS [OneToMany_Required_Self_Inverse2Id0], [t].[OneToOne_Optional_PK_Inverse2Id] AS [OneToOne_Optional_PK_Inverse2Id0], [t].[OneToOne_Optional_Self2Id] AS [OneToOne_Optional_Self2Id0], [t].[Id1], [t].[Level2_Optional_Id0], [t].[Level2_Required_Id0], [t].[Name1], [t].[OneToMany_Optional_Inverse3Id0], [t].[OneToMany_Optional_Self_Inverse3Id0], [t].[OneToMany_Required_Inverse3Id0], [t].[OneToMany_Required_Self_Inverse3Id0], [t].[OneToOne_Optional_PK_Inverse3Id0], [t].[OneToOne_Optional_Self3Id0] + FROM [LevelTwo] AS [l0] + LEFT JOIN ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id0], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name] AS [Name0], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id1], [l3].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l3].[Level2_Required_Id] AS [Level2_Required_Id0], [l3].[Name] AS [Name1], [l3].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l3].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l3].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l3].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l3].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l3].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0] + FROM [LevelThree] AS [l1] + INNER JOIN [LevelTwo] AS [l2] ON [l1].[OneToMany_Required_Inverse3Id] = [l2].[Id] + LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[OneToMany_Optional_Inverse3Id] + ) AS [t] ON [l0].[Id] = [t].[OneToMany_Optional_Inverse3Id] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id00], [t0].[Id1]"); + } + + public override async Task Multiple_complex_includes(bool async) + { + await base.Multiple_complex_includes(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l2] + LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[Level2_Optional_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Multiple_complex_includes_self_ref(bool async) + { + await base.Multiple_complex_includes_self_ref(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [t].[Id0], [t].[Date0], [t].[Name0], [t].[OneToMany_Optional_Self_Inverse1Id0], [t].[OneToMany_Required_Self_Inverse1Id0], [t].[OneToOne_Optional_Self1Id0] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelOne] AS [l0] ON [l].[OneToOne_Optional_Self1Id] = [l0].[Id] +LEFT JOIN [LevelOne] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Self_Inverse1Id] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[Date], [l2].[Name], [l2].[OneToMany_Optional_Self_Inverse1Id], [l2].[OneToMany_Required_Self_Inverse1Id], [l2].[OneToOne_Optional_Self1Id], [l3].[Id] AS [Id0], [l3].[Date] AS [Date0], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Self_Inverse1Id] AS [OneToMany_Optional_Self_Inverse1Id0], [l3].[OneToMany_Required_Self_Inverse1Id] AS [OneToMany_Required_Self_Inverse1Id0], [l3].[OneToOne_Optional_Self1Id] AS [OneToOne_Optional_Self1Id0] + FROM [LevelOne] AS [l2] + LEFT JOIN [LevelOne] AS [l3] ON [l2].[OneToOne_Optional_Self1Id] = [l3].[Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Self_Inverse1Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Include_reference_and_collection_order_by(bool async) + { + await base.Include_reference_and_collection_order_by(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Include_reference_ThenInclude_collection_order_by(bool async) + { + await base.Include_reference_ThenInclude_collection_order_by(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Include_collection_then_reference(bool async) + { + await base.Include_collection_then_reference(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Include_collection_with_conditional_order_by(bool async) + { + await base.Include_collection_with_conditional_order_by(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY CASE + WHEN [l].[Name] IS NOT NULL AND ([l].[Name] LIKE N'%03') THEN 1 + ELSE 2 +END, [l].[Id], [l0].[Id]"); + } + + public override async Task Multiple_complex_include_select(bool async) + { + await base.Multiple_complex_include_select(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l2] + LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[Level2_Optional_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Include_nested_with_optional_navigation(bool async) + { + await base.Include_nested_with_optional_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id0], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id0], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name0], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] + FROM [LevelThree] AS [l1] + LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] +) AS [t] ON [l0].[Id] = [t].[OneToMany_Required_Inverse3Id] +WHERE ([l0].[Name] <> N'L2 09') OR [l0].[Name] IS NULL +ORDER BY [l].[Id], [l0].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Complex_multi_include_with_order_by_and_paging(bool async) + { + await base.Complex_multi_include_with_order_by_and_paging(async); + + AssertSql( + @"@__p_0='0' +@__p_1='10' + +SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id] +FROM ( + SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] + FROM [LevelOne] AS [l] + ORDER BY [l].[Name] + OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY +) AS [t] +LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Required_Inverse3Id] +ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); + } + + public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(bool async) + { + await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(async); + + AssertSql( + @"@__p_0='0' +@__p_1='10' + +SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id], [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] +FROM ( + SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] + FROM [LevelOne] AS [l] + ORDER BY [l].[Name] + OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY +) AS [t] +LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] +LEFT JOIN [LevelThree] AS [l3] ON [l1].[Id] = [l3].[OneToMany_Required_Inverse3Id] +ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id]"); + } + + public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(bool async) + { + await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(async); + + AssertSql( + @"@__p_0='0' +@__p_1='10' + +SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] +FROM ( + SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] + FROM [LevelOne] AS [l] + ORDER BY [l].[Name] + OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY +) AS [t] +LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] +LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] +ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); + } + + public override async Task Multiple_include_with_multiple_optional_navigations(bool async) + { + await base.Multiple_include_with_multiple_optional_navigations(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id], [l5].[Id], [l5].[Level2_Optional_Id], [l5].[Level2_Required_Id], [l5].[Name], [l5].[OneToMany_Optional_Inverse3Id], [l5].[OneToMany_Optional_Self_Inverse3Id], [l5].[OneToMany_Required_Inverse3Id], [l5].[OneToMany_Required_Self_Inverse3Id], [l5].[OneToOne_Optional_PK_Inverse3Id], [l5].[OneToOne_Optional_Self3Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Optional_Self_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToMany_Required_Self_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id], [l3].[OneToOne_Optional_Self2Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Optional_Self_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToMany_Required_Self_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id], [l4].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] +LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[Level2_Optional_Id] +LEFT JOIN [LevelTwo] AS [l3] ON [l].[Id] = [l3].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Level2_Optional_Id] +LEFT JOIN [LevelThree] AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] +WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id], [l5].[Id]"); + } + + public override async Task SelectMany_with_Include1(bool async) + { + await base.SelectMany_with_Include1(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Orderby_SelectMany_with_Include1(bool async) + { + await base.Orderby_SelectMany_with_Include1(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task SelectMany_with_Include2(bool async) + { + await base.SelectMany_with_Include2(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id]"); + } + + public override async Task SelectMany_with_Include_ThenInclude(bool async) + { + await base.SelectMany_with_Include_ThenInclude(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l].[Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] +LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); + } + + public override async Task Multiple_SelectMany_with_Include(bool async) + { + await base.Multiple_SelectMany_with_Include(async); + + AssertSql( + @"SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [l3].[Id], [l3].[Level3_Optional_Id], [l3].[Level3_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse4Id], [l3].[OneToMany_Optional_Self_Inverse4Id], [l3].[OneToMany_Required_Inverse4Id], [l3].[OneToMany_Required_Self_Inverse4Id], [l3].[OneToOne_Optional_PK_Inverse4Id], [l3].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] +LEFT JOIN [LevelFour] AS [l3] ON [l1].[Id] = [l3].[OneToMany_Optional_Inverse4Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id]"); + } + + public override async Task Required_navigation_with_Include(bool async) + { + await base.Required_navigation_with_Include(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] +FROM [LevelThree] AS [l1] +INNER JOIN [LevelTwo] AS [l] ON [l1].[Level2_Required_Id] = [l].[Id] +INNER JOIN [LevelOne] AS [l0] ON [l].[OneToMany_Required_Inverse2Id] = [l0].[Id]"); + } + + public override async Task Required_navigation_with_Include_ThenInclude(bool async) + { + await base.Required_navigation_with_Include_ThenInclude(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Level2_Optional_Id], [l].[Level2_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse3Id], [l].[OneToMany_Optional_Self_Inverse3Id], [l].[OneToMany_Required_Inverse3Id], [l].[OneToMany_Required_Self_Inverse3Id], [l].[OneToOne_Optional_PK_Inverse3Id], [l].[OneToOne_Optional_Self3Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id] +FROM [LevelFour] AS [l2] +INNER JOIN [LevelThree] AS [l] ON [l2].[Level3_Required_Id] = [l].[Id] +INNER JOIN [LevelTwo] AS [l0] ON [l].[OneToMany_Required_Inverse3Id] = [l0].[Id] +LEFT JOIN [LevelOne] AS [l1] ON [l0].[OneToMany_Optional_Inverse2Id] = [l1].[Id]"); + } + + public override async Task Optional_navigation_with_Include_ThenInclude(bool async) + { + await base.Optional_navigation_with_Include_ThenInclude(async); + + AssertSql( + @"SELECT [l1.OneToOne_Optional_FK1].[Id], [l1.OneToOne_Optional_FK1].[Date], [l1.OneToOne_Optional_FK1].[Level1_Optional_Id], [l1.OneToOne_Optional_FK1].[Level1_Required_Id], [l1.OneToOne_Optional_FK1].[Name], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_PK_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l1] +LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] +ORDER BY [l1.OneToOne_Optional_FK1].[Id]", + // + @"SELECT [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Name], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_Self3Id], [l.OneToOne_Optional_FK3].[Id], [l.OneToOne_Optional_FK3].[Level3_Optional_Id], [l.OneToOne_Optional_FK3].[Level3_Required_Id], [l.OneToOne_Optional_FK3].[Name], [l.OneToOne_Optional_FK3].[OneToMany_Optional_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToMany_Optional_Self_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToMany_Required_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToMany_Required_Self_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToOne_Optional_PK_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToOne_Optional_Self4Id] +FROM [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToMany_Optional2] +LEFT JOIN [LevelFour] AS [l.OneToOne_Optional_FK3] ON [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Id] = [l.OneToOne_Optional_FK3].[Level3_Optional_Id] +INNER JOIN ( + SELECT DISTINCT [l1.OneToOne_Optional_FK10].[Id] + FROM [LevelOne] AS [l10] + LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] +) AS [t] ON [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id] = [t].[Id] +ORDER BY [t].[Id]"); + } + + public override async Task Multiple_optional_navigation_with_Include(bool async) + { + await base.Multiple_optional_navigation_with_Include(async); + + AssertSql( + @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l1] +LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2] ON [l1.OneToOne_Optional_FK1].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id] +ORDER BY [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id]", + // + @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] +FROM [LevelFour] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3] +INNER JOIN ( + SELECT DISTINCT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[Id] + FROM [LevelOne] AS [l10] + LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] + LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20] ON [l1.OneToOne_Optional_FK10].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[OneToOne_Optional_PK_Inverse3Id] +) AS [t] ON [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] = [t].[Id] +ORDER BY [t].[Id]"); + } + + public override async Task Multiple_optional_navigation_with_string_based_Include(bool async) + { + await base.Multiple_optional_navigation_with_string_based_Include(async); + + AssertSql( + @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l1] +LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2] ON [l1.OneToOne_Optional_FK1].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id] +ORDER BY [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id]", + // + @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] +FROM [LevelFour] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3] +INNER JOIN ( + SELECT DISTINCT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[Id] + FROM [LevelOne] AS [l10] + LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] + LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20] ON [l1.OneToOne_Optional_FK10].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[OneToOne_Optional_PK_Inverse3Id] +) AS [t] ON [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] = [t].[Id] +ORDER BY [t].[Id]"); + } + + public override async Task Optional_navigation_with_order_by_and_Include(bool async) + { + await base.Optional_navigation_with_order_by_and_Include(async); + + AssertSql( + @"SELECT [l1.OneToOne_Optional_FK1].[Id], [l1.OneToOne_Optional_FK1].[Date], [l1.OneToOne_Optional_FK1].[Level1_Optional_Id], [l1.OneToOne_Optional_FK1].[Level1_Required_Id], [l1.OneToOne_Optional_FK1].[Name], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_PK_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l1] +LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] +ORDER BY [l1.OneToOne_Optional_FK1].[Name], [l1.OneToOne_Optional_FK1].[Id]", + // + @"SELECT [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Name], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_Self3Id] +FROM [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToMany_Optional2] +INNER JOIN ( + SELECT DISTINCT [l1.OneToOne_Optional_FK10].[Id], [l1.OneToOne_Optional_FK10].[Name] + FROM [LevelOne] AS [l10] + LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] +) AS [t] ON [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id] = [t].[Id] +ORDER BY [t].[Name], [t].[Id]"); + } + + public override async Task Optional_navigation_with_Include_and_order(bool async) + { + await base.Optional_navigation_with_Include_and_order(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l0] +LEFT JOIN [LevelTwo] AS [l] ON [l0].[Id] = [l].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Name], [l0].[Id]"); + } + + public override async Task SelectMany_with_order_by_and_Include(bool async) + { + await base.SelectMany_with_order_by_and_Include(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l0].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task SelectMany_with_Include_and_order_by(bool async) + { + await base.SelectMany_with_Include_and_order_by(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l0].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task SelectMany_with_navigation_and_Distinct(bool async) + { + await base.SelectMany_with_navigation_and_Distinct(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT DISTINCT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l0] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [l1].[Id]"); + } + + public override async Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) + { + await base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT DISTINCT [l0].[Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id] AS [FK] + FROM [LevelTwo] AS [l0] +) AS [t] ON [l].[Id] = [t].[FK] +LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [l1].[Id]"); + } + + public override async Task Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) + { + await base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(async); + + AssertSql( + @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l12].[Id], [l13].[Id], [l14].[Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l14].[Name] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] +LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Required_Inverse4Id] +INNER JOIN ( + SELECT [l3].[Id], [l4].[Id] AS [Id0], [l5].[Id] AS [Id1], [l6].[Id] AS [Id2] + FROM [LevelFour] AS [l3] + INNER JOIN [LevelThree] AS [l4] ON [l3].[Level3_Required_Id] = [l4].[Id] + LEFT JOIN [LevelTwo] AS [l5] ON [l4].[Level2_Optional_Id] = [l5].[Id] + LEFT JOIN [LevelTwo] AS [l6] ON [l5].[Id] = [l6].[OneToMany_Required_Self_Inverse2Id] +) AS [t] ON [l2].[Id] = [t].[Id2] +LEFT JOIN ( + SELECT [l7].[Id], [l8].[Id] AS [Id0], [l9].[Id] AS [Id1], [l10].[Id] AS [Id2], [l10].[Level2_Optional_Id] AS [Level2_Optional_Id0] + FROM [LevelFour] AS [l7] + INNER JOIN [LevelThree] AS [l8] ON [l7].[Level3_Required_Id] = [l8].[Id] + INNER JOIN [LevelTwo] AS [l9] ON [l8].[Level2_Required_Id] = [l9].[Id] + LEFT JOIN [LevelThree] AS [l10] ON [l9].[Id] = [l10].[OneToMany_Required_Inverse3Id] +) AS [t0] ON [t].[Id2] = [t0].[Id2] +LEFT JOIN [LevelThree] AS [l11] ON [l2].[OneToMany_Optional_Inverse4Id] = [l11].[Id] +LEFT JOIN [LevelThree] AS [l12] ON [t].[Id2] = [l12].[Level2_Optional_Id] +LEFT JOIN [LevelTwo] AS [l13] ON [t0].[Level2_Optional_Id0] = [l13].[Id] +LEFT JOIN [LevelThree] AS [l14] ON [l13].[Id] = [l14].[Level2_Required_Id] +LEFT JOIN ( + SELECT [l15].[Id], [l15].[Date], [l15].[Level1_Optional_Id], [l15].[Level1_Required_Id], [l15].[Name], [l15].[OneToMany_Optional_Inverse2Id], [l15].[OneToMany_Optional_Self_Inverse2Id], [l15].[OneToMany_Required_Inverse2Id], [l15].[OneToMany_Required_Self_Inverse2Id], [l15].[OneToOne_Optional_PK_Inverse2Id], [l15].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l15] + WHERE [l15].[Id] <> 42 +) AS [t1] ON [t].[Id2] = [t1].[OneToMany_Optional_Self_Inverse2Id] +WHERE ([l11].[Name] <> N'Foo') OR [l11].[Name] IS NULL +ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id], [t1].[Id]"); + } + + public override async Task Project_collection_navigation(bool async) + { + await base.Project_collection_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id]"); + } + + public override async Task Project_collection_navigation_nested(bool async) + { + await base.Project_collection_navigation_nested(async); + + AssertSql( + @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Project_collection_navigation_using_ef_property(bool async) + { + await base.Project_collection_navigation_using_ef_property(async); + + AssertSql( + @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Project_collection_navigation_nested_anonymous(bool async) + { + await base.Project_collection_navigation_nested_anonymous(async); + + AssertSql( + @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Project_collection_navigation_composed(bool async) + { + await base.Project_collection_navigation_composed(async); + + AssertSql( + @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +WHERE [l].[Id] < 3 +ORDER BY [l].[Id], [t].[Id]"); + } + + public override async Task Project_collection_and_root_entity(bool async) + { + await base.Project_collection_and_root_entity(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id]"); + } + + public override async Task Project_collection_and_include(bool async) + { + await base.Project_collection_and_include(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Project_navigation_and_collection(bool async) + { + await base.Project_navigation_and_collection(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Include_inside_subquery(bool async) + { + await base.Include_inside_subquery(async); + + AssertSql( + @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] + WHERE [l0].[Id] > 0 +) AS [t] +WHERE [l].[Id] < 3 +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Include_collection_with_multiple_orderbys_member(bool async) + { + await base.Include_collection_with_multiple_orderbys_member(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] +FROM [LevelTwo] AS [l] +LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Name], [l].[Level1_Required_Id], [l].[Id], [l0].[Id]"); + } + + public override async Task Include_collection_with_multiple_orderbys_property(bool async) + { + await base.Include_collection_with_multiple_orderbys_property(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] +FROM [LevelTwo] AS [l] +LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Level1_Required_Id], [l].[Name], [l].[Id], [l0].[Id]"); + } + + public override async Task Include_collection_with_multiple_orderbys_methodcall(bool async) + { + await base.Include_collection_with_multiple_orderbys_methodcall(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] +FROM [LevelTwo] AS [l] +LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] +ORDER BY ABS([l].[Level1_Required_Id]), [l].[Name], [l].[Id], [l0].[Id]"); + } + + public override async Task Include_collection_with_multiple_orderbys_complex(bool async) + { + await base.Include_collection_with_multiple_orderbys_complex(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] +FROM [LevelTwo] AS [l] +LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] +ORDER BY ABS([l].[Level1_Required_Id]) + 7, [l].[Name], [l].[Id], [l0].[Id]"); + } + + public override async Task Include_collection_with_multiple_orderbys_complex_repeated(bool async) + { + await base.Include_collection_with_multiple_orderbys_complex_repeated(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] +FROM [LevelTwo] AS [l] +LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] +ORDER BY -[l].[Level1_Required_Id], [l].[Name], [l].[Id], [l0].[Id]"); + } + + public override async Task Include_reference_collection_order_by_reference_navigation(bool async) + { + await base.Include_reference_collection_order_by_reference_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l0].[Id], [l].[Id], [l1].[Id]"); + } + + public override async Task Include_after_SelectMany_and_reference_navigation(bool async) + { + await base.Include_after_SelectMany_and_reference_navigation(async); + + AssertSql( + @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l1] +INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id] +ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id]", + // + @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] +FROM [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3] +INNER JOIN ( + SELECT DISTINCT [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id] + FROM [LevelOne] AS [l10] + INNER JOIN [LevelTwo] AS [l1.OneToMany_Required10] ON [l10].[Id] = [l1.OneToMany_Required10].[OneToMany_Required_Inverse2Id] + LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK20] ON [l1.OneToMany_Required10].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Level2_Optional_Id] +) AS [t] ON [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] = [t].[Id] +ORDER BY [t].[Id]"); + } + + public override async Task Include_after_multiple_SelectMany_and_reference_navigation(bool async) + { + await base.Include_after_multiple_SelectMany_and_reference_navigation(async); + + AssertSql( + @"SELECT [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Name], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l1] +INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] +INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToMany_Optional2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id] +LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3] ON [l1.OneToMany_Required1.OneToMany_Optional2].[Id] = [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Level3_Required_Id] +ORDER BY [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Id]", + // + @"SELECT [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Level3_Required_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Name], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToOne_Optional_Self4Id] +FROM [LevelFour] AS [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4] +INNER JOIN ( + SELECT DISTINCT [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK30].[Id] + FROM [LevelOne] AS [l10] + INNER JOIN [LevelTwo] AS [l1.OneToMany_Required10] ON [l10].[Id] = [l1.OneToMany_Required10].[OneToMany_Required_Inverse2Id] + INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToMany_Optional20] ON [l1.OneToMany_Required10].[Id] = [l1.OneToMany_Required1.OneToMany_Optional20].[OneToMany_Optional_Inverse3Id] + LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK30] ON [l1.OneToMany_Required1.OneToMany_Optional20].[Id] = [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK30].[Level3_Required_Id] +) AS [t] ON [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Required_Self_Inverse4Id] = [t].[Id] +ORDER BY [t].[Id]"); + } + + public override async Task Include_after_SelectMany_and_multiple_reference_navigations(bool async) + { + await base.Include_after_SelectMany_and_multiple_reference_navigations(async); + + AssertSql( + @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l1] +INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id] +LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3] ON [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Level3_Required_Id] +ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Id]", + // + @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToOne_Optional_Self4Id] +FROM [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4] +INNER JOIN ( + SELECT DISTINCT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK30].[Id] + FROM [LevelOne] AS [l10] + INNER JOIN [LevelTwo] AS [l1.OneToMany_Required10] ON [l10].[Id] = [l1.OneToMany_Required10].[OneToMany_Required_Inverse2Id] + LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK20] ON [l1.OneToMany_Required10].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Level2_Optional_Id] + LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK30] ON [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK30].[Level3_Required_Id] +) AS [t] ON [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Optional_Self_Inverse4Id] = [t].[Id] +ORDER BY [t].[Id]"); + } + + public override async Task Include_after_SelectMany_and_reference_navigation_with_another_SelectMany_with_Distinct(bool async) + { + await base.Include_after_SelectMany_and_reference_navigation_with_another_SelectMany_with_Distinct(async); + + AssertSql( + @"SELECT [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_Self3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l1] +INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id] +INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK20] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Level2_Optional_Id] +LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3] ON [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] +ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id]", + // + @"SELECT [l11].[Id], [l11].[Date], [l11].[Name], [l11].[OneToMany_Optional_Self_Inverse1Id], [l11].[OneToMany_Required_Self_Inverse1Id], [l11].[OneToOne_Optional_Self1Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToOne_Optional_Self4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK23].[Id] +FROM [LevelOne] AS [l11] +INNER JOIN [LevelTwo] AS [l1.OneToMany_Required11] ON [l11].[Id] = [l1.OneToMany_Required11].[OneToMany_Required_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK23] ON [l1.OneToMany_Required11].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK23].[Level2_Optional_Id] +INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK24] ON [l1.OneToMany_Required11].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK24].[Level2_Optional_Id] +LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32] ON [l1.OneToMany_Required1.OneToOne_Optional_FK24].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Optional_Inverse4Id] +ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK24].[Id]", + // + @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToOne_Optional_Self4Id] +FROM [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30]"); + } + + public override async Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) + { + await base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); + + AssertSql( + @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id], [t].[Id0] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT CASE + WHEN [l1].[Id] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [c], [l1].[Name], [l0].[Id], [l1].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task Null_check_in_Dto_projection_should_not_be_removed(bool async) + { + await base.Null_check_in_Dto_projection_should_not_be_removed(async); + + AssertSql( + @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id], [t].[Id0] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT CASE + WHEN [l1].[Id] IS NULL THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) + END AS [c], [l1].[Name], [l0].[Id], [l1].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); + } + + public override async Task SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) + { + await base.SelectMany_navigation_property_followed_by_select_collection_navigation(async); + + AssertSql( + @"SELECT [l0].[Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Multiple_SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) + { + await base.Multiple_SelectMany_navigation_property_followed_by_select_collection_navigation(async); + + AssertSql( + @"SELECT [l1].[Id], [l].[Id], [l0].[Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); + } + + public override async Task SelectMany_navigation_property_with_include_and_followed_by_select_collection_navigation(bool async) + { + await base.SelectMany_navigation_property_with_include_and_followed_by_select_collection_navigation(async); + + AssertSql( + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Required_Inverse3Id] +LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); + } + + public override void Include15() + { + base.Include15(); + + AssertSql( + @""); + } + + public override void Include16() + { + base.Include16(); + + AssertSql( + @""); + } + + public override void IncludeCollection1() + { + base.IncludeCollection1(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id]"); + } + + public override void IncludeCollection2() + { + base.IncludeCollection2(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); + } + + public override void IncludeCollection3() + { + base.IncludeCollection3(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override void IncludeCollection4() + { + base.IncludeCollection4(); + + AssertSql( + @"SELECT [l].[Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id]"); + } + + public override void IncludeCollection5() + { + base.IncludeCollection5(); + + AssertSql( + @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); + } + + public override void IncludeCollection6() + { + base.IncludeCollection6(); + + AssertSql( + @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] + LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); + } + + public override void IncludeCollection6_1() + { + base.IncludeCollection6_1(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] + LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); + } + + public override void IncludeCollection6_2() + { + base.IncludeCollection6_2(); + + AssertSql( + @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id], [t].[Id2], [t].[Level2_Optional_Id0], [t].[Level2_Required_Id0], [t].[Name2], [t].[OneToMany_Optional_Inverse3Id0], [t].[OneToMany_Optional_Self_Inverse3Id0], [t].[OneToMany_Required_Inverse3Id0], [t].[OneToMany_Required_Self_Inverse3Id0], [t].[OneToOne_Optional_PK_Inverse3Id0], [t].[OneToOne_Optional_Self3Id0], [t].[Id3], [t].[Level3_Optional_Id0], [t].[Level3_Required_Id0], [t].[Name3], [t].[OneToMany_Optional_Inverse4Id0], [t].[OneToMany_Optional_Self_Inverse4Id0], [t].[OneToMany_Required_Inverse4Id0], [t].[OneToMany_Required_Self_Inverse4Id0], [t].[OneToOne_Optional_PK_Inverse4Id0], [t].[OneToOne_Optional_Self4Id0] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l3].[Id] AS [Id2], [l3].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l3].[Level2_Required_Id] AS [Level2_Required_Id0], [l3].[Name] AS [Name2], [l3].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l3].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l3].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l3].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l3].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l3].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0], [l4].[Id] AS [Id3], [l4].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l4].[Level3_Required_Id] AS [Level3_Required_Id0], [l4].[Name] AS [Name3], [l4].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l4].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l4].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l4].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l4].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l4].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] + LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] + LEFT JOIN [LevelThree] AS [l3] ON [l0].[Id] = [l3].[Level2_Optional_Id] + LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[OneToMany_Optional_Inverse4Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t].[Id3]"); + } + + public override void IncludeCollection6_3() + { + base.IncludeCollection6_3(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id], [t].[Id2], [t].[Level2_Optional_Id0], [t].[Level2_Required_Id0], [t].[Name2], [t].[OneToMany_Optional_Inverse3Id0], [t].[OneToMany_Optional_Self_Inverse3Id0], [t].[OneToMany_Required_Inverse3Id0], [t].[OneToMany_Required_Self_Inverse3Id0], [t].[OneToOne_Optional_PK_Inverse3Id0], [t].[OneToOne_Optional_Self3Id0], [t].[Id3], [t].[Level3_Optional_Id0], [t].[Level3_Required_Id0], [t].[Name3], [t].[OneToMany_Optional_Inverse4Id0], [t].[OneToMany_Optional_Self_Inverse4Id0], [t].[OneToMany_Required_Inverse4Id0], [t].[OneToMany_Required_Self_Inverse4Id0], [t].[OneToOne_Optional_PK_Inverse4Id0], [t].[OneToOne_Optional_Self4Id0] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l3].[Id] AS [Id2], [l3].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l3].[Level2_Required_Id] AS [Level2_Required_Id0], [l3].[Name] AS [Name2], [l3].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l3].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l3].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l3].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l3].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l3].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0], [l4].[Id] AS [Id3], [l4].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l4].[Level3_Required_Id] AS [Level3_Required_Id0], [l4].[Name] AS [Name3], [l4].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l4].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l4].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l4].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l4].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l4].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] + LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] + LEFT JOIN [LevelThree] AS [l3] ON [l0].[Id] = [l3].[Level2_Optional_Id] + LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[OneToMany_Optional_Inverse4Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t].[Id3]"); + } + + public override void IncludeCollection6_4() + { + base.IncludeCollection6_4(); + + AssertSql( + @"SELECT [l].[Id], [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id0], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id], [t].[Id1] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id0], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name0], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l0].[Id] AS [Id1], [l0].[OneToMany_Optional_Inverse2Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] + LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id1], [t].[Id], [t].[Id0]"); + } + + public override void IncludeCollection7() + { + base.IncludeCollection7(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l2] + LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[OneToOne_Optional_PK_Inverse3Id] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t0].[Id], [t0].[Id0]"); + } + + public override async Task IncludeCollection8(bool async) + { + await base.IncludeCollection8(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id], [l4].[Id] AS [Id1], [l4].[Level3_Optional_Id], [l4].[Level3_Required_Id], [l4].[Name] AS [Name1], [l4].[OneToMany_Optional_Inverse4Id], [l4].[OneToMany_Optional_Self_Inverse4Id], [l4].[OneToMany_Required_Inverse4Id], [l4].[OneToMany_Required_Self_Inverse4Id], [l4].[OneToOne_Optional_PK_Inverse4Id], [l4].[OneToOne_Optional_Self4Id] + FROM [LevelTwo] AS [l2] + LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[OneToOne_Optional_PK_Inverse3Id] + LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[Level3_Optional_Id] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +WHERE ( + SELECT COUNT(*) + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] + WHERE ([l].[Id] = [l0].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL)) > 0 +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); + } + + public override async Task Lift_projection_mapping_when_pushing_down_subquery(bool async) + { + await base.Lift_projection_mapping_when_pushing_down_subquery(async); + + AssertSql( + @"@__p_0='25' + +SELECT [t].[Id], [t0].[Id], [t0].[c], [l1].[Id] +FROM ( + SELECT TOP(@__p_0) [l].[Id] + FROM [LevelOne] AS [l] +) AS [t] +LEFT JOIN ( + SELECT [t1].[Id], [t1].[c], [t1].[OneToMany_Required_Inverse2Id] + FROM ( + SELECT [l0].[Id], 1 AS [c], [l0].[OneToMany_Required_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Required_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t1] + WHERE [t1].[row] <= 1 +) AS [t0] ON [t].[Id] = [t0].[OneToMany_Required_Inverse2Id] +LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[OneToMany_Required_Inverse2Id] +ORDER BY [t].[Id], [t0].[Id], [l1].[Id]"); + } + + public override async Task Including_reference_navigation_and_projecting_collection_navigation(bool async) + { + await base.Including_reference_navigation_and_projecting_collection_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] +LEFT JOIN [LevelTwo] AS [l2] ON [l].[Id] = [l2].[OneToMany_Required_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); + } + + public override async Task LeftJoin_with_Any_on_outer_source_and_projecting_collection_from_inner(bool async) + { + await base.LeftJoin_with_Any_on_outer_source_and_projecting_collection_from_inner(async); + + AssertSql( + @"SELECT CASE + WHEN [l0].[Id] IS NULL THEN 0 + ELSE [l0].[Id] +END, [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Required_Inverse3Id] +WHERE [l].[Name] IN (N'L1 01', N'L1 02') +ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); + } + + public override async Task Select_subquery_single_nested_subquery(bool async) + { + await base.Select_subquery_single_nested_subquery(async); + + AssertSql( + @"SELECT [t1].[Id], [t1].[Id0], [t1].[c] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [t].[Id], [t0].[Id] AS [Id0], [t].[c] + FROM ( + SELECT TOP(1) 1 AS [c], [l0].[Id] + FROM [LevelTwo] AS [l0] + WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] + ORDER BY [l0].[Id] + ) AS [t] + LEFT JOIN ( + SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id] + FROM [LevelThree] AS [l1] + ) AS [t0] ON [t].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +) AS [t1] +ORDER BY [l].[Id]"); + } + + public override async Task Select_subquery_single_nested_subquery2(bool async) + { + await base.Select_subquery_single_nested_subquery2(async); + + AssertSql( + @"SELECT [l].[Id], [t2].[Id], [t2].[Id0], [t2].[c], [t2].[Id1] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t1].[Id], [t1].[Id0], [t1].[c], [l0].[Id] AS [Id1], [l0].[OneToMany_Optional_Inverse2Id] + FROM [LevelTwo] AS [l0] + OUTER APPLY ( + SELECT [t].[Id], [t0].[Id] AS [Id0], [t].[c] + FROM ( + SELECT TOP(1) 1 AS [c], [l1].[Id] + FROM [LevelThree] AS [l1] + WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN ( + SELECT [l2].[Id], [l2].[OneToMany_Optional_Inverse4Id] + FROM [LevelFour] AS [l2] + ) AS [t0] ON [t].[Id] = [t0].[OneToMany_Optional_Inverse4Id] + ) AS [t1] +) AS [t2] ON [l].[Id] = [t2].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t2].[Id1], [t2].[Id], [t2].[Id0]"); + } + + public override async Task Filtered_include_basic_Where(bool async) + { + await base.Filtered_include_basic_Where(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l0] + WHERE [l0].[Id] > 5 +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id]"); + } + + public override async Task Filtered_include_OrderBy(bool async) + { + await base.Filtered_include_OrderBy(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l0] +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Name], [t].[Id]"); + } + + public override async Task Filtered_ThenInclude_OrderBy(bool async) + { + await base.Filtered_ThenInclude_OrderBy(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id] AS [Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name] AS [Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelThree] AS [l1] + ) AS [t] ON [l0].[Id] = [t].[OneToMany_Optional_Inverse3Id] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[Name0], [t0].[Id0]"); + } + + public override async Task Filtered_include_ThenInclude_OrderBy(bool async) + { + await base.Filtered_include_ThenInclude_OrderBy(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id] AS [Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name] AS [Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelThree] AS [l1] + ) AS [t] ON [l0].[Id] = [t].[OneToMany_Optional_Inverse3Id] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[Name], [t0].[Id], [t0].[Name0] DESC, [t0].[Id0]"); + } + + public override async Task Filtered_include_basic_OrderBy_Take(bool async) + { + await base.Filtered_include_basic_OrderBy_Take(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id]"); + } + + public override async Task Filtered_include_basic_OrderBy_Skip(bool async) + { + await base.Filtered_include_basic_OrderBy_Skip(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE 1 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id]"); + } + + public override async Task Filtered_include_basic_OrderBy_Skip_Take(bool async) + { + await base.Filtered_include_basic_OrderBy_Skip_Take(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE (1 < [t].[row]) AND ([t].[row] <= 4) +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id]"); + } + + public override void Filtered_include_Skip_without_OrderBy() + { + base.Filtered_include_Skip_without_OrderBy(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE 1 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override void Filtered_include_Take_without_OrderBy() + { + base.Filtered_include_Take_without_OrderBy(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_on_ThenInclude(bool async) + { + await base.Filtered_include_on_ThenInclude(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE (1 < [t].[row]) AND ([t].[row] <= 4) +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name], [t0].[Id]"); + } + + public override async Task Filtered_include_after_reference_navigation(bool async) + { + await base.Filtered_include_after_reference_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE (1 < [t].[row]) AND ([t].[row] <= 4) +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name], [t0].[Id]"); + } + + public override async Task Filtered_include_after_different_filtered_include_same_level(bool async) + { + await base.Filtered_include_after_different_filtered_include_same_level(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +LEFT JOIN ( + SELECT [t2].[Id], [t2].[Date], [t2].[Level1_Optional_Id], [t2].[Level1_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse2Id], [t2].[OneToMany_Optional_Self_Inverse2Id], [t2].[OneToMany_Required_Inverse2Id], [t2].[OneToMany_Required_Self_Inverse2Id], [t2].[OneToOne_Optional_PK_Inverse2Id], [t2].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse2Id] ORDER BY [l1].[Name] DESC) AS [row] + FROM [LevelTwo] AS [l1] + WHERE ([l1].[Name] <> N'Bar') OR [l1].[Name] IS NULL + ) AS [t2] + WHERE 1 < [t2].[row] +) AS [t1] ON [l].[Id] = [t1].[OneToMany_Required_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[Name] DESC, [t1].[Id]"); + } + + public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) + { + await base.Filtered_include_after_different_filtered_include_different_level(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t2].[Id], [t2].[Date], [t2].[Level1_Optional_Id], [t2].[Level1_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse2Id], [t2].[OneToMany_Optional_Self_Inverse2Id], [t2].[OneToMany_Required_Inverse2Id], [t2].[OneToMany_Required_Self_Inverse2Id], [t2].[OneToOne_Optional_PK_Inverse2Id], [t2].[OneToOne_Optional_Self2Id], [t2].[Id0], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Name0], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Optional_Self_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToMany_Required_Self_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id], [t2].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t0].[Id] AS [Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name] AS [Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] + FROM ( + SELECT TOP(3) [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l0] + WHERE ([l].[Id] = [l0].[OneToMany_Optional_Inverse2Id]) AND (([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL) + ORDER BY [l0].[Name] + ) AS [t] + LEFT JOIN ( + SELECT [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Bar') OR [l1].[Name] IS NULL + ) AS [t1] + WHERE 1 < [t1].[row] + ) AS [t0] ON [t].[Id] = [t0].[OneToMany_Required_Inverse3Id] +) AS [t2] +ORDER BY [l].[Id], [t2].[Name], [t2].[Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[Name0] DESC, [t2].[Id0]"); + } + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice(bool async) + { + await base.Filtered_include_same_filter_set_on_same_navigation_twice(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id] DESC) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 2 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id] DESC"); + } + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + { + await base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Id1], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Level2_Optional_Id0], [t0].[Level2_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse3Id0], [t0].[OneToMany_Optional_Self_Inverse3Id0], [t0].[OneToMany_Required_Inverse3Id0], [t0].[OneToMany_Required_Self_Inverse3Id0], [t0].[OneToOne_Optional_PK_Inverse3Id0], [t0].[OneToOne_Optional_Self3Id0] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l1].[Id] AS [Id1], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l0].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l0].[Level2_Required_Id] AS [Level2_Required_Id0], [l0].[Name] AS [Name1], [l0].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l0].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l0].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l0].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l0].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l0].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0] + FROM ( + SELECT TOP(2) [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l2] + WHERE ([l].[Id] = [l2].[OneToMany_Optional_Inverse2Id]) AND (([l2].[Name] <> N'Foo') OR [l2].[Name] IS NULL) + ORDER BY [l2].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] + LEFT JOIN [LevelThree] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +) AS [t0] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id1]"); + } + + public override async Task + Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) + { + await base + .Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Id1], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Level2_Optional_Id0], [t0].[Level2_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse3Id0], [t0].[OneToMany_Optional_Self_Inverse3Id0], [t0].[OneToMany_Required_Inverse3Id0], [t0].[OneToMany_Required_Self_Inverse3Id0], [t0].[OneToOne_Optional_PK_Inverse3Id0], [t0].[OneToOne_Optional_Self3Id0] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l1].[Id] AS [Id1], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l0].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l0].[Level2_Required_Id] AS [Level2_Required_Id0], [l0].[Name] AS [Name1], [l0].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l0].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l0].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l0].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l0].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l0].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0] + FROM ( + SELECT TOP(2) [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l2] + WHERE ([l].[Id] = [l2].[OneToMany_Optional_Inverse2Id]) AND (([l2].[Name] <> N'Foo') OR [l2].[Name] IS NULL) + ORDER BY [l2].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] + LEFT JOIN [LevelThree] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +) AS [t0] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id1]"); + } + + public override async Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) + { + await base.Filtered_include_and_non_filtered_include_on_same_navigation1(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_and_non_filtered_include_on_same_navigation2(bool async) + { + await base.Filtered_include_and_non_filtered_include_on_same_navigation2(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + { + await base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [t1].[Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [t1].[Id1], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name1], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id], [t0].[Id] AS [Id1], [t0].[Level3_Optional_Id], [t0].[Level3_Required_Id], [t0].[Name] AS [Name1], [t0].[OneToMany_Optional_Inverse4Id], [t0].[OneToMany_Optional_Self_Inverse4Id], [t0].[OneToMany_Required_Inverse4Id], [t0].[OneToMany_Required_Self_Inverse4Id], [t0].[OneToOne_Optional_PK_Inverse4Id], [t0].[OneToOne_Optional_Self4Id] + FROM ( + SELECT TOP(1) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l1] + WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[OneToOne_Optional_PK_Inverse3Id] + LEFT JOIN ( + SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] + FROM [LevelFour] AS [l2] + WHERE [l2].[Id] > 1 + ) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse4Id] +) AS [t1] +ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id1]"); + } + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + { + await base.Filtered_include_complex_three_level_with_middle_having_filter1(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [t1].[Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [t1].[Id00], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name00], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id], [t1].[Id1], [t1].[Level3_Optional_Id0], [t1].[Level3_Required_Id0], [t1].[Name1], [t1].[OneToMany_Optional_Inverse4Id0], [t1].[OneToMany_Optional_Self_Inverse4Id0], [t1].[OneToMany_Required_Inverse4Id0], [t1].[OneToMany_Required_Self_Inverse4Id0], [t1].[OneToOne_Optional_PK_Inverse4Id0], [t1].[OneToOne_Optional_Self4Id0] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id] AS [Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name] AS [Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Id0] AS [Id00], [t0].[Level3_Optional_Id], [t0].[Level3_Required_Id], [t0].[Name0] AS [Name00], [t0].[OneToMany_Optional_Inverse4Id], [t0].[OneToMany_Optional_Self_Inverse4Id], [t0].[OneToMany_Required_Inverse4Id], [t0].[OneToMany_Required_Self_Inverse4Id], [t0].[OneToOne_Optional_PK_Inverse4Id], [t0].[OneToOne_Optional_Self4Id], [t0].[Id1], [t0].[Level3_Optional_Id0], [t0].[Level3_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse4Id0], [t0].[OneToMany_Optional_Self_Inverse4Id0], [t0].[OneToMany_Required_Inverse4Id0], [t0].[OneToMany_Required_Self_Inverse4Id0], [t0].[OneToOne_Optional_PK_Inverse4Id0], [t0].[OneToOne_Optional_Self4Id0] + FROM [LevelTwo] AS [l0] + OUTER APPLY ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [l1].[Id] AS [Id0], [l1].[Level3_Optional_Id], [l1].[Level3_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse4Id], [l1].[OneToMany_Optional_Self_Inverse4Id], [l1].[OneToMany_Required_Inverse4Id], [l1].[OneToMany_Required_Self_Inverse4Id], [l1].[OneToOne_Optional_PK_Inverse4Id], [l1].[OneToOne_Optional_Self4Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l2].[Level3_Required_Id] AS [Level3_Required_Id0], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l2].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l2].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l2].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l2].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l2].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] + FROM ( + SELECT TOP(1) [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] + FROM [LevelThree] AS [l3] + WHERE ([l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id]) AND (([l3].[Name] <> N'Foo') OR [l3].[Name] IS NULL) + ORDER BY [l3].[Id] + ) AS [t] + LEFT JOIN [LevelFour] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse4Id] + LEFT JOIN [LevelFour] AS [l2] ON [t].[Id] = [l2].[OneToMany_Required_Inverse4Id] + ) AS [t0] +) AS [t1] ON [l].[Id] = [t1].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id00], [t1].[Id1]"); + } + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + { + await base.Filtered_include_complex_three_level_with_middle_having_filter2(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [t1].[Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [t1].[Id00], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name00], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id], [t1].[Id1], [t1].[Level3_Optional_Id0], [t1].[Level3_Required_Id0], [t1].[Name1], [t1].[OneToMany_Optional_Inverse4Id0], [t1].[OneToMany_Optional_Self_Inverse4Id0], [t1].[OneToMany_Required_Inverse4Id0], [t1].[OneToMany_Required_Self_Inverse4Id0], [t1].[OneToOne_Optional_PK_Inverse4Id0], [t1].[OneToOne_Optional_Self4Id0] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id] AS [Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name] AS [Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Id0] AS [Id00], [t0].[Level3_Optional_Id], [t0].[Level3_Required_Id], [t0].[Name0] AS [Name00], [t0].[OneToMany_Optional_Inverse4Id], [t0].[OneToMany_Optional_Self_Inverse4Id], [t0].[OneToMany_Required_Inverse4Id], [t0].[OneToMany_Required_Self_Inverse4Id], [t0].[OneToOne_Optional_PK_Inverse4Id], [t0].[OneToOne_Optional_Self4Id], [t0].[Id1], [t0].[Level3_Optional_Id0], [t0].[Level3_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse4Id0], [t0].[OneToMany_Optional_Self_Inverse4Id0], [t0].[OneToMany_Required_Inverse4Id0], [t0].[OneToMany_Required_Self_Inverse4Id0], [t0].[OneToOne_Optional_PK_Inverse4Id0], [t0].[OneToOne_Optional_Self4Id0] + FROM [LevelTwo] AS [l0] + OUTER APPLY ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [l1].[Id] AS [Id0], [l1].[Level3_Optional_Id], [l1].[Level3_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse4Id], [l1].[OneToMany_Optional_Self_Inverse4Id], [l1].[OneToMany_Required_Inverse4Id], [l1].[OneToMany_Required_Self_Inverse4Id], [l1].[OneToOne_Optional_PK_Inverse4Id], [l1].[OneToOne_Optional_Self4Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l2].[Level3_Required_Id] AS [Level3_Required_Id0], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l2].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l2].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l2].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l2].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l2].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] + FROM ( + SELECT TOP(1) [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] + FROM [LevelThree] AS [l3] + WHERE ([l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id]) AND (([l3].[Name] <> N'Foo') OR [l3].[Name] IS NULL) + ORDER BY [l3].[Id] + ) AS [t] + LEFT JOIN [LevelFour] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse4Id] + LEFT JOIN [LevelFour] AS [l2] ON [t].[Id] = [l2].[OneToMany_Required_Inverse4Id] + ) AS [t0] +) AS [t1] ON [l].[Id] = [t1].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id00], [t1].[Id1]"); + } + + public override void Filtered_include_variable_used_inside_filter() + { + base.Filtered_include_variable_used_inside_filter(); + + AssertSql( + @"@__prm_0='Foo' (Size = 4000) + +SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> @__prm_0) OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override void Filtered_include_context_accessed_inside_filter() + { + base.Filtered_include_context_accessed_inside_filter(); + + AssertSql( + @"SELECT COUNT(*) +FROM [LevelOne] AS [l]", + // + @"@__p_0='True' + +SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE @__p_0 = CAST(1 AS bit) + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override void Filtered_include_context_accessed_inside_filter_correlated() + { + base.Filtered_include_context_accessed_inside_filter_correlated(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ( + SELECT COUNT(*) + FROM [LevelOne] AS [l1] + WHERE [l1].[Id] <> [l0].[Id]) > 1 + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_outer_parameter_used_inside_filter(bool async) + { + await base.Filtered_include_outer_parameter_used_inside_filter(async); + + AssertSql( + @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l0] + LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +) AS [t] +OUTER APPLY ( + SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [t1].[Id] AS [Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name] AS [Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id] + FROM [LevelTwo] AS [l2] + LEFT JOIN ( + SELECT [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] + FROM [LevelThree] AS [l3] + WHERE [l3].[Id] <> [l].[Id] + ) AS [t1] ON [l2].[Id] = [t1].[OneToMany_Optional_Inverse3Id] +) AS [t0] +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t0].[Id], [t0].[Id0]"); + } + + public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) + { + await base.Complex_query_with_let_collection_projection_FirstOrDefault(async); + + AssertSql( + @"SELECT [t1].[Id], [t1].[Name], [t1].[Id0], [t1].[c] +FROM [LevelOne] AS [l] +OUTER APPLY ( + SELECT [t].[Id], [t0].[Name], [t0].[Id] AS [Id0], [t].[c] + FROM ( + SELECT TOP(1) 1 AS [c], [l0].[Id] + FROM [LevelTwo] AS [l0] + WHERE ([l].[Id] = [l0].[OneToMany_Optional_Inverse2Id]) AND (([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL) + ) AS [t] + OUTER APPLY ( + SELECT [l1].[Name], [l1].[Id] + FROM [LevelOne] AS [l1] + WHERE EXISTS ( + SELECT 1 + FROM [LevelTwo] AS [l2] + WHERE ([l1].[Id] = [l2].[OneToMany_Optional_Inverse2Id]) AND ([l2].[Id] = [t].[Id])) + ) AS [t0] +) AS [t1] +ORDER BY [l].[Id]"); + } + + public override async Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) + { + await base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); + + AssertSql( + @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l12].[Id], [l13].[Id], [l14].[Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l14].[Name] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] +LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Required_Inverse4Id] +INNER JOIN ( + SELECT [l3].[Id], [l4].[Id] AS [Id0], [l5].[Id] AS [Id1], [l6].[Id] AS [Id2] + FROM [LevelFour] AS [l3] + INNER JOIN [LevelThree] AS [l4] ON [l3].[Level3_Required_Id] = [l4].[Id] + LEFT JOIN [LevelTwo] AS [l5] ON [l4].[Level2_Optional_Id] = [l5].[Id] + LEFT JOIN [LevelTwo] AS [l6] ON [l5].[Id] = [l6].[OneToMany_Required_Self_Inverse2Id] +) AS [t] ON [l2].[Id] = [t].[Id2] +LEFT JOIN ( + SELECT [l7].[Id], [l8].[Id] AS [Id0], [l9].[Id] AS [Id1], [l10].[Id] AS [Id2], [l10].[Level2_Optional_Id] AS [Level2_Optional_Id0] + FROM [LevelFour] AS [l7] + INNER JOIN [LevelThree] AS [l8] ON [l7].[Level3_Required_Id] = [l8].[Id] + INNER JOIN [LevelTwo] AS [l9] ON [l8].[Level2_Required_Id] = [l9].[Id] + LEFT JOIN [LevelThree] AS [l10] ON [l9].[Id] = [l10].[OneToMany_Required_Inverse3Id] +) AS [t0] ON [t].[Id2] = [t0].[Id2] +LEFT JOIN [LevelThree] AS [l11] ON [l2].[OneToMany_Optional_Inverse4Id] = [l11].[Id] +LEFT JOIN [LevelThree] AS [l12] ON [t].[Id2] = [l12].[Level2_Optional_Id] +LEFT JOIN [LevelTwo] AS [l13] ON [t0].[Level2_Optional_Id0] = [l13].[Id] +LEFT JOIN [LevelThree] AS [l14] ON [l13].[Id] = [l14].[Level2_Required_Id] +LEFT JOIN ( + SELECT [l15].[Id], [l15].[Date], [l15].[Level1_Optional_Id], [l15].[Level1_Required_Id], [l15].[Name], [l15].[OneToMany_Optional_Inverse2Id], [l15].[OneToMany_Optional_Self_Inverse2Id], [l15].[OneToMany_Required_Inverse2Id], [l15].[OneToMany_Required_Self_Inverse2Id], [l15].[OneToOne_Optional_PK_Inverse2Id], [l15].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l15] + WHERE [l15].[Id] <> 42 +) AS [t1] ON [t].[Id2] = [t1].[OneToMany_Optional_Self_Inverse2Id] +WHERE ([l11].[Name] <> N'Foo') OR [l11].[Name] IS NULL +ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id], [t1].[Id]"); + } + + public override async Task Take_Select_collection_Take(bool async) + { + await base.Take_Select_collection_Take(async); + + AssertSql( + @"@__p_0='1' + +SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[OneToMany_Optional_Self_Inverse1Id], [t0].[OneToMany_Required_Self_Inverse1Id], [t0].[OneToOne_Optional_Self1Id] +FROM ( + SELECT TOP(@__p_0) [l].[Id], [l].[Name] + FROM [LevelOne] AS [l] + ORDER BY [l].[Id] +) AS [t] +OUTER APPLY ( + SELECT [t1].[Id], [t1].[Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l0].[Id] AS [Id0], [l0].[Date], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] + FROM ( + SELECT TOP(3) [l1].[Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Required_Inverse2Id] + FROM [LevelTwo] AS [l1] + WHERE [t].[Id] = [l1].[OneToMany_Required_Inverse2Id] + ORDER BY [l1].[Id] + ) AS [t1] + INNER JOIN [LevelOne] AS [l0] ON [t1].[Level1_Required_Id] = [l0].[Id] +) AS [t0] +ORDER BY [t].[Id], [t0].[Id], [t0].[Id0]"); + } + + public override async Task Skip_Take_Select_collection_Skip_Take(bool async) + { + await base.Skip_Take_Select_collection_Skip_Take(async); + + AssertSql( + @"@__p_0='1' + +SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[OneToMany_Optional_Self_Inverse1Id], [t0].[OneToMany_Required_Self_Inverse1Id], [t0].[OneToOne_Optional_Self1Id] +FROM ( + SELECT [l].[Id], [l].[Name] + FROM [LevelOne] AS [l] + ORDER BY [l].[Id] + OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY +) AS [t] +OUTER APPLY ( + SELECT [t1].[Id], [t1].[Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l0].[Id] AS [Id0], [l0].[Date], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] + FROM ( + SELECT [l1].[Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Required_Inverse2Id] + FROM [LevelTwo] AS [l1] + WHERE [t].[Id] = [l1].[OneToMany_Required_Inverse2Id] + ORDER BY [l1].[Id] + OFFSET 1 ROWS FETCH NEXT 3 ROWS ONLY + ) AS [t1] + INNER JOIN [LevelOne] AS [l0] ON [t1].[Level1_Required_Id] = [l0].[Id] +) AS [t0] +ORDER BY [t].[Id], [t0].[Id], [t0].[Id0]"); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs new file mode 100644 index 00000000000..984d3584b59 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest.cs @@ -0,0 +1,152 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest : ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase< + ComplexNavigationsSharedTypeQuerySqlServerFixture> + { + public ComplexNavigationsCollectionsSharedTypeQuerySqlServerTest( + ComplexNavigationsSharedTypeQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task SelectMany_with_Include1(bool async) + { + await base.SelectMany_with_Include1(async); + + AssertSql( + @"SELECT [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [l].[Id], [t].[Id0], [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Level3_Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[Id0], [t0].[Id00] +FROM [Level1] AS [l] +INNER JOIN ( + SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l1].[Id] AS [Id0] + FROM [Level1] AS [l0] + INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id] + WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [t1].[Id] AS [Id0], [t1].[Id0] AS [Id00] + FROM [Level1] AS [l2] + INNER JOIN ( + SELECT [l3].[Id], [l4].[Id] AS [Id0] + FROM [Level1] AS [l3] + INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id] + WHERE ([l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL) AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL + ) AS [t1] ON [l2].[Id] = [t1].[Id] + WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL +) AS [t0] ON [t].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t0].[Id], [t0].[Id0], [t0].[Id00]"); + } + + public override async Task SelectMany_with_navigation_and_Distinct(bool async) + { + await base.SelectMany_with_navigation_and_Distinct(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t0].[Id], [t0].[OneToOne_Required_PK_Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Level2_Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[Id0] +FROM [Level1] AS [l] +INNER JOIN ( + SELECT DISTINCT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id] + FROM [Level1] AS [l0] + INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id] + WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l3].[Id] AS [Id0] + FROM [Level1] AS [l2] + INNER JOIN [Level1] AS [l3] ON [l2].[Id] = [l3].[Id] + WHERE ([l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL) AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +WHERE ([t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL) AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL +ORDER BY [l].[Id], [t].[Id], [t0].[Id], [t0].[Id0]"); + } + + public override async Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) + { + await base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t].[Name], [t].[FK], [t0].[Id], [t0].[OneToOne_Required_PK_Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Level2_Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[Id0] +FROM [Level1] AS [l] +INNER JOIN ( + SELECT DISTINCT [l0].[Id], [l0].[Level2_Name] AS [Name], [l0].[OneToMany_Optional_Inverse2Id] AS [FK] + FROM [Level1] AS [l0] + INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id] + WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL +) AS [t] ON [l].[Id] = [t].[FK] +LEFT JOIN ( + SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l3].[Id] AS [Id0] + FROM [Level1] AS [l2] + INNER JOIN [Level1] AS [l3] ON [l2].[Id] = [l3].[Id] + WHERE ([l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL) AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t].[Id], [t].[Name], [t].[FK], [t0].[Id], [t0].[Id0]"); + } + + public override async Task Take_Select_collection_Take(bool async) + { + await base.Take_Select_collection_Take(async); + + AssertSql( + @"@__p_0='1' + +SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[Id00] +FROM ( + SELECT TOP(@__p_0) [l].[Id], [l].[Name] + FROM [Level1] AS [l] + ORDER BY [l].[Id] +) AS [t] +OUTER APPLY ( + SELECT [t1].[Id], [t1].[Level2_Name] AS [Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l1].[Id] AS [Id0], [l1].[Date], [l1].[Name] AS [Name0], [t1].[Id0] AS [Id00] + FROM ( + SELECT TOP(3) [l0].[Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Required_Inverse2Id], [l2].[Id] AS [Id0] + FROM [Level1] AS [l0] + INNER JOIN [Level1] AS [l2] ON [l0].[Id] = [l2].[Id] + WHERE (([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL) AND ([t].[Id] = [l0].[OneToMany_Required_Inverse2Id]) + ORDER BY [l0].[Id] + ) AS [t1] + INNER JOIN [Level1] AS [l1] ON [t1].[Level1_Required_Id] = [l1].[Id] +) AS [t0] +ORDER BY [t].[Id], [t0].[Id], [t0].[Id00], [t0].[Id0]"); + } + + public override async Task Skip_Take_Select_collection_Skip_Take(bool async) + { + await base.Skip_Take_Select_collection_Skip_Take(async); + + AssertSql( + @"@__p_0='1' + +SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[Id00] +FROM ( + SELECT [l].[Id], [l].[Name] + FROM [Level1] AS [l] + ORDER BY [l].[Id] + OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY +) AS [t] +OUTER APPLY ( + SELECT [t1].[Id], [t1].[Level2_Name] AS [Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l1].[Id] AS [Id0], [l1].[Date], [l1].[Name] AS [Name0], [t1].[Id0] AS [Id00] + FROM ( + SELECT [l0].[Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Required_Inverse2Id], [l2].[Id] AS [Id0] + FROM [Level1] AS [l0] + INNER JOIN [Level1] AS [l2] ON [l0].[Id] = [l2].[Id] + WHERE (([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL) AND ([t].[Id] = [l0].[OneToMany_Required_Inverse2Id]) + ORDER BY [l0].[Id] + OFFSET 1 ROWS FETCH NEXT 3 ROWS ONLY + ) AS [t1] + INNER JOIN [Level1] AS [l1] ON [t1].[Level1_Required_Id] = [l1].[Id] +) AS [t0] +ORDER BY [t].[Id], [t0].[Id], [t0].[Id00], [t0].[Id0]"); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqlServerTest.cs new file mode 100644 index 00000000000..32ba4ec3a7e --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqlServerTest.cs @@ -0,0 +1,776 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Threading.Tasks; +using Xunit; +using Xunit.Abstractions; + +// ReSharper disable InconsistentNaming +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsSplitQuerySqlServerTest : ComplexNavigationsCollectionsSplitQueryRelationalTestBase + { + public ComplexNavigationsCollectionsSplitQuerySqlServerTest( + ComplexNavigationsQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + + public override async Task Filtered_include_basic_Where(bool async) + { + await base.Filtered_include_basic_Where(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l0] + WHERE [l0].[Id] > 5 +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id]"); + } + + public override async Task Filtered_include_OrderBy(bool async) + { + await base.Filtered_include_OrderBy(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE 0 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); + } + + public override async Task Filtered_ThenInclude_OrderBy(bool async) + { + await base.Filtered_ThenInclude_OrderBy(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id]", + // + @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] + FROM [LevelThree] AS [l1] + ) AS [t] + WHERE 0 < [t].[row] +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name]"); + } + + public override async Task Filtered_include_ThenInclude_OrderBy(bool async) + { + await base.Filtered_include_ThenInclude_OrderBy(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE 0 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]", + // + @"SELECT [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id] + FROM ( + SELECT [l0].[Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE 0 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t2].[Id], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Optional_Self_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToMany_Required_Self_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id], [t2].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] + FROM [LevelThree] AS [l1] + ) AS [t2] + WHERE 0 < [t2].[row] +) AS [t1] ON [t0].[Id] = [t1].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[Name] DESC"); + } + + public override async Task Filtered_include_basic_OrderBy_Take(bool async) + { + await base.Filtered_include_basic_OrderBy_Take(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); + } + + public override async Task Filtered_include_basic_OrderBy_Skip(bool async) + { + await base.Filtered_include_basic_OrderBy_Skip(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE 1 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); + } + + public override async Task Filtered_include_basic_OrderBy_Skip_Take(bool async) + { + await base.Filtered_include_basic_OrderBy_Skip_Take(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE (1 < [t].[row]) AND ([t].[row] <= 4) +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); + } + + [ConditionalFact(Skip = "issue #24708")] + public override void Filtered_include_Skip_without_OrderBy() + { + base.Filtered_include_Skip_without_OrderBy(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE 1 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + [ConditionalFact(Skip = "issue #24708")] + public override void Filtered_include_Take_without_OrderBy() + { + base.Filtered_include_Take_without_OrderBy(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_on_ThenInclude(bool async) + { + await base.Filtered_include_on_ThenInclude(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +ORDER BY [l].[Id], [l0].[Id]", + // + @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +INNER JOIN ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE (1 < [t].[row]) AND ([t].[row] <= 4) +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name]"); + } + + public override async Task Filtered_include_after_reference_navigation(bool async) + { + await base.Filtered_include_after_reference_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +ORDER BY [l].[Id], [l0].[Id]", + // + @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +INNER JOIN ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE (1 < [t].[row]) AND ([t].[row] <= 4) +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name]"); + } + + public override async Task Filtered_include_after_different_filtered_include_same_level(bool async) + { + await base.Filtered_include_after_different_filtered_include_same_level(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Required_Inverse2Id] ORDER BY [l0].[Name] DESC) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Bar') OR [l0].[Name] IS NULL + ) AS [t] + WHERE 1 < [t].[row] +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Required_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[Name] DESC"); + } + + public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) + { + await base.Filtered_include_after_different_filtered_include_different_level(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]", + // + @"SELECT [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id] + FROM ( + SELECT [l0].[Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t2].[Id], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Optional_Self_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToMany_Required_Self_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id], [t2].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Bar') OR [l1].[Name] IS NULL + ) AS [t2] + WHERE 1 < [t2].[row] +) AS [t1] ON [t0].[Id] = [t1].[OneToMany_Required_Inverse3Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t1].[OneToMany_Required_Inverse3Id], [t1].[Name] DESC"); + } + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice(bool async) + { + await base.Filtered_include_same_filter_set_on_same_navigation_twice(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id] DESC) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 2 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id] DESC"); + } + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + { + await base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +CROSS APPLY ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] + FROM ( + SELECT TOP(2) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l1] + WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] +) AS [t0] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]", + // + @"SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id], [t0].[Id0] +FROM [LevelOne] AS [l] +CROSS APPLY ( + SELECT [t].[Id], [l0].[Id] AS [Id0] + FROM ( + SELECT TOP(2) [l1].[Id] + FROM [LevelTwo] AS [l1] + WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] +) AS [t0] +INNER JOIN [LevelThree] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]"); + } + + public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) + { + await base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] +FROM [LevelOne] AS [l] +CROSS APPLY ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] + FROM ( + SELECT TOP(2) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l1] + WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] +) AS [t0] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]", + // + @"SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id], [t0].[Id0] +FROM [LevelOne] AS [l] +CROSS APPLY ( + SELECT [t].[Id], [l0].[Id] AS [Id0] + FROM ( + SELECT TOP(2) [l1].[Id] + FROM [LevelTwo] AS [l1] + WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] +) AS [t0] +INNER JOIN [LevelThree] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]"); + } + + public override async Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) + { + await base.Filtered_include_and_non_filtered_include_on_same_navigation1(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_and_non_filtered_include_on_same_navigation2(bool async) + { + await base.Filtered_include_and_non_filtered_include_on_same_navigation2(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + { + await base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id] +FROM [LevelOne] AS [l] +CROSS APPLY ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] + FROM ( + SELECT TOP(1) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] + FROM [LevelTwo] AS [l1] + WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[OneToOne_Optional_PK_Inverse3Id] +) AS [t0] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]", + // + @"SELECT [t1].[Id], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id], [l].[Id], [t0].[Id], [t0].[Id0] +FROM [LevelOne] AS [l] +CROSS APPLY ( + SELECT [t].[Id], [l0].[Id] AS [Id0] + FROM ( + SELECT TOP(1) [l1].[Id] + FROM [LevelTwo] AS [l1] + WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) + ORDER BY [l1].[Id] + ) AS [t] + LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[OneToOne_Optional_PK_Inverse3Id] +) AS [t0] +INNER JOIN ( + SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] + FROM [LevelFour] AS [l2] + WHERE [l2].[Id] > 1 +) AS [t1] ON [t0].[Id0] = [t1].[OneToMany_Optional_Inverse4Id] +ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]"); + } + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + { + await base.Filtered_include_complex_three_level_with_middle_having_filter1(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id]", + // + @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", + // + @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] + FROM ( + SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse4Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", + // + @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] + FROM ( + SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Required_Inverse4Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]"); + } + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + { + await base.Filtered_include_complex_three_level_with_middle_having_filter2(async); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [l0].[Id]", + // + @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] + FROM ( + SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", + // + @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] + FROM ( + SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse4Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", + // + @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] +FROM [LevelOne] AS [l] +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +INNER JOIN ( + SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] + FROM ( + SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] + FROM [LevelThree] AS [l1] + WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 1 +) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] +INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Required_Inverse4Id] +ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]"); + } + + [ConditionalFact(Skip = "issue #24708")] + public override void Filtered_include_variable_used_inside_filter() + { + base.Filtered_include_variable_used_inside_filter(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"@__prm_0='Foo' (Size = 4000) + +SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ([l0].[Name] <> @__prm_0) OR [l0].[Name] IS NULL + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + [ConditionalFact(Skip = "issue #24708")] + public override void Filtered_include_context_accessed_inside_filter() + { + base.Filtered_include_context_accessed_inside_filter(); + + AssertSql( + @"SELECT COUNT(*) +FROM [LevelOne] AS [l]", + // + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"@__p_0='True' + +SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE @__p_0 = CAST(1 AS bit) + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + [ConditionalFact(Skip = "issue #24708")] + public override void Filtered_include_context_accessed_inside_filter_correlated() + { + base.Filtered_include_context_accessed_inside_filter_correlated(); + + AssertSql( + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +ORDER BY [l].[Id]", + // + @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] +FROM [LevelOne] AS [l] +INNER JOIN ( + SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] + FROM ( + SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] + FROM [LevelTwo] AS [l0] + WHERE ( + SELECT COUNT(*) + FROM [LevelOne] AS [l1] + WHERE [l1].[Id] <> [l0].[Id]) > 1 + ) AS [t] + WHERE [t].[row] <= 3 +) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] +ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + } + + public override async Task Filtered_include_outer_parameter_used_inside_filter(bool async) + { + await base.Filtered_include_outer_parameter_used_inside_filter(async); + + AssertSql(" "); + } + + private void AssertSql(params string[] expected) + => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); + } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQuerySqlServerTest.cs new file mode 100644 index 00000000000..44764343211 --- /dev/null +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQuerySqlServerTest.cs @@ -0,0 +1,20 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsSplitSharedTypeQuerySqlServerTest : ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase< + ComplexNavigationsSharedTypeQuerySqlServerFixture> + { + public ComplexNavigationsCollectionsSplitSharedTypeQuerySqlServerTest( + ComplexNavigationsSharedTypeQuerySqlServerFixture fixture, + ITestOutputHelper testOutputHelper) + : base(fixture) + { + Fixture.TestSqlLoggerFactory.Clear(); + //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); + } + } +} diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs index 132e0b2f6cc..4d05481fb3a 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsQuerySqlServerTest.cs @@ -155,43 +155,6 @@ FROM [LevelTwo] AS [l] WHERE [l0].[Id] IN (1, 2)"); } - public override async Task Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(bool async) - { - await base.Multi_level_include_one_to_many_optional_and_one_to_many_optional_produces_valid_sql(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); - } - - public override async Task - Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times(bool async) - { - await base.Multi_level_include_correct_PK_is_chosen_as_the_join_predicate_for_queries_that_join_same_table_multiple_times( - async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Id00], [t0].[Date0], [t0].[Level1_Optional_Id0], [t0].[Level1_Required_Id0], [t0].[Name00], [t0].[OneToMany_Optional_Inverse2Id0], [t0].[OneToMany_Optional_Self_Inverse2Id0], [t0].[OneToMany_Required_Inverse2Id0], [t0].[OneToMany_Required_Self_Inverse2Id0], [t0].[OneToOne_Optional_PK_Inverse2Id0], [t0].[OneToOne_Optional_Self2Id0], [t0].[Id1], [t0].[Level2_Optional_Id0], [t0].[Level2_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse3Id0], [t0].[OneToMany_Optional_Self_Inverse3Id0], [t0].[OneToMany_Required_Inverse3Id0], [t0].[OneToMany_Required_Self_Inverse3Id0], [t0].[OneToOne_Optional_PK_Inverse3Id0], [t0].[OneToOne_Optional_Self3Id0] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id] AS [Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name] AS [Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id0] AS [Id00], [t].[Date] AS [Date0], [t].[Level1_Optional_Id] AS [Level1_Optional_Id0], [t].[Level1_Required_Id] AS [Level1_Required_Id0], [t].[Name0] AS [Name00], [t].[OneToMany_Optional_Inverse2Id] AS [OneToMany_Optional_Inverse2Id0], [t].[OneToMany_Optional_Self_Inverse2Id] AS [OneToMany_Optional_Self_Inverse2Id0], [t].[OneToMany_Required_Inverse2Id] AS [OneToMany_Required_Inverse2Id0], [t].[OneToMany_Required_Self_Inverse2Id] AS [OneToMany_Required_Self_Inverse2Id0], [t].[OneToOne_Optional_PK_Inverse2Id] AS [OneToOne_Optional_PK_Inverse2Id0], [t].[OneToOne_Optional_Self2Id] AS [OneToOne_Optional_Self2Id0], [t].[Id1], [t].[Level2_Optional_Id0], [t].[Level2_Required_Id0], [t].[Name1], [t].[OneToMany_Optional_Inverse3Id0], [t].[OneToMany_Optional_Self_Inverse3Id0], [t].[OneToMany_Required_Inverse3Id0], [t].[OneToMany_Required_Self_Inverse3Id0], [t].[OneToOne_Optional_PK_Inverse3Id0], [t].[OneToOne_Optional_Self3Id0] - FROM [LevelTwo] AS [l0] - LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id0], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name] AS [Name0], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id1], [l3].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l3].[Level2_Required_Id] AS [Level2_Required_Id0], [l3].[Name] AS [Name1], [l3].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l3].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l3].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l3].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l3].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l3].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0] - FROM [LevelThree] AS [l1] - INNER JOIN [LevelTwo] AS [l2] ON [l1].[OneToMany_Required_Inverse3Id] = [l2].[Id] - LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[OneToMany_Optional_Inverse3Id] - ) AS [t] ON [l0].[Id] = [t].[OneToMany_Optional_Inverse3Id] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id00], [t0].[Id1]"); - } - public override void Multi_level_include_with_short_circuiting() { base.Multi_level_include_with_short_circuiting(); @@ -537,79 +500,6 @@ FROM [LevelFour] AS [l0] ) AS [t] ON [l].[Name] = [t].[Name2]"); } - public override async Task Multiple_complex_includes(bool async) - { - await base.Multiple_complex_includes(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l2] - LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[Level2_Optional_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); - } - - public override async Task Multiple_complex_includes_self_ref(bool async) - { - await base.Multiple_complex_includes_self_ref(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id], [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [t].[Id0], [t].[Date0], [t].[Name0], [t].[OneToMany_Optional_Self_Inverse1Id0], [t].[OneToMany_Required_Self_Inverse1Id0], [t].[OneToOne_Optional_Self1Id0] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelOne] AS [l0] ON [l].[OneToOne_Optional_Self1Id] = [l0].[Id] -LEFT JOIN [LevelOne] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Self_Inverse1Id] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[Date], [l2].[Name], [l2].[OneToMany_Optional_Self_Inverse1Id], [l2].[OneToMany_Required_Self_Inverse1Id], [l2].[OneToOne_Optional_Self1Id], [l3].[Id] AS [Id0], [l3].[Date] AS [Date0], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Self_Inverse1Id] AS [OneToMany_Optional_Self_Inverse1Id0], [l3].[OneToMany_Required_Self_Inverse1Id] AS [OneToMany_Required_Self_Inverse1Id0], [l3].[OneToOne_Optional_Self1Id] AS [OneToOne_Optional_Self1Id0] - FROM [LevelOne] AS [l2] - LEFT JOIN [LevelOne] AS [l3] ON [l2].[OneToOne_Optional_Self1Id] = [l3].[Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Self_Inverse1Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); - } - - public override async Task Include_reference_and_collection_order_by(bool async) - { - await base.Include_reference_and_collection_order_by(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Include_reference_ThenInclude_collection_order_by(bool async) - { - await base.Include_reference_ThenInclude_collection_order_by(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Include_collection_then_reference(bool async) - { - await base.Include_collection_then_reference(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); - } - public override async Task Include_reference_and_project_into_anonymous_type(bool async) { await base.Include_reference_and_project_into_anonymous_type(async); @@ -620,37 +510,6 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); } - public override async Task Include_collection_with_conditional_order_by(bool async) - { - await base.Include_collection_with_conditional_order_by(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY CASE - WHEN [l].[Name] IS NOT NULL AND ([l].[Name] LIKE N'%03') THEN 1 - ELSE 2 -END, [l].[Id], [l0].[Id]"); - } - - public override async Task Multiple_complex_include_select(bool async) - { - await base.Multiple_complex_include_select(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l2] - LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[Level2_Optional_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0]"); - } - public override async Task Select_nav_prop_reference_optional1(bool async) { await base.Select_nav_prop_reference_optional1(async); @@ -1119,23 +978,6 @@ FROM [LevelOne] AS [l] WHERE ([l0].[Name] <> N'L2 05') OR [l0].[Name] IS NULL"); } - public override async Task Include_nested_with_optional_navigation(bool async) - { - await base.Include_nested_with_optional_navigation(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id0], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id0], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name0], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] - FROM [LevelThree] AS [l1] - LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] -) AS [t] ON [l0].[Id] = [t].[OneToMany_Required_Inverse3Id] -WHERE ([l0].[Name] <> N'L2 09') OR [l0].[Name] IS NULL -ORDER BY [l].[Id], [l0].[Id], [t].[Id], [t].[Id0]"); - } - public override async Task Join_flattening_bug_4539(bool async) { await base.Join_flattening_bug_4539(async); @@ -1322,87 +1164,6 @@ FROM [LevelTwo] AS [l1] WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) > 0"); } - public override async Task Complex_multi_include_with_order_by_and_paging(bool async) - { - await base.Complex_multi_include_with_order_by_and_paging(async); - - AssertSql( - @"@__p_0='0' -@__p_1='10' - -SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id] -FROM ( - SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] - FROM [LevelOne] AS [l] - ORDER BY [l].[Name] - OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY -) AS [t] -LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Required_Inverse3Id] -ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); - } - - public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(bool async) - { - await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key(async); - - AssertSql( - @"@__p_0='0' -@__p_1='10' - -SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id], [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] -FROM ( - SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] - FROM [LevelOne] AS [l] - ORDER BY [l].[Name] - OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY -) AS [t] -LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] -LEFT JOIN [LevelThree] AS [l3] ON [l1].[Id] = [l3].[OneToMany_Required_Inverse3Id] -ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id]"); - } - - public override async Task Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(bool async) - { - await base.Complex_multi_include_with_order_by_and_paging_joins_on_correct_key2(async); - - AssertSql( - @"@__p_0='0' -@__p_1='10' - -SELECT [t].[Id], [t].[Date], [t].[Name], [t].[OneToMany_Optional_Self_Inverse1Id], [t].[OneToMany_Required_Self_Inverse1Id], [t].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] -FROM ( - SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] - FROM [LevelOne] AS [l] - ORDER BY [l].[Name] - OFFSET @__p_0 ROWS FETCH NEXT @__p_1 ROWS ONLY -) AS [t] -LEFT JOIN [LevelTwo] AS [l0] ON [t].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] -LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] -ORDER BY [t].[Name], [t].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); - } - - public override async Task Multiple_include_with_multiple_optional_navigations(bool async) - { - await base.Multiple_include_with_multiple_optional_navigations(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id], [l5].[Id], [l5].[Level2_Optional_Id], [l5].[Level2_Required_Id], [l5].[Name], [l5].[OneToMany_Optional_Inverse3Id], [l5].[OneToMany_Optional_Self_Inverse3Id], [l5].[OneToMany_Required_Inverse3Id], [l5].[OneToMany_Required_Self_Inverse3Id], [l5].[OneToOne_Optional_PK_Inverse3Id], [l5].[OneToOne_Optional_Self3Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l3].[Date], [l3].[Level1_Optional_Id], [l3].[Level1_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse2Id], [l3].[OneToMany_Optional_Self_Inverse2Id], [l3].[OneToMany_Required_Inverse2Id], [l3].[OneToMany_Required_Self_Inverse2Id], [l3].[OneToOne_Optional_PK_Inverse2Id], [l3].[OneToOne_Optional_Self2Id], [l4].[Level2_Optional_Id], [l4].[Level2_Required_Id], [l4].[Name], [l4].[OneToMany_Optional_Inverse3Id], [l4].[OneToMany_Optional_Self_Inverse3Id], [l4].[OneToMany_Required_Inverse3Id], [l4].[OneToMany_Required_Self_Inverse3Id], [l4].[OneToOne_Optional_PK_Inverse3Id], [l4].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] -LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[Level2_Optional_Id] -LEFT JOIN [LevelTwo] AS [l3] ON [l].[Id] = [l3].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l4] ON [l3].[Id] = [l4].[Level2_Optional_Id] -LEFT JOIN [LevelThree] AS [l5] ON [l0].[Id] = [l5].[OneToMany_Optional_Inverse3Id] -WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id], [l4].[Id], [l5].[Id]"); - } - public override async Task Correlated_subquery_doesnt_project_unnecessary_columns_in_top_level(bool async) { await base.Correlated_subquery_doesnt_project_unnecessary_columns_in_top_level(async); @@ -1632,68 +1393,6 @@ FROM [LevelOne] AS [l] ORDER BY [l].[Id]"); } - public override async Task SelectMany_with_Include1(bool async) - { - await base.SelectMany_with_Include1(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Orderby_SelectMany_with_Include1(bool async) - { - await base.Orderby_SelectMany_with_Include1(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task SelectMany_with_Include2(bool async) - { - await base.SelectMany_with_Include2(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id]"); - } - - public override async Task SelectMany_with_Include_ThenInclude(bool async) - { - await base.SelectMany_with_Include_ThenInclude(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l].[Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] -LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); - } - - public override async Task Multiple_SelectMany_with_Include(bool async) - { - await base.Multiple_SelectMany_with_Include(async); - - AssertSql( - @"SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [l3].[Id], [l3].[Level3_Optional_Id], [l3].[Level3_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse4Id], [l3].[OneToMany_Optional_Self_Inverse4Id], [l3].[OneToMany_Required_Inverse4Id], [l3].[OneToMany_Required_Self_Inverse4Id], [l3].[OneToOne_Optional_PK_Inverse4Id], [l3].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] -LEFT JOIN [LevelFour] AS [l3] ON [l1].[Id] = [l3].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [l3].[Id]"); - } - public override async Task SelectMany_with_string_based_Include1(bool async) { await base.SelectMany_with_string_based_Include1(async); @@ -1729,29 +1428,6 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id]"); } - public override async Task Required_navigation_with_Include(bool async) - { - await base.Required_navigation_with_Include(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Date], [l0].[Name], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] -FROM [LevelThree] AS [l1] -INNER JOIN [LevelTwo] AS [l] ON [l1].[Level2_Required_Id] = [l].[Id] -INNER JOIN [LevelOne] AS [l0] ON [l].[OneToMany_Required_Inverse2Id] = [l0].[Id]"); - } - - public override async Task Required_navigation_with_Include_ThenInclude(bool async) - { - await base.Required_navigation_with_Include_ThenInclude(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Level2_Optional_Id], [l].[Level2_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse3Id], [l].[OneToMany_Optional_Self_Inverse3Id], [l].[OneToMany_Required_Inverse3Id], [l].[OneToMany_Required_Self_Inverse3Id], [l].[OneToOne_Optional_PK_Inverse3Id], [l].[OneToOne_Optional_Self3Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id] -FROM [LevelFour] AS [l2] -INNER JOIN [LevelThree] AS [l] ON [l2].[Level3_Required_Id] = [l].[Id] -INNER JOIN [LevelTwo] AS [l0] ON [l].[OneToMany_Required_Inverse3Id] = [l0].[Id] -LEFT JOIN [LevelOne] AS [l1] ON [l0].[OneToMany_Optional_Inverse2Id] = [l1].[Id]"); - } - public override async Task Multiple_required_navigations_with_Include(bool async) { await base.Multiple_required_navigations_with_Include(async); @@ -1811,198 +1487,47 @@ FROM [LevelOne] AS [l1] LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2] ON [l1.OneToOne_Optional_FK1].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_FK2].[Level2_Optional_Id]"); } - public override async Task Optional_navigation_with_Include_ThenInclude(bool async) + public override async Task SelectMany_with_navigation_and_explicit_DefaultIfEmpty(bool async) { - await base.Optional_navigation_with_Include_ThenInclude(async); + await base.SelectMany_with_navigation_and_explicit_DefaultIfEmpty(async); AssertSql( - @"SELECT [l1.OneToOne_Optional_FK1].[Id], [l1.OneToOne_Optional_FK1].[Date], [l1.OneToOne_Optional_FK1].[Level1_Optional_Id], [l1.OneToOne_Optional_FK1].[Level1_Required_Id], [l1.OneToOne_Optional_FK1].[Name], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_PK_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l1] -LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] -ORDER BY [l1.OneToOne_Optional_FK1].[Id]", - // - @"SELECT [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Name], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_Self3Id], [l.OneToOne_Optional_FK3].[Id], [l.OneToOne_Optional_FK3].[Level3_Optional_Id], [l.OneToOne_Optional_FK3].[Level3_Required_Id], [l.OneToOne_Optional_FK3].[Name], [l.OneToOne_Optional_FK3].[OneToMany_Optional_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToMany_Optional_Self_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToMany_Required_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToMany_Required_Self_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToOne_Optional_PK_Inverse4Id], [l.OneToOne_Optional_FK3].[OneToOne_Optional_Self4Id] -FROM [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToMany_Optional2] -LEFT JOIN [LevelFour] AS [l.OneToOne_Optional_FK3] ON [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Id] = [l.OneToOne_Optional_FK3].[Level3_Optional_Id] -INNER JOIN ( - SELECT DISTINCT [l1.OneToOne_Optional_FK10].[Id] - FROM [LevelOne] AS [l10] - LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] -) AS [t] ON [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id] = [t].[Id] -ORDER BY [t].[Id]"); + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] +WHERE [l0].[Id] IS NOT NULL"); } - public override async Task Multiple_optional_navigation_with_Include(bool async) + public override async Task SelectMany_with_navigation_filter_and_explicit_DefaultIfEmpty(bool async) { - await base.Multiple_optional_navigation_with_Include(async); + await base.SelectMany_with_navigation_filter_and_explicit_DefaultIfEmpty(async); AssertSql( - @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l1] -LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2] ON [l1.OneToOne_Optional_FK1].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id] -ORDER BY [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id]", - // - @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] -FROM [LevelFour] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3] -INNER JOIN ( - SELECT DISTINCT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[Id] - FROM [LevelOne] AS [l10] - LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] - LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20] ON [l1.OneToOne_Optional_FK10].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[OneToOne_Optional_PK_Inverse3Id] -) AS [t] ON [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] = [t].[Id] -ORDER BY [t].[Id]"); + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +LEFT JOIN ( + SELECT [l0].[Id], [l0].[OneToMany_Optional_Inverse2Id] + FROM [LevelTwo] AS [l0] + WHERE [l0].[Id] > 5 +) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] +WHERE [t].[Id] IS NOT NULL"); } - public override async Task Multiple_optional_navigation_with_string_based_Include(bool async) + public override async Task SelectMany_with_nested_navigation_and_explicit_DefaultIfEmpty(bool async) { - await base.Multiple_optional_navigation_with_string_based_Include(async); + await base.SelectMany_with_nested_navigation_and_explicit_DefaultIfEmpty(async); AssertSql( - @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l1] -LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2] ON [l1.OneToOne_Optional_FK1].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[OneToOne_Optional_PK_Inverse3Id] -ORDER BY [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2].[Id]", - // - @"SELECT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[Name], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] -FROM [LevelFour] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3] -INNER JOIN ( - SELECT DISTINCT [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[Id] - FROM [LevelOne] AS [l10] - LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] - LEFT JOIN [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20] ON [l1.OneToOne_Optional_FK10].[Id] = [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK20].[OneToOne_Optional_PK_Inverse3Id] -) AS [t] ON [l1.OneToOne_Optional_FK1.OneToOne_Optional_PK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] = [t].[Id] -ORDER BY [t].[Id]"); + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] +LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] +WHERE [l1].[Id] IS NOT NULL"); } - public override async Task Optional_navigation_with_order_by_and_Include(bool async) + public override async Task SelectMany_with_nested_navigation_filter_and_explicit_DefaultIfEmpty(bool async) { - await base.Optional_navigation_with_order_by_and_Include(async); - - AssertSql( - @"SELECT [l1.OneToOne_Optional_FK1].[Id], [l1.OneToOne_Optional_FK1].[Date], [l1.OneToOne_Optional_FK1].[Level1_Optional_Id], [l1.OneToOne_Optional_FK1].[Level1_Required_Id], [l1.OneToOne_Optional_FK1].[Name], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Optional_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToMany_Required_Self_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_PK_Inverse2Id], [l1.OneToOne_Optional_FK1].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l1] -LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK1] ON [l1].[Id] = [l1.OneToOne_Optional_FK1].[Level1_Optional_Id] -ORDER BY [l1.OneToOne_Optional_FK1].[Name], [l1.OneToOne_Optional_FK1].[Id]", - // - @"SELECT [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Optional_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Level2_Required_Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[Name], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToOne_Optional_Self3Id] -FROM [LevelThree] AS [l1.OneToOne_Optional_FK1.OneToMany_Optional2] -INNER JOIN ( - SELECT DISTINCT [l1.OneToOne_Optional_FK10].[Id], [l1.OneToOne_Optional_FK10].[Name] - FROM [LevelOne] AS [l10] - LEFT JOIN [LevelTwo] AS [l1.OneToOne_Optional_FK10] ON [l10].[Id] = [l1.OneToOne_Optional_FK10].[Level1_Optional_Id] -) AS [t] ON [l1.OneToOne_Optional_FK1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id] = [t].[Id] -ORDER BY [t].[Name], [t].[Id]"); - } - - public override async Task Optional_navigation_with_Include_and_order(bool async) - { - await base.Optional_navigation_with_Include_and_order(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l0] -LEFT JOIN [LevelTwo] AS [l] ON [l0].[Id] = [l].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Name], [l0].[Id]"); - } - - public override async Task SelectMany_with_order_by_and_Include(bool async) - { - await base.SelectMany_with_order_by_and_Include(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l0].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task SelectMany_with_Include_and_order_by(bool async) - { - await base.SelectMany_with_Include_and_order_by(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l0].[Name], [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task SelectMany_with_navigation_and_explicit_DefaultIfEmpty(bool async) - { - await base.SelectMany_with_navigation_and_explicit_DefaultIfEmpty(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -WHERE [l0].[Id] IS NOT NULL"); - } - - public override async Task SelectMany_with_navigation_and_Distinct(bool async) - { - await base.SelectMany_with_navigation_and_Distinct(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT DISTINCT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l0] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [l1].[Id]"); - } - - public override async Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) - { - await base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT DISTINCT [l0].[Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id] AS [FK] - FROM [LevelTwo] AS [l0] -) AS [t] ON [l].[Id] = [t].[FK] -LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [l1].[Id]"); - } - - public override async Task SelectMany_with_navigation_filter_and_explicit_DefaultIfEmpty(bool async) - { - await base.SelectMany_with_navigation_filter_and_explicit_DefaultIfEmpty(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[OneToMany_Optional_Inverse2Id] - FROM [LevelTwo] AS [l0] - WHERE [l0].[Id] > 5 -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -WHERE [t].[Id] IS NOT NULL"); - } - - public override async Task SelectMany_with_nested_navigation_and_explicit_DefaultIfEmpty(bool async) - { - await base.SelectMany_with_nested_navigation_and_explicit_DefaultIfEmpty(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -WHERE [l1].[Id] IS NOT NULL"); - } - - public override async Task SelectMany_with_nested_navigation_filter_and_explicit_DefaultIfEmpty(bool async) - { - await base.SelectMany_with_nested_navigation_filter_and_explicit_DefaultIfEmpty(async); + await base.SelectMany_with_nested_navigation_filter_and_explicit_DefaultIfEmpty(async); AssertSql( @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] @@ -2161,45 +1686,6 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelOne] AS [l3] ON [l2].[Id] = [l3].[Id]"); } - public override async Task - Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top(bool async) - { - await base.Complex_SelectMany_with_nested_navigations_and_explicit_DefaultIfEmpty_with_other_query_operators_composed_on_top( - async); - - AssertSql( - @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l12].[Id], [l13].[Id], [l14].[Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l14].[Name] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] -LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Required_Inverse4Id] -INNER JOIN ( - SELECT [l3].[Id], [l4].[Id] AS [Id0], [l5].[Id] AS [Id1], [l6].[Id] AS [Id2] - FROM [LevelFour] AS [l3] - INNER JOIN [LevelThree] AS [l4] ON [l3].[Level3_Required_Id] = [l4].[Id] - LEFT JOIN [LevelTwo] AS [l5] ON [l4].[Level2_Optional_Id] = [l5].[Id] - LEFT JOIN [LevelTwo] AS [l6] ON [l5].[Id] = [l6].[OneToMany_Required_Self_Inverse2Id] -) AS [t] ON [l2].[Id] = [t].[Id2] -LEFT JOIN ( - SELECT [l7].[Id], [l8].[Id] AS [Id0], [l9].[Id] AS [Id1], [l10].[Id] AS [Id2], [l10].[Level2_Optional_Id] AS [Level2_Optional_Id0] - FROM [LevelFour] AS [l7] - INNER JOIN [LevelThree] AS [l8] ON [l7].[Level3_Required_Id] = [l8].[Id] - INNER JOIN [LevelTwo] AS [l9] ON [l8].[Level2_Required_Id] = [l9].[Id] - LEFT JOIN [LevelThree] AS [l10] ON [l9].[Id] = [l10].[OneToMany_Required_Inverse3Id] -) AS [t0] ON [t].[Id2] = [t0].[Id2] -LEFT JOIN [LevelThree] AS [l11] ON [l2].[OneToMany_Optional_Inverse4Id] = [l11].[Id] -LEFT JOIN [LevelThree] AS [l12] ON [t].[Id2] = [l12].[Level2_Optional_Id] -LEFT JOIN [LevelTwo] AS [l13] ON [t0].[Level2_Optional_Id0] = [l13].[Id] -LEFT JOIN [LevelThree] AS [l14] ON [l13].[Id] = [l14].[Level2_Required_Id] -LEFT JOIN ( - SELECT [l15].[Id], [l15].[Date], [l15].[Level1_Optional_Id], [l15].[Level1_Required_Id], [l15].[Name], [l15].[OneToMany_Optional_Inverse2Id], [l15].[OneToMany_Optional_Self_Inverse2Id], [l15].[OneToMany_Required_Inverse2Id], [l15].[OneToMany_Required_Self_Inverse2Id], [l15].[OneToOne_Optional_PK_Inverse2Id], [l15].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l15] - WHERE [l15].[Id] <> 42 -) AS [t1] ON [t].[Id2] = [t1].[OneToMany_Optional_Self_Inverse2Id] -WHERE ([l11].[Name] <> N'Foo') OR [l11].[Name] IS NULL -ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id], [t1].[Id]"); - } - public override async Task Multiple_SelectMany_with_navigation_and_explicit_DefaultIfEmpty(bool async) { await base.Multiple_SelectMany_with_navigation_and_explicit_DefaultIfEmpty(async); @@ -3043,53 +2529,6 @@ public override async Task Subquery_with_Distinct_Skip_FirstOrDefault_without_Or ""); } - public override async Task Project_collection_navigation(bool async) - { - await base.Project_collection_navigation(async); - - AssertSql( - @"SELECT [l].[Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id]"); - } - - public override async Task Project_collection_navigation_nested(bool async) - { - await base.Project_collection_navigation_nested(async); - - AssertSql( - @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Project_collection_navigation_using_ef_property(bool async) - { - await base.Project_collection_navigation_using_ef_property(async); - - AssertSql( - @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Project_collection_navigation_nested_anonymous(bool async) - { - await base.Project_collection_navigation_nested_anonymous(async); - - AssertSql( - @"SELECT [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - public override async Task Project_collection_navigation_count(bool async) { await base.Project_collection_navigation_count(async); @@ -3103,74 +2542,6 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); } - public override async Task Project_collection_navigation_composed(bool async) - { - await base.Project_collection_navigation_composed(async); - - AssertSql( - @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -WHERE [l].[Id] < 3 -ORDER BY [l].[Id], [t].[Id]"); - } - - public override async Task Project_collection_and_root_entity(bool async) - { - await base.Project_collection_and_root_entity(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id]"); - } - - public override async Task Project_collection_and_include(bool async) - { - await base.Project_collection_and_include(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Project_navigation_and_collection(bool async) - { - await base.Project_navigation_and_collection(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Include_inside_subquery(bool async) - { - await base.Include_inside_subquery(async); - - AssertSql( - @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] - WHERE [l0].[Id] > 0 -) AS [t] -WHERE [l].[Id] < 3 -ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); - } - public override async Task Select_optional_navigation_property_string_concat(bool async) { await base.Select_optional_navigation_property_string_concat(async); @@ -3188,61 +2559,6 @@ WHERE [l0].[Id] > 5 ) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id]"); } - public override async Task Include_collection_with_multiple_orderbys_member(bool async) - { - await base.Include_collection_with_multiple_orderbys_member(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] -FROM [LevelTwo] AS [l] -LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Name], [l].[Level1_Required_Id], [l].[Id], [l0].[Id]"); - } - - public override async Task Include_collection_with_multiple_orderbys_property(bool async) - { - await base.Include_collection_with_multiple_orderbys_property(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] -FROM [LevelTwo] AS [l] -LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Level1_Required_Id], [l].[Name], [l].[Id], [l0].[Id]"); - } - - public override async Task Include_collection_with_multiple_orderbys_methodcall(bool async) - { - await base.Include_collection_with_multiple_orderbys_methodcall(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] -FROM [LevelTwo] AS [l] -LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] -ORDER BY ABS([l].[Level1_Required_Id]), [l].[Name], [l].[Id], [l0].[Id]"); - } - - public override async Task Include_collection_with_multiple_orderbys_complex(bool async) - { - await base.Include_collection_with_multiple_orderbys_complex(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] -FROM [LevelTwo] AS [l] -LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] -ORDER BY ABS([l].[Level1_Required_Id]) + 7, [l].[Name], [l].[Id], [l0].[Id]"); - } - - public override async Task Include_collection_with_multiple_orderbys_complex_repeated(bool async) - { - await base.Include_collection_with_multiple_orderbys_complex_repeated(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Level1_Optional_Id], [l].[Level1_Required_Id], [l].[Name], [l].[OneToMany_Optional_Inverse2Id], [l].[OneToMany_Optional_Self_Inverse2Id], [l].[OneToMany_Required_Inverse2Id], [l].[OneToMany_Required_Self_Inverse2Id], [l].[OneToOne_Optional_PK_Inverse2Id], [l].[OneToOne_Optional_Self2Id], [l0].[Id], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] -FROM [LevelTwo] AS [l] -LEFT JOIN [LevelThree] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse3Id] -ORDER BY -[l].[Level1_Required_Id], [l].[Name], [l].[Id], [l0].[Id]"); - } - public override async Task String_include_multiple_derived_navigation_with_same_name_and_same_type(bool async) { await base.String_include_multiple_derived_navigation_with_same_name_and_same_type(async); @@ -3345,18 +2661,6 @@ FROM [InheritanceOne] AS [i3] ORDER BY [i].[Id], [i0].[Id], [i1].[Id], [i2].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); } - public override async Task Include_reference_collection_order_by_reference_navigation(bool async) - { - await base.Include_reference_collection_order_by_reference_navigation(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l0].[Id], [l].[Id], [l1].[Id]"); - } - public override async Task Nav_rewrite_doesnt_apply_null_protection_for_function_arguments(bool async) { await base.Nav_rewrite_doesnt_apply_null_protection_for_function_arguments(async); @@ -3379,207 +2683,38 @@ FROM [LevelOne] AS [l] WHERE [l0].[Name] NOT IN (N'Name1', N'Name2') OR [l0].[Name] IS NULL"); } - public override async Task Include_after_SelectMany_and_reference_navigation(bool async) + public override async Task Include1(bool async) { - await base.Include_after_SelectMany_and_reference_navigation(async); + await base.Include1(async); AssertSql( - @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l1] -INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id] -ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id]", - // - @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] -FROM [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3] -INNER JOIN ( - SELECT DISTINCT [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id] - FROM [LevelOne] AS [l10] - INNER JOIN [LevelTwo] AS [l1.OneToMany_Required10] ON [l10].[Id] = [l1.OneToMany_Required10].[OneToMany_Required_Inverse2Id] - LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK20] ON [l1.OneToMany_Required10].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Level2_Optional_Id] -) AS [t] ON [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] = [t].[Id] -ORDER BY [t].[Id]"); + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); } - public override async Task Include_after_multiple_SelectMany_and_reference_navigation(bool async) + public override async Task Include2(bool async) { - await base.Include_after_multiple_SelectMany_and_reference_navigation(async); + await base.Include2(async); AssertSql( - @"SELECT [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Name], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l1] -INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] -INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToMany_Optional2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToMany_Optional2].[OneToMany_Optional_Inverse3Id] -LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3] ON [l1.OneToMany_Required1.OneToMany_Optional2].[Id] = [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Level3_Required_Id] -ORDER BY [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3].[Id]", - // - @"SELECT [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Level3_Required_Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[Name], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToOne_Optional_Self4Id] -FROM [LevelFour] AS [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4] -INNER JOIN ( - SELECT DISTINCT [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK30].[Id] - FROM [LevelOne] AS [l10] - INNER JOIN [LevelTwo] AS [l1.OneToMany_Required10] ON [l10].[Id] = [l1.OneToMany_Required10].[OneToMany_Required_Inverse2Id] - INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToMany_Optional20] ON [l1.OneToMany_Required10].[Id] = [l1.OneToMany_Required1.OneToMany_Optional20].[OneToMany_Optional_Inverse3Id] - LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK30] ON [l1.OneToMany_Required1.OneToMany_Optional20].[Id] = [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK30].[Level3_Required_Id] -) AS [t] ON [l1.OneToMany_Required1.OneToMany_Optional2.OneToOne_Required_FK3.OneToMany_Required_Self4].[OneToMany_Required_Self_Inverse4Id] = [t].[Id] -ORDER BY [t].[Id]"); + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); } - public override async Task Include_after_SelectMany_and_multiple_reference_navigations(bool async) + public override async Task Include3(bool async) { - await base.Include_after_SelectMany_and_multiple_reference_navigations(async); + await base.Include3(async); AssertSql( - @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l1] -INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id] -LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3] ON [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Level3_Required_Id] -ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3].[Id]", - // - @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToOne_Optional_Self4Id] -FROM [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4] -INNER JOIN ( - SELECT DISTINCT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK30].[Id] - FROM [LevelOne] AS [l10] - INNER JOIN [LevelTwo] AS [l1.OneToMany_Required10] ON [l10].[Id] = [l1.OneToMany_Required10].[OneToMany_Required_Inverse2Id] - LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK20] ON [l1.OneToMany_Required10].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Level2_Optional_Id] - LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK30] ON [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK30].[Level3_Required_Id] -) AS [t] ON [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToOne_Required_FK3.OneToMany_Optional_Self4].[OneToMany_Optional_Self_Inverse4Id] = [t].[Id] -ORDER BY [t].[Id]"); + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] +FROM [LevelOne] AS [l] +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToOne_Optional_PK_Inverse2Id]"); } - public override async Task Include_after_SelectMany_and_reference_navigation_with_another_SelectMany_with_Distinct(bool async) - { - await base.Include_after_SelectMany_and_reference_navigation_with_another_SelectMany_with_Distinct(async); - - AssertSql( - @"SELECT [l1].[Id], [l1].[Date], [l1].[Name], [l1].[OneToMany_Optional_Self_Inverse1Id], [l1].[OneToMany_Required_Self_Inverse1Id], [l1].[OneToOne_Optional_Self1Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Optional_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToMany_Required_Self_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_PK_Inverse3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2].[OneToOne_Optional_Self3Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l1] -INNER JOIN [LevelTwo] AS [l1.OneToMany_Required1] ON [l1].[Id] = [l1.OneToMany_Required1].[OneToMany_Required_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Level2_Optional_Id] -INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK20] ON [l1.OneToMany_Required1].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Level2_Optional_Id] -LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3] ON [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional3].[OneToMany_Optional_Inverse4Id] -ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK2].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK20].[Id]", - // - @"SELECT [l11].[Id], [l11].[Date], [l11].[Name], [l11].[OneToMany_Optional_Self_Inverse1Id], [l11].[OneToMany_Required_Self_Inverse1Id], [l11].[OneToOne_Optional_Self1Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToOne_Optional_Self4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK23].[Id] -FROM [LevelOne] AS [l11] -INNER JOIN [LevelTwo] AS [l1.OneToMany_Required11] ON [l11].[Id] = [l1.OneToMany_Required11].[OneToMany_Required_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK23] ON [l1.OneToMany_Required11].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK23].[Level2_Optional_Id] -INNER JOIN [LevelThree] AS [l1.OneToMany_Required1.OneToOne_Optional_FK24] ON [l1.OneToMany_Required11].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK24].[Level2_Optional_Id] -LEFT JOIN [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32] ON [l1.OneToMany_Required1.OneToOne_Optional_FK24].[Id] = [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional32].[OneToMany_Optional_Inverse4Id] -ORDER BY [l1.OneToMany_Required1.OneToOne_Optional_FK24].[Id]", - // - @"SELECT [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Level3_Optional_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Level3_Required_Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[Name], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Optional_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Optional_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Required_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToMany_Required_Self_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToOne_Optional_PK_Inverse4Id], [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30].[OneToOne_Optional_Self4Id] -FROM [LevelFour] AS [l1.OneToMany_Required1.OneToOne_Optional_FK2.OneToMany_Optional30]"); - } - - public override async Task Null_check_in_anonymous_type_projection_should_not_be_removed(bool async) - { - await base.Null_check_in_anonymous_type_projection_should_not_be_removed(async); - - AssertSql( - @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id], [t].[Id0] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT CASE - WHEN [l1].[Id] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [c], [l1].[Name], [l0].[Id], [l1].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); - } - - public override async Task Null_check_in_Dto_projection_should_not_be_removed(bool async) - { - await base.Null_check_in_Dto_projection_should_not_be_removed(async); - - AssertSql( - @"SELECT [l].[Id], [t].[c], [t].[Name], [t].[Id], [t].[Id0] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT CASE - WHEN [l1].[Id] IS NULL THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) - END AS [c], [l1].[Name], [l0].[Id], [l1].[Id] AS [Id0], [l0].[OneToMany_Optional_Inverse2Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); - } - - public override async Task SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) - { - await base.SelectMany_navigation_property_followed_by_select_collection_navigation(async); - - AssertSql( - @"SELECT [l0].[Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override async Task Multiple_SelectMany_navigation_property_followed_by_select_collection_navigation(bool async) - { - await base.Multiple_SelectMany_navigation_property_followed_by_select_collection_navigation(async); - - AssertSql( - @"SELECT [l1].[Id], [l].[Id], [l0].[Id], [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); - } - - public override async Task SelectMany_navigation_property_with_include_and_followed_by_select_collection_navigation(bool async) - { - await base.SelectMany_navigation_property_with_include_and_followed_by_select_collection_navigation(async); - - AssertSql( - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Required_Inverse3Id] -LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); - } - - public override async Task Include1(bool async) - { - await base.Include1(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); - } - - public override async Task Include2(bool async) - { - await base.Include2(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); - } - - public override async Task Include3(bool async) - { - await base.Include3(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToOne_Optional_PK_Inverse2Id]"); - } - - public override async Task Include4(bool async) + public override async Task Include4(bool async) { await base.Include4(async); @@ -3708,22 +2843,6 @@ FROM [LevelOne] AS [l] LEFT JOIN [LevelThree] AS [l2] ON [l0].[Id] = [l2].[Level2_Optional_Id]"); } - public override void Include15() - { - base.Include15(); - - AssertSql( - @""); - } - - public override void Include16() - { - base.Include16(); - - AssertSql( - @""); - } - public override void Include17() { base.Include17(); @@ -3903,195 +3022,6 @@ FROM [LevelOne] AS [l] ) AS [t]"); } - public override void IncludeCollection1() - { - base.IncludeCollection1(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id]"); - } - - public override void IncludeCollection2() - { - base.IncludeCollection2(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); - } - - public override void IncludeCollection3() - { - base.IncludeCollection3(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - - public override void IncludeCollection4() - { - base.IncludeCollection4(); - - AssertSql( - @"SELECT [l].[Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id]"); - } - - public override void IncludeCollection5() - { - base.IncludeCollection5(); - - AssertSql( - @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0]"); - } - - public override void IncludeCollection6() - { - base.IncludeCollection6(); - - AssertSql( - @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); - } - - public override void IncludeCollection6_1() - { - base.IncludeCollection6_1(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); - } - - public override void IncludeCollection6_2() - { - base.IncludeCollection6_2(); - - AssertSql( - @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id], [t].[Id2], [t].[Level2_Optional_Id0], [t].[Level2_Required_Id0], [t].[Name2], [t].[OneToMany_Optional_Inverse3Id0], [t].[OneToMany_Optional_Self_Inverse3Id0], [t].[OneToMany_Required_Inverse3Id0], [t].[OneToMany_Required_Self_Inverse3Id0], [t].[OneToOne_Optional_PK_Inverse3Id0], [t].[OneToOne_Optional_Self3Id0], [t].[Id3], [t].[Level3_Optional_Id0], [t].[Level3_Required_Id0], [t].[Name3], [t].[OneToMany_Optional_Inverse4Id0], [t].[OneToMany_Optional_Self_Inverse4Id0], [t].[OneToMany_Required_Inverse4Id0], [t].[OneToMany_Required_Self_Inverse4Id0], [t].[OneToOne_Optional_PK_Inverse4Id0], [t].[OneToOne_Optional_Self4Id0] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l3].[Id] AS [Id2], [l3].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l3].[Level2_Required_Id] AS [Level2_Required_Id0], [l3].[Name] AS [Name2], [l3].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l3].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l3].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l3].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l3].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l3].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0], [l4].[Id] AS [Id3], [l4].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l4].[Level3_Required_Id] AS [Level3_Required_Id0], [l4].[Name] AS [Name3], [l4].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l4].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l4].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l4].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l4].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l4].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] - LEFT JOIN [LevelThree] AS [l3] ON [l0].[Id] = [l3].[Level2_Optional_Id] - LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[OneToMany_Optional_Inverse4Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t].[Id3]"); - } - - public override void IncludeCollection6_3() - { - base.IncludeCollection6_3(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id], [t].[Id2], [t].[Level2_Optional_Id0], [t].[Level2_Required_Id0], [t].[Name2], [t].[OneToMany_Optional_Inverse3Id0], [t].[OneToMany_Optional_Self_Inverse3Id0], [t].[OneToMany_Required_Inverse3Id0], [t].[OneToMany_Required_Self_Inverse3Id0], [t].[OneToOne_Optional_PK_Inverse3Id0], [t].[OneToOne_Optional_Self3Id0], [t].[Id3], [t].[Level3_Optional_Id0], [t].[Level3_Required_Id0], [t].[Name3], [t].[OneToMany_Optional_Inverse4Id0], [t].[OneToMany_Optional_Self_Inverse4Id0], [t].[OneToMany_Required_Inverse4Id0], [t].[OneToMany_Required_Self_Inverse4Id0], [t].[OneToOne_Optional_PK_Inverse4Id0], [t].[OneToOne_Optional_Self4Id0] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l3].[Id] AS [Id2], [l3].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l3].[Level2_Required_Id] AS [Level2_Required_Id0], [l3].[Name] AS [Name2], [l3].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l3].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l3].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l3].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l3].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l3].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0], [l4].[Id] AS [Id3], [l4].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l4].[Level3_Required_Id] AS [Level3_Required_Id0], [l4].[Name] AS [Name3], [l4].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l4].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l4].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l4].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l4].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l4].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] - LEFT JOIN [LevelThree] AS [l3] ON [l0].[Id] = [l3].[Level2_Optional_Id] - LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[OneToMany_Optional_Inverse4Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t].[Id3]"); - } - - public override void IncludeCollection6_4() - { - base.IncludeCollection6_4(); - - AssertSql( - @"SELECT [l].[Id], [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id0], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id], [t].[Id1] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id] AS [Id0], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name] AS [Name0], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l0].[Id] AS [Id1], [l0].[OneToMany_Optional_Inverse2Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Optional_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id1], [t].[Id], [t].[Id0]"); - } - - public override void IncludeCollection7() - { - base.IncludeCollection7(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l2] - LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[OneToOne_Optional_PK_Inverse3Id] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t0].[Id], [t0].[Id0]"); - } - - public override async Task IncludeCollection8(bool async) - { - await base.IncludeCollection8(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t].[Id1], [t].[Level3_Optional_Id], [t].[Level3_Required_Id], [t].[Name1], [t].[OneToMany_Optional_Inverse4Id], [t].[OneToMany_Optional_Self_Inverse4Id], [t].[OneToMany_Required_Inverse4Id], [t].[OneToMany_Required_Self_Inverse4Id], [t].[OneToOne_Optional_PK_Inverse4Id], [t].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [l3].[Id] AS [Id0], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name] AS [Name0], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id], [l4].[Id] AS [Id1], [l4].[Level3_Optional_Id], [l4].[Level3_Required_Id], [l4].[Name] AS [Name1], [l4].[OneToMany_Optional_Inverse4Id], [l4].[OneToMany_Optional_Self_Inverse4Id], [l4].[OneToMany_Required_Inverse4Id], [l4].[OneToMany_Required_Self_Inverse4Id], [l4].[OneToOne_Optional_PK_Inverse4Id], [l4].[OneToOne_Optional_Self4Id] - FROM [LevelTwo] AS [l2] - LEFT JOIN [LevelThree] AS [l3] ON [l2].[Id] = [l3].[OneToOne_Optional_PK_Inverse3Id] - LEFT JOIN [LevelFour] AS [l4] ON [l3].[Id] = [l4].[Level3_Optional_Id] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -WHERE ( - SELECT COUNT(*) - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToOne_Optional_PK_Inverse3Id] - WHERE ([l].[Id] = [l0].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL)) > 0 -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t].[Id1]"); - } - public override async Task Include_with_all_method_include_gets_ignored(bool isAsnc) { await base.Include_with_all_method_include_gets_ignored(isAsnc); @@ -4303,43 +3233,6 @@ WHERE [l2].[Id] IS NULL ) AS [t]"); } - public override async Task Lift_projection_mapping_when_pushing_down_subquery(bool async) - { - await base.Lift_projection_mapping_when_pushing_down_subquery(async); - - AssertSql( - @"@__p_0='25' - -SELECT [t].[Id], [t0].[Id], [t0].[c], [l1].[Id] -FROM ( - SELECT TOP(@__p_0) [l].[Id] - FROM [LevelOne] AS [l] -) AS [t] -LEFT JOIN ( - SELECT [t1].[Id], [t1].[c], [t1].[OneToMany_Required_Inverse2Id] - FROM ( - SELECT [l0].[Id], 1 AS [c], [l0].[OneToMany_Required_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Required_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t1] - WHERE [t1].[row] <= 1 -) AS [t0] ON [t].[Id] = [t0].[OneToMany_Required_Inverse2Id] -LEFT JOIN [LevelTwo] AS [l1] ON [t].[Id] = [l1].[OneToMany_Required_Inverse2Id] -ORDER BY [t].[Id], [t0].[Id], [l1].[Id]"); - } - - public override async Task Including_reference_navigation_and_projecting_collection_navigation(bool async) - { - await base.Including_reference_navigation_and_projecting_collection_navigation(async); - - AssertSql( - @"SELECT [l].[Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] -LEFT JOIN [LevelTwo] AS [l2] ON [l].[Id] = [l2].[OneToMany_Required_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id]"); - } - public override async Task Including_reference_navigation_and_projecting_collection_navigation_2(bool async) { await base.Including_reference_navigation_and_projecting_collection_navigation_2(async); @@ -4386,22 +3279,6 @@ FROM [LevelOne] AS [l] WHERE [l0].[Id] IS NOT NULL AND ([l0].[Name] = N'L2 01')"); } - public override async Task LeftJoin_with_Any_on_outer_source_and_projecting_collection_from_inner(bool async) - { - await base.LeftJoin_with_Any_on_outer_source_and_projecting_collection_from_inner(async); - - AssertSql( - @"SELECT CASE - WHEN [l0].[Id] IS NULL THEN 0 - ELSE [l0].[Id] -END, [l].[Id], [l0].[Id], [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Required_Inverse3Id] -WHERE [l].[Name] IN (N'L1 01', N'L1 02') -ORDER BY [l].[Id], [l0].[Id], [l1].[Id]"); - } - public override async Task Sum_with_selector_cast_using_as(bool async) { await base.Sum_with_selector_cast_using_as(async); @@ -4437,1406 +3314,90 @@ FROM [LevelOne] AS [l] WHERE [l].[Id] = [l0].[Id]"); } - public override async Task Select_subquery_single_nested_subquery(bool async) + public override async Task SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(bool async) { - await base.Select_subquery_single_nested_subquery(async); + await base.SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(async); AssertSql( - @"SELECT [t1].[Id], [t1].[Id0], [t1].[c] + @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [t].[Id], [t0].[Id] AS [Id0], [t].[c] - FROM ( - SELECT TOP(1) 1 AS [c], [l0].[Id] - FROM [LevelTwo] AS [l0] - WHERE [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] - ORDER BY [l0].[Id] - ) AS [t] - LEFT JOIN ( - SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id] - FROM [LevelThree] AS [l1] - ) AS [t0] ON [t].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -) AS [t1] -ORDER BY [l].[Id]"); - } - - public override async Task Select_subquery_single_nested_subquery2(bool async) - { - await base.Select_subquery_single_nested_subquery2(async); - - AssertSql( - @"SELECT [l].[Id], [t2].[Id], [t2].[Id0], [t2].[c], [t2].[Id1] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t1].[Id], [t1].[Id0], [t1].[c], [l0].[Id] AS [Id1], [l0].[OneToMany_Optional_Inverse2Id] - FROM [LevelTwo] AS [l0] - OUTER APPLY ( - SELECT [t].[Id], [t0].[Id] AS [Id0], [t].[c] - FROM ( - SELECT TOP(1) 1 AS [c], [l1].[Id] - FROM [LevelThree] AS [l1] - WHERE [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToMany_Optional_Inverse4Id] - FROM [LevelFour] AS [l2] - ) AS [t0] ON [t].[Id] = [t0].[OneToMany_Optional_Inverse4Id] - ) AS [t1] -) AS [t2] ON [l].[Id] = [t2].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t2].[Id1], [t2].[Id], [t2].[Id0]"); - } - - public override async Task SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(bool async) - { - await base.SelectMany_with_outside_reference_to_joined_table_correctly_translated_to_apply(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] -INNER JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] -INNER JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] -LEFT JOIN [LevelOne] AS [l3] ON ([l0].[Id] >= [l3].[Id]) AND (([l2].[Name] = [l3].[Name]) OR ([l2].[Name] IS NULL AND [l3].[Name] IS NULL))"); - } - - public override async Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async) - { - await base.Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(async); - - AssertSql( - @""); - } - - public override void Contains_over_optional_navigation_with_null_constant() - { - base.Contains_over_optional_navigation_with_null_constant(); - - AssertSql( - @"SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [LevelOne] AS [l] - LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] - WHERE [l0].[Id] IS NULL) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END"); - } - - public override async Task Contains_over_optional_navigation_with_null_parameter(bool async) - { - await base.Contains_over_optional_navigation_with_null_parameter(async); - - AssertSql( - @"SELECT CASE - WHEN EXISTS ( - SELECT 1 - FROM [LevelOne] AS [l] - LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] - WHERE [l0].[Id] IS NULL) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END"); - } - - public override async Task Contains_over_optional_navigation_with_null_column(bool async) - { - await base.Contains_over_optional_navigation_with_null_column(async); - - AssertSql( - @"SELECT [l].[Name], [l0].[Name] AS [OptionalName], CASE - WHEN EXISTS ( - SELECT 1 - FROM [LevelOne] AS [l1] - LEFT JOIN [LevelTwo] AS [l2] ON [l1].[Id] = [l2].[Level1_Optional_Id] - WHERE ([l2].[Name] = [l0].[Name]) OR ([l2].[Name] IS NULL AND [l0].[Name] IS NULL)) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Contains] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); - } - - public override async Task Contains_over_optional_navigation_with_null_entity_reference(bool async) - { - await base.Contains_over_optional_navigation_with_null_entity_reference(async); - - AssertSql( - @"SELECT [l].[Name], [l0].[Name] AS [OptionalName], CASE - WHEN EXISTS ( - SELECT 1 - FROM [LevelOne] AS [l2] - LEFT JOIN [LevelTwo] AS [l3] ON [l2].[Id] = [l3].[Level1_Optional_Id] - WHERE ([l3].[Id] = [l1].[Id]) OR ([l3].[Id] IS NULL AND [l1].[Id] IS NULL)) THEN CAST(1 AS bit) - ELSE CAST(0 AS bit) -END AS [Contains] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToOne_Optional_PK_Inverse2Id]"); - } - - public override async Task Filtered_include_basic_Where(bool async) - { - await base.Filtered_include_basic_Where(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l0] - WHERE [l0].[Id] > 5 -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id]"); - } - - public override async Task Filtered_include_OrderBy(bool async) - { - await base.Filtered_include_OrderBy(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l0] -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Name], [t].[Id]"); - } - - public override async Task Filtered_ThenInclude_OrderBy(bool async) - { - await base.Filtered_ThenInclude_OrderBy(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id] AS [Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name] AS [Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelThree] AS [l1] - ) AS [t] ON [l0].[Id] = [t].[OneToMany_Optional_Inverse3Id] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[Name0], [t0].[Id0]"); - } - - public override async Task Filtered_include_ThenInclude_OrderBy(bool async) - { - await base.Filtered_include_ThenInclude_OrderBy(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t].[Id] AS [Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name] AS [Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelThree] AS [l1] - ) AS [t] ON [l0].[Id] = [t].[OneToMany_Optional_Inverse3Id] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[Name], [t0].[Id], [t0].[Name0] DESC, [t0].[Id0]"); - } - - public override async Task Filtered_include_basic_OrderBy_Take(bool async) - { - await base.Filtered_include_basic_OrderBy_Take(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id]"); - } - - public override async Task Filtered_include_basic_OrderBy_Skip(bool async) - { - await base.Filtered_include_basic_OrderBy_Skip(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE 1 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id]"); - } - - public override async Task Filtered_include_basic_OrderBy_Skip_Take(bool async) - { - await base.Filtered_include_basic_OrderBy_Skip_Take(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE (1 < [t].[row]) AND ([t].[row] <= 4) -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id]"); - } - - public override void Filtered_include_Skip_without_OrderBy() - { - base.Filtered_include_Skip_without_OrderBy(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE 1 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override void Filtered_include_Take_without_OrderBy() - { - base.Filtered_include_Take_without_OrderBy(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override async Task Filtered_include_on_ThenInclude(bool async) - { - await base.Filtered_include_on_ThenInclude(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE (1 < [t].[row]) AND ([t].[row] <= 4) -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name], [t0].[Id]"); - } - - public override async Task Filtered_include_after_reference_navigation(bool async) - { - await base.Filtered_include_after_reference_navigation(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -LEFT JOIN ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE (1 < [t].[row]) AND ([t].[row] <= 4) -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name], [t0].[Id]"); - } - - public override async Task Filtered_include_after_different_filtered_include_same_level(bool async) - { - await base.Filtered_include_after_different_filtered_include_same_level(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -LEFT JOIN ( - SELECT [t2].[Id], [t2].[Date], [t2].[Level1_Optional_Id], [t2].[Level1_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse2Id], [t2].[OneToMany_Optional_Self_Inverse2Id], [t2].[OneToMany_Required_Inverse2Id], [t2].[OneToMany_Required_Self_Inverse2Id], [t2].[OneToOne_Optional_PK_Inverse2Id], [t2].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse2Id] ORDER BY [l1].[Name] DESC) AS [row] - FROM [LevelTwo] AS [l1] - WHERE ([l1].[Name] <> N'Bar') OR [l1].[Name] IS NULL - ) AS [t2] - WHERE 1 < [t2].[row] -) AS [t1] ON [l].[Id] = [t1].[OneToMany_Required_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t0].[Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[Name] DESC, [t1].[Id]"); - } - - public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) - { - await base.Filtered_include_after_different_filtered_include_different_level(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t2].[Id], [t2].[Date], [t2].[Level1_Optional_Id], [t2].[Level1_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse2Id], [t2].[OneToMany_Optional_Self_Inverse2Id], [t2].[OneToMany_Required_Inverse2Id], [t2].[OneToMany_Required_Self_Inverse2Id], [t2].[OneToOne_Optional_PK_Inverse2Id], [t2].[OneToOne_Optional_Self2Id], [t2].[Id0], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Name0], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Optional_Self_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToMany_Required_Self_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id], [t2].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t0].[Id] AS [Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name] AS [Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] - FROM ( - SELECT TOP(3) [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l0] - WHERE ([l].[Id] = [l0].[OneToMany_Optional_Inverse2Id]) AND (([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL) - ORDER BY [l0].[Name] - ) AS [t] - LEFT JOIN ( - SELECT [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Bar') OR [l1].[Name] IS NULL - ) AS [t1] - WHERE 1 < [t1].[row] - ) AS [t0] ON [t].[Id] = [t0].[OneToMany_Required_Inverse3Id] -) AS [t2] -ORDER BY [l].[Id], [t2].[Name], [t2].[Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[Name0] DESC, [t2].[Id0]"); - } - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice(bool async) - { - await base.Filtered_include_same_filter_set_on_same_navigation_twice(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id] DESC) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 2 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id] DESC"); - } - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) - { - await base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Id1], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Level2_Optional_Id0], [t0].[Level2_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse3Id0], [t0].[OneToMany_Optional_Self_Inverse3Id0], [t0].[OneToMany_Required_Inverse3Id0], [t0].[OneToMany_Required_Self_Inverse3Id0], [t0].[OneToOne_Optional_PK_Inverse3Id0], [t0].[OneToOne_Optional_Self3Id0] -FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l1].[Id] AS [Id1], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l0].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l0].[Level2_Required_Id] AS [Level2_Required_Id0], [l0].[Name] AS [Name1], [l0].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l0].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l0].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l0].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l0].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l0].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0] - FROM ( - SELECT TOP(2) [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l2] - WHERE ([l].[Id] = [l2].[OneToMany_Optional_Inverse2Id]) AND (([l2].[Name] <> N'Foo') OR [l2].[Name] IS NULL) - ORDER BY [l2].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] - LEFT JOIN [LevelThree] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -) AS [t0] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id1]"); - } - - public override async Task - Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) - { - await base - .Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Id1], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Level2_Optional_Id0], [t0].[Level2_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse3Id0], [t0].[OneToMany_Optional_Self_Inverse3Id0], [t0].[OneToMany_Required_Inverse3Id0], [t0].[OneToMany_Required_Self_Inverse3Id0], [t0].[OneToOne_Optional_PK_Inverse3Id0], [t0].[OneToOne_Optional_Self3Id0] -FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l1].[Id] AS [Id1], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], [l0].[Level2_Optional_Id] AS [Level2_Optional_Id0], [l0].[Level2_Required_Id] AS [Level2_Required_Id0], [l0].[Name] AS [Name1], [l0].[OneToMany_Optional_Inverse3Id] AS [OneToMany_Optional_Inverse3Id0], [l0].[OneToMany_Optional_Self_Inverse3Id] AS [OneToMany_Optional_Self_Inverse3Id0], [l0].[OneToMany_Required_Inverse3Id] AS [OneToMany_Required_Inverse3Id0], [l0].[OneToMany_Required_Self_Inverse3Id] AS [OneToMany_Required_Self_Inverse3Id0], [l0].[OneToOne_Optional_PK_Inverse3Id] AS [OneToOne_Optional_PK_Inverse3Id0], [l0].[OneToOne_Optional_Self3Id] AS [OneToOne_Optional_Self3Id0] - FROM ( - SELECT TOP(2) [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l2] - WHERE ([l].[Id] = [l2].[OneToMany_Optional_Inverse2Id]) AND (([l2].[Name] <> N'Foo') OR [l2].[Name] IS NULL) - ORDER BY [l2].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] - LEFT JOIN [LevelThree] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -) AS [t0] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0], [t0].[Id1]"); - } - - public override async Task Filtered_include_and_non_filtered_include_on_same_navigation1(bool async) - { - await base.Filtered_include_and_non_filtered_include_on_same_navigation1(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override async Task Filtered_include_and_non_filtered_include_on_same_navigation2(bool async) - { - await base.Filtered_include_and_non_filtered_include_on_same_navigation2(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) - { - await base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [t1].[Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [t1].[Id1], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name1], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id] -FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id], [t0].[Id] AS [Id1], [t0].[Level3_Optional_Id], [t0].[Level3_Required_Id], [t0].[Name] AS [Name1], [t0].[OneToMany_Optional_Inverse4Id], [t0].[OneToMany_Optional_Self_Inverse4Id], [t0].[OneToMany_Required_Inverse4Id], [t0].[OneToMany_Required_Self_Inverse4Id], [t0].[OneToOne_Optional_PK_Inverse4Id], [t0].[OneToOne_Optional_Self4Id] - FROM ( - SELECT TOP(1) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l1] - WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[OneToOne_Optional_PK_Inverse3Id] - LEFT JOIN ( - SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] - FROM [LevelFour] AS [l2] - WHERE [l2].[Id] > 1 - ) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse4Id] -) AS [t1] -ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id1]"); - } - - public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) - { - await base.Filtered_include_complex_three_level_with_middle_having_filter1(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [t1].[Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [t1].[Id00], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name00], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id], [t1].[Id1], [t1].[Level3_Optional_Id0], [t1].[Level3_Required_Id0], [t1].[Name1], [t1].[OneToMany_Optional_Inverse4Id0], [t1].[OneToMany_Optional_Self_Inverse4Id0], [t1].[OneToMany_Required_Inverse4Id0], [t1].[OneToMany_Required_Self_Inverse4Id0], [t1].[OneToOne_Optional_PK_Inverse4Id0], [t1].[OneToOne_Optional_Self4Id0] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id] AS [Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name] AS [Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Id0] AS [Id00], [t0].[Level3_Optional_Id], [t0].[Level3_Required_Id], [t0].[Name0] AS [Name00], [t0].[OneToMany_Optional_Inverse4Id], [t0].[OneToMany_Optional_Self_Inverse4Id], [t0].[OneToMany_Required_Inverse4Id], [t0].[OneToMany_Required_Self_Inverse4Id], [t0].[OneToOne_Optional_PK_Inverse4Id], [t0].[OneToOne_Optional_Self4Id], [t0].[Id1], [t0].[Level3_Optional_Id0], [t0].[Level3_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse4Id0], [t0].[OneToMany_Optional_Self_Inverse4Id0], [t0].[OneToMany_Required_Inverse4Id0], [t0].[OneToMany_Required_Self_Inverse4Id0], [t0].[OneToOne_Optional_PK_Inverse4Id0], [t0].[OneToOne_Optional_Self4Id0] - FROM [LevelTwo] AS [l0] - OUTER APPLY ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [l1].[Id] AS [Id0], [l1].[Level3_Optional_Id], [l1].[Level3_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse4Id], [l1].[OneToMany_Optional_Self_Inverse4Id], [l1].[OneToMany_Required_Inverse4Id], [l1].[OneToMany_Required_Self_Inverse4Id], [l1].[OneToOne_Optional_PK_Inverse4Id], [l1].[OneToOne_Optional_Self4Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l2].[Level3_Required_Id] AS [Level3_Required_Id0], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l2].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l2].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l2].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l2].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l2].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] - FROM ( - SELECT TOP(1) [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] - FROM [LevelThree] AS [l3] - WHERE ([l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id]) AND (([l3].[Name] <> N'Foo') OR [l3].[Name] IS NULL) - ORDER BY [l3].[Id] - ) AS [t] - LEFT JOIN [LevelFour] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse4Id] - LEFT JOIN [LevelFour] AS [l2] ON [t].[Id] = [l2].[OneToMany_Required_Inverse4Id] - ) AS [t0] -) AS [t1] ON [l].[Id] = [t1].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id00], [t1].[Id1]"); - } - - public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) - { - await base.Filtered_include_complex_three_level_with_middle_having_filter2(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [t1].[Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [t1].[Id00], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name00], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id], [t1].[Id1], [t1].[Level3_Optional_Id0], [t1].[Level3_Required_Id0], [t1].[Name1], [t1].[OneToMany_Optional_Inverse4Id0], [t1].[OneToMany_Optional_Self_Inverse4Id0], [t1].[OneToMany_Required_Inverse4Id0], [t1].[OneToMany_Required_Self_Inverse4Id0], [t1].[OneToOne_Optional_PK_Inverse4Id0], [t1].[OneToOne_Optional_Self4Id0] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [t0].[Id] AS [Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name] AS [Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [t0].[Id0] AS [Id00], [t0].[Level3_Optional_Id], [t0].[Level3_Required_Id], [t0].[Name0] AS [Name00], [t0].[OneToMany_Optional_Inverse4Id], [t0].[OneToMany_Optional_Self_Inverse4Id], [t0].[OneToMany_Required_Inverse4Id], [t0].[OneToMany_Required_Self_Inverse4Id], [t0].[OneToOne_Optional_PK_Inverse4Id], [t0].[OneToOne_Optional_Self4Id], [t0].[Id1], [t0].[Level3_Optional_Id0], [t0].[Level3_Required_Id0], [t0].[Name1], [t0].[OneToMany_Optional_Inverse4Id0], [t0].[OneToMany_Optional_Self_Inverse4Id0], [t0].[OneToMany_Required_Inverse4Id0], [t0].[OneToMany_Required_Self_Inverse4Id0], [t0].[OneToOne_Optional_PK_Inverse4Id0], [t0].[OneToOne_Optional_Self4Id0] - FROM [LevelTwo] AS [l0] - OUTER APPLY ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [l1].[Id] AS [Id0], [l1].[Level3_Optional_Id], [l1].[Level3_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse4Id], [l1].[OneToMany_Optional_Self_Inverse4Id], [l1].[OneToMany_Required_Inverse4Id], [l1].[OneToMany_Required_Self_Inverse4Id], [l1].[OneToOne_Optional_PK_Inverse4Id], [l1].[OneToOne_Optional_Self4Id], [l2].[Id] AS [Id1], [l2].[Level3_Optional_Id] AS [Level3_Optional_Id0], [l2].[Level3_Required_Id] AS [Level3_Required_Id0], [l2].[Name] AS [Name1], [l2].[OneToMany_Optional_Inverse4Id] AS [OneToMany_Optional_Inverse4Id0], [l2].[OneToMany_Optional_Self_Inverse4Id] AS [OneToMany_Optional_Self_Inverse4Id0], [l2].[OneToMany_Required_Inverse4Id] AS [OneToMany_Required_Inverse4Id0], [l2].[OneToMany_Required_Self_Inverse4Id] AS [OneToMany_Required_Self_Inverse4Id0], [l2].[OneToOne_Optional_PK_Inverse4Id] AS [OneToOne_Optional_PK_Inverse4Id0], [l2].[OneToOne_Optional_Self4Id] AS [OneToOne_Optional_Self4Id0] - FROM ( - SELECT TOP(1) [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] - FROM [LevelThree] AS [l3] - WHERE ([l0].[Id] = [l3].[OneToMany_Optional_Inverse3Id]) AND (([l3].[Name] <> N'Foo') OR [l3].[Name] IS NULL) - ORDER BY [l3].[Id] - ) AS [t] - LEFT JOIN [LevelFour] AS [l1] ON [t].[Id] = [l1].[OneToMany_Optional_Inverse4Id] - LEFT JOIN [LevelFour] AS [l2] ON [t].[Id] = [l2].[OneToMany_Required_Inverse4Id] - ) AS [t0] -) AS [t1] ON [l].[Id] = [t1].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t1].[Id], [t1].[Id0], [t1].[Id00], [t1].[Id1]"); - } - - public override void Filtered_include_variable_used_inside_filter() - { - base.Filtered_include_variable_used_inside_filter(); - - AssertSql( - @"@__prm_0='Foo' (Size = 4000) - -SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> @__prm_0) OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override void Filtered_include_context_accessed_inside_filter() - { - base.Filtered_include_context_accessed_inside_filter(); - - AssertSql( - @"SELECT COUNT(*) -FROM [LevelOne] AS [l]", - // - @"@__p_0='True' - -SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE @__p_0 = CAST(1 AS bit) - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override void Filtered_include_context_accessed_inside_filter_correlated() - { - base.Filtered_include_context_accessed_inside_filter_correlated(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ( - SELECT COUNT(*) - FROM [LevelOne] AS [l1] - WHERE [l1].[Id] <> [l0].[Id]) > 1 - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override async Task Filtered_include_outer_parameter_used_inside_filter(bool async) - { - await base.Filtered_include_outer_parameter_used_inside_filter(async); - - AssertSql( - @"SELECT [l].[Id], [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [t].[Id0], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name0], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id], [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l1].[Id] AS [Id0], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name] AS [Name0], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l0] - LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[OneToMany_Optional_Inverse3Id] -) AS [t] -OUTER APPLY ( - SELECT [l2].[Id], [l2].[Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Optional_Self_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToMany_Required_Self_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l2].[OneToOne_Optional_Self2Id], [t1].[Id] AS [Id0], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name] AS [Name0], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id] - FROM [LevelTwo] AS [l2] - LEFT JOIN ( - SELECT [l3].[Id], [l3].[Level2_Optional_Id], [l3].[Level2_Required_Id], [l3].[Name], [l3].[OneToMany_Optional_Inverse3Id], [l3].[OneToMany_Optional_Self_Inverse3Id], [l3].[OneToMany_Required_Inverse3Id], [l3].[OneToMany_Required_Self_Inverse3Id], [l3].[OneToOne_Optional_PK_Inverse3Id], [l3].[OneToOne_Optional_Self3Id] - FROM [LevelThree] AS [l3] - WHERE [l3].[Id] <> [l].[Id] - ) AS [t1] ON [l2].[Id] = [t1].[OneToMany_Optional_Inverse3Id] -) AS [t0] -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t0].[Id], [t0].[Id0]"); - } - - public override async Task Filtered_include_basic_Where_split(bool async) - { - await base.Filtered_include_basic_Where_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l0] - WHERE [l0].[Id] > 5 -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id]"); - } - - public override async Task Filtered_include_OrderBy_split(bool async) - { - await base.Filtered_include_OrderBy_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE 0 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); - } - - public override async Task Filtered_ThenInclude_OrderBy_split(bool async) - { - await base.Filtered_ThenInclude_OrderBy_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id]", - // - @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] - FROM [LevelThree] AS [l1] - ) AS [t] - WHERE 0 < [t].[row] -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name]"); - } - - public override async Task Filtered_include_ThenInclude_OrderBy_split(bool async) - { - await base.Filtered_include_ThenInclude_OrderBy_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE 0 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]", - // - @"SELECT [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id] - FROM ( - SELECT [l0].[Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE 0 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t2].[Id], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Optional_Self_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToMany_Required_Self_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id], [t2].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] - FROM [LevelThree] AS [l1] - ) AS [t2] - WHERE 0 < [t2].[row] -) AS [t1] ON [t0].[Id] = [t1].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[Name] DESC"); - } - - public override async Task Filtered_include_basic_OrderBy_Take_split(bool async) - { - await base.Filtered_include_basic_OrderBy_Take_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); - } - - public override async Task Filtered_include_basic_OrderBy_Skip_split(bool async) - { - await base.Filtered_include_basic_OrderBy_Skip_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE 1 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); - } - - public override async Task Filtered_include_basic_OrderBy_Skip_Take_split(bool async) - { - await base.Filtered_include_basic_OrderBy_Skip_Take_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE (1 < [t].[row]) AND ([t].[row] <= 4) -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]"); - } - - public override void Filtered_include_Skip_without_OrderBy_split() - { - base.Filtered_include_Skip_without_OrderBy_split(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE 1 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override void Filtered_include_Take_without_OrderBy_split() - { - base.Filtered_include_Take_without_OrderBy_split(); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override async Task Filtered_include_on_ThenInclude_split(bool async) - { - await base.Filtered_include_on_ThenInclude_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -ORDER BY [l].[Id], [l0].[Id]", - // - @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -INNER JOIN ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE (1 < [t].[row]) AND ([t].[row] <= 4) -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name]"); - } - - public override async Task Filtered_include_after_reference_navigation_split(bool async) - { - await base.Filtered_include_after_reference_navigation_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id], [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -ORDER BY [l].[Id], [l0].[Id]", - // - @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] -INNER JOIN ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Name]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE (1 < [t].[row]) AND ([t].[row] <= 4) -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[OneToMany_Optional_Inverse3Id], [t0].[Name]"); - } - - public override async Task Filtered_include_after_different_filtered_include_same_level_split(bool async) - { - await base.Filtered_include_after_different_filtered_include_same_level_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Required_Inverse2Id] ORDER BY [l0].[Name] DESC) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Bar') OR [l0].[Name] IS NULL - ) AS [t] - WHERE 1 < [t].[row] -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Required_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[Name] DESC"); - } - - public override async Task Filtered_include_after_different_filtered_include_different_level_split(bool async) - { - await base.Filtered_include_after_different_filtered_include_different_level_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name]", - // - @"SELECT [t1].[Id], [t1].[Level2_Optional_Id], [t1].[Level2_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse3Id], [t1].[OneToMany_Optional_Self_Inverse3Id], [t1].[OneToMany_Required_Inverse3Id], [t1].[OneToMany_Required_Self_Inverse3Id], [t1].[OneToOne_Optional_PK_Inverse3Id], [t1].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id] - FROM ( - SELECT [l0].[Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Name]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t2].[Id], [t2].[Level2_Optional_Id], [t2].[Level2_Required_Id], [t2].[Name], [t2].[OneToMany_Optional_Inverse3Id], [t2].[OneToMany_Optional_Self_Inverse3Id], [t2].[OneToMany_Required_Inverse3Id], [t2].[OneToMany_Required_Self_Inverse3Id], [t2].[OneToOne_Optional_PK_Inverse3Id], [t2].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Required_Inverse3Id] ORDER BY [l1].[Name] DESC) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Bar') OR [l1].[Name] IS NULL - ) AS [t2] - WHERE 1 < [t2].[row] -) AS [t1] ON [t0].[Id] = [t1].[OneToMany_Required_Inverse3Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Name], [t1].[OneToMany_Required_Inverse3Id], [t1].[Name] DESC"); - } - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_split(bool async) - { - await base.Filtered_include_same_filter_set_on_same_navigation_twice_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id] DESC) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 2 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id] DESC"); - } - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async) - { - await base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -CROSS APPLY ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] - FROM ( - SELECT TOP(2) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l1] - WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] -) AS [t0] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]", - // - @"SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id], [t0].[Id0] -FROM [LevelOne] AS [l] -CROSS APPLY ( - SELECT [t].[Id], [l0].[Id] AS [Id0] - FROM ( - SELECT TOP(2) [l1].[Id] - FROM [LevelTwo] AS [l1] - WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] -) AS [t0] -INNER JOIN [LevelThree] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]"); - } - - public override async Task - Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) - { - await base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split( - async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id] -FROM [LevelOne] AS [l] -CROSS APPLY ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] - FROM ( - SELECT TOP(2) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l1] - WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] -) AS [t0] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]", - // - @"SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Optional_Self_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToMany_Required_Self_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [l2].[OneToOne_Optional_Self3Id], [l].[Id], [t0].[Id], [t0].[Id0] -FROM [LevelOne] AS [l] -CROSS APPLY ( - SELECT [t].[Id], [l0].[Id] AS [Id0] - FROM ( - SELECT TOP(2) [l1].[Id] - FROM [LevelTwo] AS [l1] - WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[Level2_Required_Id] -) AS [t0] -INNER JOIN [LevelThree] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]"); - } - - public override async Task Filtered_include_and_non_filtered_include_on_same_navigation1_split(bool async) - { - await base.Filtered_include_and_non_filtered_include_on_same_navigation1_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override async Task Filtered_include_and_non_filtered_include_on_same_navigation2_split(bool async) - { - await base.Filtered_include_and_non_filtered_include_on_same_navigation2_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async) - { - await base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [t0].[Id0], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name0], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id] -FROM [LevelOne] AS [l] -CROSS APPLY ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id], [l0].[Id] AS [Id0], [l0].[Level2_Optional_Id], [l0].[Level2_Required_Id], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Inverse3Id], [l0].[OneToMany_Optional_Self_Inverse3Id], [l0].[OneToMany_Required_Inverse3Id], [l0].[OneToMany_Required_Self_Inverse3Id], [l0].[OneToOne_Optional_PK_Inverse3Id], [l0].[OneToOne_Optional_Self3Id] - FROM ( - SELECT TOP(1) [l1].[Id], [l1].[Date], [l1].[Level1_Optional_Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse2Id], [l1].[OneToMany_Optional_Self_Inverse2Id], [l1].[OneToMany_Required_Inverse2Id], [l1].[OneToMany_Required_Self_Inverse2Id], [l1].[OneToOne_Optional_PK_Inverse2Id], [l1].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l1] - WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[OneToOne_Optional_PK_Inverse3Id] -) AS [t0] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]", - // - @"SELECT [t1].[Id], [t1].[Level3_Optional_Id], [t1].[Level3_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse4Id], [t1].[OneToMany_Optional_Self_Inverse4Id], [t1].[OneToMany_Required_Inverse4Id], [t1].[OneToMany_Required_Self_Inverse4Id], [t1].[OneToOne_Optional_PK_Inverse4Id], [t1].[OneToOne_Optional_Self4Id], [l].[Id], [t0].[Id], [t0].[Id0] -FROM [LevelOne] AS [l] -CROSS APPLY ( - SELECT [t].[Id], [l0].[Id] AS [Id0] - FROM ( - SELECT TOP(1) [l1].[Id] - FROM [LevelTwo] AS [l1] - WHERE ([l].[Id] = [l1].[OneToMany_Optional_Inverse2Id]) AND (([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL) - ORDER BY [l1].[Id] - ) AS [t] - LEFT JOIN [LevelThree] AS [l0] ON [t].[Id] = [l0].[OneToOne_Optional_PK_Inverse3Id] -) AS [t0] -INNER JOIN ( - SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id] - FROM [LevelFour] AS [l2] - WHERE [l2].[Id] > 1 -) AS [t1] ON [t0].[Id0] = [t1].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [t0].[Id], [t0].[Id0]"); +INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] +INNER JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Required_Id] +INNER JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[Level3_Required_Id] +LEFT JOIN [LevelOne] AS [l3] ON ([l0].[Id] >= [l3].[Id]) AND (([l2].[Name] = [l3].[Name]) OR ([l2].[Name] IS NULL AND [l3].[Name] IS NULL))"); } - public override async Task Filtered_include_complex_three_level_with_middle_having_filter1_split(bool async) + public override async Task Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(bool async) { - await base.Filtered_include_complex_three_level_with_middle_having_filter1_split(async); + await base.Nested_SelectMany_correlated_with_join_table_correctly_translated_to_apply(async); AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id]", - // - @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", - // - @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] - FROM ( - SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", - // - @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] - FROM ( - SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Required_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]"); + @""); } - public override async Task Filtered_include_complex_three_level_with_middle_having_filter2_split(bool async) + public override void Contains_over_optional_navigation_with_null_constant() { - await base.Filtered_include_complex_three_level_with_middle_having_filter2_split(async); + base.Contains_over_optional_navigation_with_null_constant(); AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [l0].[Id]", - // - @"SELECT [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Optional_Self_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToMany_Required_Self_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[OneToOne_Optional_Self3Id], [l].[Id], [l0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t].[Id], [t].[Level2_Optional_Id], [t].[Level2_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse3Id], [t].[OneToMany_Optional_Self_Inverse3Id], [t].[OneToMany_Required_Inverse3Id], [t].[OneToMany_Required_Self_Inverse3Id], [t].[OneToOne_Optional_PK_Inverse3Id], [t].[OneToOne_Optional_Self3Id] - FROM ( - SELECT [l1].[Id], [l1].[Level2_Optional_Id], [l1].[Level2_Required_Id], [l1].[Name], [l1].[OneToMany_Optional_Inverse3Id], [l1].[OneToMany_Optional_Self_Inverse3Id], [l1].[OneToMany_Required_Inverse3Id], [l1].[OneToMany_Required_Self_Inverse3Id], [l1].[OneToOne_Optional_PK_Inverse3Id], [l1].[OneToOne_Optional_Self3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", - // - @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] - FROM ( - SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Optional_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]", - // - @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [t0].[Id] -FROM [LevelOne] AS [l] -INNER JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[OneToMany_Optional_Inverse2Id] -INNER JOIN ( - SELECT [t].[Id], [t].[OneToMany_Optional_Inverse3Id] - FROM ( - SELECT [l1].[Id], [l1].[OneToMany_Optional_Inverse3Id], ROW_NUMBER() OVER(PARTITION BY [l1].[OneToMany_Optional_Inverse3Id] ORDER BY [l1].[Id]) AS [row] - FROM [LevelThree] AS [l1] - WHERE ([l1].[Name] <> N'Foo') OR [l1].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 1 -) AS [t0] ON [l0].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -INNER JOIN [LevelFour] AS [l2] ON [t0].[Id] = [l2].[OneToMany_Required_Inverse4Id] -ORDER BY [l].[Id], [l0].[Id], [t0].[Id], [t0].[OneToMany_Optional_Inverse3Id]"); + @"SELECT CASE + WHEN EXISTS ( + SELECT 1 + FROM [LevelOne] AS [l] + LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] + WHERE [l0].[Id] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END"); } - public override void Filtered_include_variable_used_inside_filter_split() + public override async Task Contains_over_optional_navigation_with_null_parameter(bool async) { - base.Filtered_include_variable_used_inside_filter_split(); + await base.Contains_over_optional_navigation_with_null_parameter(async); AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"@__prm_0='Foo' (Size = 4000) - -SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] -FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ([l0].[Name] <> @__prm_0) OR [l0].[Name] IS NULL - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); + @"SELECT CASE + WHEN EXISTS ( + SELECT 1 + FROM [LevelOne] AS [l] + LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] + WHERE [l0].[Id] IS NULL) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END"); } - public override void Filtered_include_context_accessed_inside_filter_split() + public override async Task Contains_over_optional_navigation_with_null_column(bool async) { - base.Filtered_include_context_accessed_inside_filter_split(); + await base.Contains_over_optional_navigation_with_null_column(async); AssertSql( - @"SELECT COUNT(*) -FROM [LevelOne] AS [l]", - // - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"@__p_0='True' - -SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] + @"SELECT [l].[Name], [l0].[Name] AS [OptionalName], CASE + WHEN EXISTS ( + SELECT 1 + FROM [LevelOne] AS [l1] + LEFT JOIN [LevelTwo] AS [l2] ON [l1].[Id] = [l2].[Level1_Optional_Id] + WHERE ([l2].[Name] = [l0].[Name]) OR ([l2].[Name] IS NULL AND [l0].[Name] IS NULL)) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Contains] FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE @__p_0 = CAST(1 AS bit) - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id]"); } - public override void Filtered_include_context_accessed_inside_filter_correlated_split() + public override async Task Contains_over_optional_navigation_with_null_entity_reference(bool async) { - base.Filtered_include_context_accessed_inside_filter_correlated_split(); + await base.Contains_over_optional_navigation_with_null_entity_reference(async); AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [l].[OneToMany_Optional_Self_Inverse1Id], [l].[OneToMany_Required_Self_Inverse1Id], [l].[OneToOne_Optional_Self1Id] -FROM [LevelOne] AS [l] -ORDER BY [l].[Id]", - // - @"SELECT [t0].[Id], [t0].[Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Optional_Self_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToMany_Required_Self_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[OneToOne_Optional_Self2Id], [l].[Id] + @"SELECT [l].[Name], [l0].[Name] AS [OptionalName], CASE + WHEN EXISTS ( + SELECT 1 + FROM [LevelOne] AS [l2] + LEFT JOIN [LevelTwo] AS [l3] ON [l2].[Id] = [l3].[Level1_Optional_Id] + WHERE ([l3].[Id] = [l1].[Id]) OR ([l3].[Id] IS NULL AND [l1].[Id] IS NULL)) THEN CAST(1 AS bit) + ELSE CAST(0 AS bit) +END AS [Contains] FROM [LevelOne] AS [l] -INNER JOIN ( - SELECT [t].[Id], [t].[Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Optional_Self_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToMany_Required_Self_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [t].[OneToOne_Optional_Self2Id] - FROM ( - SELECT [l0].[Id], [l0].[Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Optional_Self_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToMany_Required_Self_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l0].[OneToOne_Optional_Self2Id], ROW_NUMBER() OVER(PARTITION BY [l0].[OneToMany_Optional_Inverse2Id] ORDER BY [l0].[Id]) AS [row] - FROM [LevelTwo] AS [l0] - WHERE ( - SELECT COUNT(*) - FROM [LevelOne] AS [l1] - WHERE [l1].[Id] <> [l0].[Id]) > 1 - ) AS [t] - WHERE [t].[row] <= 3 -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t0].[OneToMany_Optional_Inverse2Id], [t0].[Id]"); - } - - public override void Filtered_include_outer_parameter_used_inside_filter_split() - { - base.Filtered_include_outer_parameter_used_inside_filter_split(); - - AssertSql(" "); +LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Optional_Id] +LEFT JOIN [LevelTwo] AS [l1] ON [l].[Id] = [l1].[OneToOne_Optional_PK_Inverse2Id]"); } public override async Task Element_selector_with_coalesce_repeated_in_aggregate(bool async) @@ -6128,32 +3689,6 @@ FROM [LevelOne] AS [l] ) AS [t]"); } - public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) - { - await base.Complex_query_with_let_collection_projection_FirstOrDefault(async); - - AssertSql( - @"SELECT [t1].[Id], [t1].[Name], [t1].[Id0], [t1].[c] -FROM [LevelOne] AS [l] -OUTER APPLY ( - SELECT [t].[Id], [t0].[Name], [t0].[Id] AS [Id0], [t].[c] - FROM ( - SELECT TOP(1) 1 AS [c], [l0].[Id] - FROM [LevelTwo] AS [l0] - WHERE ([l].[Id] = [l0].[OneToMany_Optional_Inverse2Id]) AND (([l0].[Name] <> N'Foo') OR [l0].[Name] IS NULL) - ) AS [t] - OUTER APPLY ( - SELECT [l1].[Name], [l1].[Id] - FROM [LevelOne] AS [l1] - WHERE EXISTS ( - SELECT 1 - FROM [LevelTwo] AS [l2] - WHERE ([l1].[Id] = [l2].[OneToMany_Optional_Inverse2Id]) AND ([l2].[Id] = [t].[Id])) - ) AS [t0] -) AS [t1] -ORDER BY [l].[Id]"); - } - public override async Task Project_shadow_properties(bool async) { await base.Project_shadow_properties(async); @@ -6192,97 +3727,6 @@ FROM [InheritanceOne] AS [i] FROM [InheritanceLeafTwo] AS [i]"); } - public override async Task SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(bool async) - { - await base.SelectMany_DefaultIfEmpty_multiple_times_with_joins_projecting_a_collection(async); - - AssertSql( - @"SELECT [l2].[Id], [l2].[Level3_Optional_Id], [l2].[Level3_Required_Id], [l2].[Name], [l2].[OneToMany_Optional_Inverse4Id], [l2].[OneToMany_Optional_Self_Inverse4Id], [l2].[OneToMany_Required_Inverse4Id], [l2].[OneToMany_Required_Self_Inverse4Id], [l2].[OneToOne_Optional_PK_Inverse4Id], [l2].[OneToOne_Optional_Self4Id], [l].[Id], [l0].[Id], [l1].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l12].[Id], [l13].[Id], [l14].[Id], [t1].[Id], [t1].[Date], [t1].[Level1_Optional_Id], [t1].[Level1_Required_Id], [t1].[Name], [t1].[OneToMany_Optional_Inverse2Id], [t1].[OneToMany_Optional_Self_Inverse2Id], [t1].[OneToMany_Required_Inverse2Id], [t1].[OneToMany_Required_Self_Inverse2Id], [t1].[OneToOne_Optional_PK_Inverse2Id], [t1].[OneToOne_Optional_Self2Id], [l14].[Name] -FROM [LevelOne] AS [l] -LEFT JOIN [LevelTwo] AS [l0] ON [l].[Id] = [l0].[Level1_Required_Id] -LEFT JOIN [LevelThree] AS [l1] ON [l0].[Id] = [l1].[Level2_Optional_Id] -LEFT JOIN [LevelFour] AS [l2] ON [l1].[Id] = [l2].[OneToMany_Required_Inverse4Id] -INNER JOIN ( - SELECT [l3].[Id], [l4].[Id] AS [Id0], [l5].[Id] AS [Id1], [l6].[Id] AS [Id2] - FROM [LevelFour] AS [l3] - INNER JOIN [LevelThree] AS [l4] ON [l3].[Level3_Required_Id] = [l4].[Id] - LEFT JOIN [LevelTwo] AS [l5] ON [l4].[Level2_Optional_Id] = [l5].[Id] - LEFT JOIN [LevelTwo] AS [l6] ON [l5].[Id] = [l6].[OneToMany_Required_Self_Inverse2Id] -) AS [t] ON [l2].[Id] = [t].[Id2] -LEFT JOIN ( - SELECT [l7].[Id], [l8].[Id] AS [Id0], [l9].[Id] AS [Id1], [l10].[Id] AS [Id2], [l10].[Level2_Optional_Id] AS [Level2_Optional_Id0] - FROM [LevelFour] AS [l7] - INNER JOIN [LevelThree] AS [l8] ON [l7].[Level3_Required_Id] = [l8].[Id] - INNER JOIN [LevelTwo] AS [l9] ON [l8].[Level2_Required_Id] = [l9].[Id] - LEFT JOIN [LevelThree] AS [l10] ON [l9].[Id] = [l10].[OneToMany_Required_Inverse3Id] -) AS [t0] ON [t].[Id2] = [t0].[Id2] -LEFT JOIN [LevelThree] AS [l11] ON [l2].[OneToMany_Optional_Inverse4Id] = [l11].[Id] -LEFT JOIN [LevelThree] AS [l12] ON [t].[Id2] = [l12].[Level2_Optional_Id] -LEFT JOIN [LevelTwo] AS [l13] ON [t0].[Level2_Optional_Id0] = [l13].[Id] -LEFT JOIN [LevelThree] AS [l14] ON [l13].[Id] = [l14].[Level2_Required_Id] -LEFT JOIN ( - SELECT [l15].[Id], [l15].[Date], [l15].[Level1_Optional_Id], [l15].[Level1_Required_Id], [l15].[Name], [l15].[OneToMany_Optional_Inverse2Id], [l15].[OneToMany_Optional_Self_Inverse2Id], [l15].[OneToMany_Required_Inverse2Id], [l15].[OneToMany_Required_Self_Inverse2Id], [l15].[OneToOne_Optional_PK_Inverse2Id], [l15].[OneToOne_Optional_Self2Id] - FROM [LevelTwo] AS [l15] - WHERE [l15].[Id] <> 42 -) AS [t1] ON [t].[Id2] = [t1].[OneToMany_Optional_Self_Inverse2Id] -WHERE ([l11].[Name] <> N'Foo') OR [l11].[Name] IS NULL -ORDER BY [l12].[Id], [l].[Id], [l0].[Id], [l1].[Id], [l2].[Id], [t].[Id], [t].[Id0], [t].[Id1], [t].[Id2], [t0].[Id], [t0].[Id0], [t0].[Id1], [t0].[Id2], [l11].[Id], [l13].[Id], [l14].[Id], [t1].[Id]"); - } - - public override async Task Take_Select_collection_Take(bool async) - { - await base.Take_Select_collection_Take(async); - - AssertSql( - @"@__p_0='1' - -SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[OneToMany_Optional_Self_Inverse1Id], [t0].[OneToMany_Required_Self_Inverse1Id], [t0].[OneToOne_Optional_Self1Id] -FROM ( - SELECT TOP(@__p_0) [l].[Id], [l].[Name] - FROM [LevelOne] AS [l] - ORDER BY [l].[Id] -) AS [t] -OUTER APPLY ( - SELECT [t1].[Id], [t1].[Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l0].[Id] AS [Id0], [l0].[Date], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] - FROM ( - SELECT TOP(3) [l1].[Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Required_Inverse2Id] - FROM [LevelTwo] AS [l1] - WHERE [t].[Id] = [l1].[OneToMany_Required_Inverse2Id] - ORDER BY [l1].[Id] - ) AS [t1] - INNER JOIN [LevelOne] AS [l0] ON [t1].[Level1_Required_Id] = [l0].[Id] -) AS [t0] -ORDER BY [t].[Id], [t0].[Id], [t0].[Id0]"); - } - - public override async Task Skip_Take_Select_collection_Skip_Take(bool async) - { - await base.Skip_Take_Select_collection_Skip_Take(async); - - AssertSql( - @"@__p_0='1' - -SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[OneToMany_Optional_Self_Inverse1Id], [t0].[OneToMany_Required_Self_Inverse1Id], [t0].[OneToOne_Optional_Self1Id] -FROM ( - SELECT [l].[Id], [l].[Name] - FROM [LevelOne] AS [l] - ORDER BY [l].[Id] - OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY -) AS [t] -OUTER APPLY ( - SELECT [t1].[Id], [t1].[Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l0].[Id] AS [Id0], [l0].[Date], [l0].[Name] AS [Name0], [l0].[OneToMany_Optional_Self_Inverse1Id], [l0].[OneToMany_Required_Self_Inverse1Id], [l0].[OneToOne_Optional_Self1Id] - FROM ( - SELECT [l1].[Id], [l1].[Level1_Required_Id], [l1].[Name], [l1].[OneToMany_Required_Inverse2Id] - FROM [LevelTwo] AS [l1] - WHERE [t].[Id] = [l1].[OneToMany_Required_Inverse2Id] - ORDER BY [l1].[Id] - OFFSET 1 ROWS FETCH NEXT 3 ROWS ONLY - ) AS [t1] - INNER JOIN [LevelOne] AS [l0] ON [t1].[Level1_Required_Id] = [l0].[Id] -) AS [t0] -ORDER BY [t].[Id], [t0].[Id], [t0].[Id0]"); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs index 1c2e2c19774..9bff7783b90 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqlServerTest.cs @@ -1,10 +1,7 @@ // Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using System; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics; -using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query @@ -252,134 +249,6 @@ FROM [Level1] AS [l1] ) AS [t0] ON [l].[Id] = [t0].[Level1_Optional_Id]"); } - public override async Task SelectMany_with_Include1(bool async) - { - await base.SelectMany_with_Include1(async); - - AssertSql( - @"SELECT [t].[Id], [t].[OneToOne_Required_PK_Date], [t].[Level1_Optional_Id], [t].[Level1_Required_Id], [t].[Level2_Name], [t].[OneToMany_Optional_Inverse2Id], [t].[OneToMany_Required_Inverse2Id], [t].[OneToOne_Optional_PK_Inverse2Id], [l].[Id], [t].[Id0], [t0].[Id], [t0].[Level2_Optional_Id], [t0].[Level2_Required_Id], [t0].[Level3_Name], [t0].[OneToMany_Optional_Inverse3Id], [t0].[OneToMany_Required_Inverse3Id], [t0].[OneToOne_Optional_PK_Inverse3Id], [t0].[Id0], [t0].[Id00] -FROM [Level1] AS [l] -INNER JOIN ( - SELECT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id], [l1].[Id] AS [Id0] - FROM [Level1] AS [l0] - INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id] - WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[Level2_Optional_Id], [l2].[Level2_Required_Id], [l2].[Level3_Name], [l2].[OneToMany_Optional_Inverse3Id], [l2].[OneToMany_Required_Inverse3Id], [l2].[OneToOne_Optional_PK_Inverse3Id], [t1].[Id] AS [Id0], [t1].[Id0] AS [Id00] - FROM [Level1] AS [l2] - INNER JOIN ( - SELECT [l3].[Id], [l4].[Id] AS [Id0] - FROM [Level1] AS [l3] - INNER JOIN [Level1] AS [l4] ON [l3].[Id] = [l4].[Id] - WHERE ([l3].[OneToOne_Required_PK_Date] IS NOT NULL AND [l3].[Level1_Required_Id] IS NOT NULL) AND [l3].[OneToMany_Required_Inverse2Id] IS NOT NULL - ) AS [t1] ON [l2].[Id] = [t1].[Id] - WHERE [l2].[Level2_Required_Id] IS NOT NULL AND [l2].[OneToMany_Required_Inverse3Id] IS NOT NULL -) AS [t0] ON [t].[Id] = [t0].[OneToMany_Optional_Inverse3Id] -ORDER BY [l].[Id], [t].[Id], [t].[Id0], [t0].[Id], [t0].[Id0], [t0].[Id00]"); - } - - public override async Task SelectMany_with_navigation_and_Distinct(bool async) - { - await base.SelectMany_with_navigation_and_Distinct(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t0].[Id], [t0].[OneToOne_Required_PK_Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Level2_Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[Id0] -FROM [Level1] AS [l] -INNER JOIN ( - SELECT DISTINCT [l0].[Id], [l0].[OneToOne_Required_PK_Date], [l0].[Level1_Optional_Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Optional_Inverse2Id], [l0].[OneToMany_Required_Inverse2Id], [l0].[OneToOne_Optional_PK_Inverse2Id] - FROM [Level1] AS [l0] - INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id] - WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL -) AS [t] ON [l].[Id] = [t].[OneToMany_Optional_Inverse2Id] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l3].[Id] AS [Id0] - FROM [Level1] AS [l2] - INNER JOIN [Level1] AS [l3] ON [l2].[Id] = [l3].[Id] - WHERE ([l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL) AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -WHERE ([t].[OneToOne_Required_PK_Date] IS NOT NULL AND [t].[Level1_Required_Id] IS NOT NULL) AND [t].[OneToMany_Required_Inverse2Id] IS NOT NULL -ORDER BY [l].[Id], [t].[Id], [t0].[Id], [t0].[Id0]"); - } - - public override async Task SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(bool async) - { - await base.SelectMany_with_navigation_and_Distinct_projecting_columns_including_join_key(async); - - AssertSql( - @"SELECT [l].[Id], [l].[Date], [l].[Name], [t].[Id], [t].[Name], [t].[FK], [t0].[Id], [t0].[OneToOne_Required_PK_Date], [t0].[Level1_Optional_Id], [t0].[Level1_Required_Id], [t0].[Level2_Name], [t0].[OneToMany_Optional_Inverse2Id], [t0].[OneToMany_Required_Inverse2Id], [t0].[OneToOne_Optional_PK_Inverse2Id], [t0].[Id0] -FROM [Level1] AS [l] -INNER JOIN ( - SELECT DISTINCT [l0].[Id], [l0].[Level2_Name] AS [Name], [l0].[OneToMany_Optional_Inverse2Id] AS [FK] - FROM [Level1] AS [l0] - INNER JOIN [Level1] AS [l1] ON [l0].[Id] = [l1].[Id] - WHERE ([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL -) AS [t] ON [l].[Id] = [t].[FK] -LEFT JOIN ( - SELECT [l2].[Id], [l2].[OneToOne_Required_PK_Date], [l2].[Level1_Optional_Id], [l2].[Level1_Required_Id], [l2].[Level2_Name], [l2].[OneToMany_Optional_Inverse2Id], [l2].[OneToMany_Required_Inverse2Id], [l2].[OneToOne_Optional_PK_Inverse2Id], [l3].[Id] AS [Id0] - FROM [Level1] AS [l2] - INNER JOIN [Level1] AS [l3] ON [l2].[Id] = [l3].[Id] - WHERE ([l2].[OneToOne_Required_PK_Date] IS NOT NULL AND [l2].[Level1_Required_Id] IS NOT NULL) AND [l2].[OneToMany_Required_Inverse2Id] IS NOT NULL -) AS [t0] ON [l].[Id] = [t0].[OneToMany_Optional_Inverse2Id] -ORDER BY [l].[Id], [t].[Id], [t].[Name], [t].[FK], [t0].[Id], [t0].[Id0]"); - } - - public override async Task Take_Select_collection_Take(bool async) - { - await base.Take_Select_collection_Take(async); - - AssertSql( - @"@__p_0='1' - -SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[Id00] -FROM ( - SELECT TOP(@__p_0) [l].[Id], [l].[Name] - FROM [Level1] AS [l] - ORDER BY [l].[Id] -) AS [t] -OUTER APPLY ( - SELECT [t1].[Id], [t1].[Level2_Name] AS [Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l1].[Id] AS [Id0], [l1].[Date], [l1].[Name] AS [Name0], [t1].[Id0] AS [Id00] - FROM ( - SELECT TOP(3) [l0].[Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Required_Inverse2Id], [l2].[Id] AS [Id0] - FROM [Level1] AS [l0] - INNER JOIN [Level1] AS [l2] ON [l0].[Id] = [l2].[Id] - WHERE (([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL) AND ([t].[Id] = [l0].[OneToMany_Required_Inverse2Id]) - ORDER BY [l0].[Id] - ) AS [t1] - INNER JOIN [Level1] AS [l1] ON [t1].[Level1_Required_Id] = [l1].[Id] -) AS [t0] -ORDER BY [t].[Id], [t0].[Id], [t0].[Id00], [t0].[Id0]"); - } - - public override async Task Skip_Take_Select_collection_Skip_Take(bool async) - { - await base.Skip_Take_Select_collection_Skip_Take(async); - - AssertSql( - @"@__p_0='1' - -SELECT [t].[Id], [t].[Name], [t0].[Id], [t0].[Name], [t0].[Level1Id], [t0].[Level2Id], [t0].[Id0], [t0].[Date], [t0].[Name0], [t0].[Id00] -FROM ( - SELECT [l].[Id], [l].[Name] - FROM [Level1] AS [l] - ORDER BY [l].[Id] - OFFSET @__p_0 ROWS FETCH NEXT @__p_0 ROWS ONLY -) AS [t] -OUTER APPLY ( - SELECT [t1].[Id], [t1].[Level2_Name] AS [Name], [t1].[OneToMany_Required_Inverse2Id] AS [Level1Id], [t1].[Level1_Required_Id] AS [Level2Id], [l1].[Id] AS [Id0], [l1].[Date], [l1].[Name] AS [Name0], [t1].[Id0] AS [Id00] - FROM ( - SELECT [l0].[Id], [l0].[Level1_Required_Id], [l0].[Level2_Name], [l0].[OneToMany_Required_Inverse2Id], [l2].[Id] AS [Id0] - FROM [Level1] AS [l0] - INNER JOIN [Level1] AS [l2] ON [l0].[Id] = [l2].[Id] - WHERE (([l0].[OneToOne_Required_PK_Date] IS NOT NULL AND [l0].[Level1_Required_Id] IS NOT NULL) AND [l0].[OneToMany_Required_Inverse2Id] IS NOT NULL) AND ([t].[Id] = [l0].[OneToMany_Required_Inverse2Id]) - ORDER BY [l0].[Id] - OFFSET 1 ROWS FETCH NEXT 3 ROWS ONLY - ) AS [t1] - INNER JOIN [Level1] AS [l1] ON [t1].[Level1_Required_Id] = [l1].[Id] -) AS [t0] -ORDER BY [t].[Id], [t0].[Id], [t0].[Id00], [t0].[Id0]"); - } - private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqliteTest.cs new file mode 100644 index 00000000000..5ee85cdb63e --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsQuerySqliteTest.cs @@ -0,0 +1,97 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Sqlite.Internal; +using Xunit; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsQuerySqliteTest : ComplexNavigationsCollectionsQueryRelationalTestBase + { + public ComplexNavigationsCollectionsQuerySqliteTest(ComplexNavigationsQuerySqliteFixture fixture) + : base(fixture) + { + } + + [ConditionalTheory(Skip = "Issue #17230")] + public override Task Include_inside_subquery(bool async) + { + return base.Include_inside_subquery(async); + } + + public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_after_different_filtered_include_different_level(async))).Message); + + public override async Task Filtered_include_outer_parameter_used_inside_filter(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_outer_parameter_used_inside_filter(async))).Message); + + public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async))).Message); + + public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( + bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async))).Message); + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async))).Message); + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_complex_three_level_with_middle_having_filter1(async))).Message); + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_complex_three_level_with_middle_having_filter2(async))).Message); + + public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Complex_query_with_let_collection_projection_FirstOrDefault(async))).Message); + + public override async Task Take_Select_collection_Take(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Take_Select_collection_Take(async))).Message); + + public override async Task Skip_Take_Select_collection_Skip_Take(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Skip_Take_Select_collection_Skip_Take(async))).Message); + + public override async Task Select_subquery_single_nested_subquery(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Select_subquery_single_nested_subquery(async))).Message); + + public override async Task Select_subquery_single_nested_subquery2(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Select_subquery_single_nested_subquery2(async))).Message); + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqliteTest.cs new file mode 100644 index 00000000000..9c5c6fb4436 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSharedTypeQuerySqliteTest.cs @@ -0,0 +1,87 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Sqlite.Internal; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsSharedTypeQuerySqliteTest : ComplexNavigationsCollectionsSharedQueryTypeRelationalTestBase< + ComplexNavigationsSharedTypeQuerySqliteFixture> + { + public ComplexNavigationsCollectionsSharedTypeQuerySqliteTest(ComplexNavigationsSharedTypeQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + } + + public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_after_different_filtered_include_different_level(async))).Message); + + public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async))).Message); + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_complex_three_level_with_middle_having_filter1(async))).Message); + + public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( + bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async))).Message); + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async))).Message); + + public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_complex_three_level_with_middle_having_filter2(async))).Message); + + public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Complex_query_with_let_collection_projection_FirstOrDefault(async))).Message); + + public override async Task Take_Select_collection_Take(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Take_Select_collection_Take(async))).Message); + + public override async Task Skip_Take_Select_collection_Skip_Take(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Skip_Take_Select_collection_Skip_Take(async))).Message); + + public override async Task Select_subquery_single_nested_subquery(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Select_subquery_single_nested_subquery(async))).Message); + + public override async Task Select_subquery_single_nested_subquery2(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Select_subquery_single_nested_subquery2(async))).Message); + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqliteTest.cs new file mode 100644 index 00000000000..12788a18c38 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSplitQuerySqliteTest.cs @@ -0,0 +1,36 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Sqlite.Internal; +using Xunit; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsSplitQuerySqliteTest : ComplexNavigationsCollectionsSplitQueryRelationalTestBase + { + public ComplexNavigationsCollectionsSplitQuerySqliteTest(ComplexNavigationsQuerySqliteFixture fixture) + : base(fixture) + { + } + + public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async))).Message); + + public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async))).Message); + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async))).Message); + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQuerySqliteTest.cs new file mode 100644 index 00000000000..590fde73690 --- /dev/null +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsCollectionsSplitSharedTypeQuerySqliteTest.cs @@ -0,0 +1,38 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore.Sqlite.Internal; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.EntityFrameworkCore.Query +{ + public class ComplexNavigationsCollectionsSplitSharedTypeQuerySqliteTest : ComplexNavigationsCollectionsSplitSharedQueryTypeRelationalTestBase< + ComplexNavigationsSharedTypeQuerySqliteFixture> + { + public ComplexNavigationsCollectionsSplitSharedTypeQuerySqliteTest(ComplexNavigationsSharedTypeQuerySqliteFixture fixture, ITestOutputHelper testOutputHelper) + : base(fixture) + { + } + + public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async))).Message); + + public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async))).Message); + + public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) + => Assert.Equal( + SqliteStrings.ApplyNotSupported, + (await Assert.ThrowsAsync( + () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async))).Message); + } +} diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs index 0bc87082329..763b9182c77 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsQuerySqliteTest.cs @@ -15,110 +15,12 @@ public ComplexNavigationsQuerySqliteTest(ComplexNavigationsQuerySqliteFixture fi { } - [ConditionalTheory(Skip = "Issue #17230")] - public override Task Include_inside_subquery(bool async) - { - return base.Include_inside_subquery(async); - } - - public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_after_different_filtered_include_different_level(async))).Message); - - public override async Task Filtered_include_outer_parameter_used_inside_filter(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_outer_parameter_used_inside_filter(async))).Message); - - public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async))).Message); - - public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( - bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async))).Message); - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async))).Message); - - public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_complex_three_level_with_middle_having_filter1(async))).Message); - - public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_complex_three_level_with_middle_having_filter2(async))).Message); - - public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(async))).Message); - - public override async Task - Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(async))).Message); - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(async))).Message); - public override async Task Let_let_contains_from_outer_let(bool async) => Assert.Equal( SqliteStrings.ApplyNotSupported, (await Assert.ThrowsAsync( () => base.Let_let_contains_from_outer_let(async))).Message); - public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Complex_query_with_let_collection_projection_FirstOrDefault(async))).Message); - - public override async Task Take_Select_collection_Take(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Take_Select_collection_Take(async))).Message); - - public override async Task Skip_Take_Select_collection_Skip_Take(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Skip_Take_Select_collection_Skip_Take(async))).Message); - - public override async Task Select_subquery_single_nested_subquery(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Select_subquery_single_nested_subquery(async))).Message); - - public override async Task Select_subquery_single_nested_subquery2(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Select_subquery_single_nested_subquery2(async))).Message); - public override void Member_pushdown_chain_3_levels_deep_entity() => Assert.Equal( SqliteStrings.ApplyNotSupported, diff --git a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteTest.cs b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteTest.cs index 847cdfa4df4..669f32ba073 100644 --- a/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteTest.cs +++ b/test/EFCore.Sqlite.FunctionalTests/Query/ComplexNavigationsSharedTypeQuerySqliteTest.cs @@ -3,7 +3,6 @@ using System; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore.Diagnostics; using Microsoft.EntityFrameworkCore.Sqlite.Internal; using Xunit; using Xunit.Abstractions; @@ -18,95 +17,10 @@ public ComplexNavigationsSharedTypeQuerySqliteTest(ComplexNavigationsSharedTypeQ { } - public override async Task Filtered_include_after_different_filtered_include_different_level(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_after_different_filtered_include_different_level(async))).Message); - - public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation(async))).Message); - - public override async Task Filtered_include_complex_three_level_with_middle_having_filter1(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_complex_three_level_with_middle_having_filter1(async))).Message); - - public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only( - bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only(async))).Message); - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes(async))).Message); - - public override async Task Filtered_include_complex_three_level_with_middle_having_filter2(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_complex_three_level_with_middle_having_filter2(async))).Message); - public override async Task Let_let_contains_from_outer_let(bool async) => Assert.Equal( SqliteStrings.ApplyNotSupported, (await Assert.ThrowsAsync( () => base.Let_let_contains_from_outer_let(async))).Message); - - public override async Task Complex_query_with_let_collection_projection_FirstOrDefault(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Complex_query_with_let_collection_projection_FirstOrDefault(async))).Message); - - public override async Task Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_and_non_filtered_include_followed_by_then_include_on_same_navigation_split(async))).Message); - - public override async Task Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_multiple_multi_level_includes_with_first_level_using_filter_include_on_one_of_the_chains_only_split(async))).Message); - - public override async Task Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Filtered_include_same_filter_set_on_same_navigation_twice_followed_by_ThenIncludes_split(async))).Message); - - public override async Task Take_Select_collection_Take(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Take_Select_collection_Take(async))).Message); - - public override async Task Skip_Take_Select_collection_Skip_Take(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Skip_Take_Select_collection_Skip_Take(async))).Message); - - public override async Task Select_subquery_single_nested_subquery(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Select_subquery_single_nested_subquery(async))).Message); - - public override async Task Select_subquery_single_nested_subquery2(bool async) - => Assert.Equal( - SqliteStrings.ApplyNotSupported, - (await Assert.ThrowsAsync( - () => base.Select_subquery_single_nested_subquery2(async))).Message); } }