// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore.Query;
using Xunit.Abstractions;

namespace EntityFrameworkCore.Jet.FunctionalTests.Query;

public class CompositeKeysQueryJetTest : CompositeKeysQueryRelationalTestBase<CompositeKeysQueryJetFixture>
{
    public CompositeKeysQueryJetTest(
        CompositeKeysQueryJetFixture fixture,
        ITestOutputHelper testOutputHelper)
        : base(fixture)
    {
        Fixture.TestSqlLoggerFactory.Clear();
        //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper);
    }

    protected override bool CanExecuteQueryString
        => false;

    public override async Task Projecting_multiple_collections_same_level_top_level_ordering(bool async)
    {
        await base.Projecting_multiple_collections_same_level_top_level_ordering(async);

        AssertSql(
"""
SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c1`.`Id1`, `c1`.`Id2`, `c1`.`Date`, `c1`.`Level1_Optional_Id1`, `c1`.`Level1_Optional_Id2`, `c1`.`Level1_Required_Id1`, `c1`.`Level1_Required_Id2`, `c1`.`Name`, `c1`.`OneToMany_Optional_Inverse2Id1`, `c1`.`OneToMany_Optional_Inverse2Id2`, `c1`.`OneToMany_Optional_Self_Inverse2Id1`, `c1`.`OneToMany_Optional_Self_Inverse2Id2`, `c1`.`OneToMany_Required_Inverse2Id1`, `c1`.`OneToMany_Required_Inverse2Id2`, `c1`.`OneToMany_Required_Self_Inverse2Id1`, `c1`.`OneToMany_Required_Self_Inverse2Id2`, `c1`.`OneToOne_Optional_PK_Inverse2Id1`, `c1`.`OneToOne_Optional_PK_Inverse2Id2`, `c1`.`OneToOne_Optional_Self2Id1`, `c1`.`OneToOne_Optional_Self2Id2`
FROM (`CompositeOnes` AS `c`
LEFT JOIN `CompositeTwos` AS `c0` ON `c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1` AND `c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`)
LEFT JOIN `CompositeTwos` AS `c1` ON `c`.`Id1` = `c1`.`OneToMany_Required_Inverse2Id1` AND `c`.`Id2` = `c1`.`OneToMany_Required_Inverse2Id2`
ORDER BY `c`.`Id2`, `c`.`Id1`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`
""");
    }

    public override async Task Projecting_multiple_collections_same_level_top_level_ordering_using_entire_composite_key(bool async)
    {
        await base.Projecting_multiple_collections_same_level_top_level_ordering_using_entire_composite_key(async);

        AssertSql(
"""
SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c1`.`Id1`, `c1`.`Id2`, `c1`.`Date`, `c1`.`Level1_Optional_Id1`, `c1`.`Level1_Optional_Id2`, `c1`.`Level1_Required_Id1`, `c1`.`Level1_Required_Id2`, `c1`.`Name`, `c1`.`OneToMany_Optional_Inverse2Id1`, `c1`.`OneToMany_Optional_Inverse2Id2`, `c1`.`OneToMany_Optional_Self_Inverse2Id1`, `c1`.`OneToMany_Optional_Self_Inverse2Id2`, `c1`.`OneToMany_Required_Inverse2Id1`, `c1`.`OneToMany_Required_Inverse2Id2`, `c1`.`OneToMany_Required_Self_Inverse2Id1`, `c1`.`OneToMany_Required_Self_Inverse2Id2`, `c1`.`OneToOne_Optional_PK_Inverse2Id1`, `c1`.`OneToOne_Optional_PK_Inverse2Id2`, `c1`.`OneToOne_Optional_Self2Id1`, `c1`.`OneToOne_Optional_Self2Id2`
FROM (`CompositeOnes` AS `c`
LEFT JOIN `CompositeTwos` AS `c0` ON `c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1` AND `c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`)
LEFT JOIN `CompositeTwos` AS `c1` ON `c`.`Id1` = `c1`.`OneToMany_Required_Inverse2Id1` AND `c`.`Id2` = `c1`.`OneToMany_Required_Inverse2Id2`
ORDER BY `c`.`Id2`, `c`.`Id1` DESC, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1`
""");
    }

    public override async Task Projecting_multiple_collections_with_ordering_same_level(bool async)
    {
        await base.Projecting_multiple_collections_with_ordering_same_level(async);

        AssertSql(
"""
SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c1`.`Id1`, `c1`.`Id2`, `c1`.`Date`, `c1`.`Level1_Optional_Id1`, `c1`.`Level1_Optional_Id2`, `c1`.`Level1_Required_Id1`, `c1`.`Level1_Required_Id2`, `c1`.`Name`, `c1`.`OneToMany_Optional_Inverse2Id1`, `c1`.`OneToMany_Optional_Inverse2Id2`, `c1`.`OneToMany_Optional_Self_Inverse2Id1`, `c1`.`OneToMany_Optional_Self_Inverse2Id2`, `c1`.`OneToMany_Required_Inverse2Id1`, `c1`.`OneToMany_Required_Inverse2Id2`, `c1`.`OneToMany_Required_Self_Inverse2Id1`, `c1`.`OneToMany_Required_Self_Inverse2Id2`, `c1`.`OneToOne_Optional_PK_Inverse2Id1`, `c1`.`OneToOne_Optional_PK_Inverse2Id2`, `c1`.`OneToOne_Optional_Self2Id1`, `c1`.`OneToOne_Optional_Self2Id2`
FROM (`CompositeOnes` AS `c`
LEFT JOIN `CompositeTwos` AS `c0` ON `c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1` AND `c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`)
LEFT JOIN `CompositeTwos` AS `c1` ON `c`.`Id1` = `c1`.`OneToMany_Required_Inverse2Id1` AND `c`.`Id2` = `c1`.`OneToMany_Required_Inverse2Id2`
ORDER BY `c`.`Id1`, `c`.`Id2`, `c0`.`Id2`, `c0`.`Id1`, `c1`.`Name` DESC, `c1`.`Id1`
""");
    }

    public override async Task Projecting_multiple_collections_with_ordering_same_level_top_level_ordering(bool async)
    {
        await base.Projecting_multiple_collections_with_ordering_same_level_top_level_ordering(async);

        AssertSql(
"""
SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `c0`.`Id1`, `c0`.`Id2`, `c0`.`Date`, `c0`.`Level1_Optional_Id1`, `c0`.`Level1_Optional_Id2`, `c0`.`Level1_Required_Id1`, `c0`.`Level1_Required_Id2`, `c0`.`Name`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`, `c0`.`OneToMany_Optional_Self_Inverse2Id1`, `c0`.`OneToMany_Optional_Self_Inverse2Id2`, `c0`.`OneToMany_Required_Inverse2Id1`, `c0`.`OneToMany_Required_Inverse2Id2`, `c0`.`OneToMany_Required_Self_Inverse2Id1`, `c0`.`OneToMany_Required_Self_Inverse2Id2`, `c0`.`OneToOne_Optional_PK_Inverse2Id1`, `c0`.`OneToOne_Optional_PK_Inverse2Id2`, `c0`.`OneToOne_Optional_Self2Id1`, `c0`.`OneToOne_Optional_Self2Id2`, `c1`.`Id1`, `c1`.`Id2`, `c1`.`Date`, `c1`.`Level1_Optional_Id1`, `c1`.`Level1_Optional_Id2`, `c1`.`Level1_Required_Id1`, `c1`.`Level1_Required_Id2`, `c1`.`Name`, `c1`.`OneToMany_Optional_Inverse2Id1`, `c1`.`OneToMany_Optional_Inverse2Id2`, `c1`.`OneToMany_Optional_Self_Inverse2Id1`, `c1`.`OneToMany_Optional_Self_Inverse2Id2`, `c1`.`OneToMany_Required_Inverse2Id1`, `c1`.`OneToMany_Required_Inverse2Id2`, `c1`.`OneToMany_Required_Self_Inverse2Id1`, `c1`.`OneToMany_Required_Self_Inverse2Id2`, `c1`.`OneToOne_Optional_PK_Inverse2Id1`, `c1`.`OneToOne_Optional_PK_Inverse2Id2`, `c1`.`OneToOne_Optional_Self2Id1`, `c1`.`OneToOne_Optional_Self2Id2`
FROM (`CompositeOnes` AS `c`
LEFT JOIN `CompositeTwos` AS `c0` ON `c`.`Id1` = `c0`.`OneToMany_Optional_Inverse2Id1` AND `c`.`Id2` = `c0`.`OneToMany_Optional_Inverse2Id2`)
LEFT JOIN `CompositeTwos` AS `c1` ON `c`.`Id1` = `c1`.`OneToMany_Required_Inverse2Id1` AND `c`.`Id2` = `c1`.`OneToMany_Required_Inverse2Id2`
ORDER BY `c`.`Id2`, `c`.`Id1`, `c0`.`Id2`, `c0`.`Id1`, `c1`.`Name` DESC, `c1`.`Id1`
""");
    }

    public override async Task Projecting_collections_multi_level(bool async)
    {
        await base.Projecting_collections_multi_level(async);

        AssertSql(
"""
SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `t`.`Name`, `t`.`Id1`, `t`.`Id2`, `t`.`Id10`, `t`.`Id20`, `t`.`Level2_Optional_Id1`, `t`.`Level2_Optional_Id2`, `t`.`Level2_Required_Id1`, `t`.`Level2_Required_Id2`, `t`.`Name0`, `t`.`OneToMany_Optional_Inverse3Id1`, `t`.`OneToMany_Optional_Inverse3Id2`, `t`.`OneToMany_Optional_Self_Inverse3Id1`, `t`.`OneToMany_Optional_Self_Inverse3Id2`, `t`.`OneToMany_Required_Inverse3Id1`, `t`.`OneToMany_Required_Inverse3Id2`, `t`.`OneToMany_Required_Self_Inverse3Id1`, `t`.`OneToMany_Required_Self_Inverse3Id2`, `t`.`OneToOne_Optional_PK_Inverse3Id1`, `t`.`OneToOne_Optional_PK_Inverse3Id2`, `t`.`OneToOne_Optional_Self3Id1`, `t`.`OneToOne_Optional_Self3Id2`
FROM `CompositeOnes` AS `c`
LEFT JOIN (
    SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `c1`.`Id1` AS `Id10`, `c1`.`Id2` AS `Id20`, `c1`.`Level2_Optional_Id1`, `c1`.`Level2_Optional_Id2`, `c1`.`Level2_Required_Id1`, `c1`.`Level2_Required_Id2`, `c1`.`Name` AS `Name0`, `c1`.`OneToMany_Optional_Inverse3Id1`, `c1`.`OneToMany_Optional_Inverse3Id2`, `c1`.`OneToMany_Optional_Self_Inverse3Id1`, `c1`.`OneToMany_Optional_Self_Inverse3Id2`, `c1`.`OneToMany_Required_Inverse3Id1`, `c1`.`OneToMany_Required_Inverse3Id2`, `c1`.`OneToMany_Required_Self_Inverse3Id1`, `c1`.`OneToMany_Required_Self_Inverse3Id2`, `c1`.`OneToOne_Optional_PK_Inverse3Id1`, `c1`.`OneToOne_Optional_PK_Inverse3Id2`, `c1`.`OneToOne_Optional_Self3Id1`, `c1`.`OneToOne_Optional_Self3Id2`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`
    FROM `CompositeTwos` AS `c0`
    LEFT JOIN `CompositeThrees` AS `c1` ON `c0`.`Id1` = `c1`.`OneToMany_Required_Inverse3Id1` AND `c0`.`Id2` = `c1`.`OneToMany_Required_Inverse3Id2`
) AS `t` ON `c`.`Id1` = `t`.`OneToMany_Optional_Inverse2Id1` AND `c`.`Id2` = `t`.`OneToMany_Optional_Inverse2Id2`
ORDER BY `c`.`Id2`, `c`.`Id1`, `t`.`Id2`, `t`.`Id1`, `t`.`Id20` DESC
""");
    }

    public override async Task Projecting_multiple_collections_on_multiple_levels_no_explicit_ordering(bool async)
    {
        await base.Projecting_multiple_collections_on_multiple_levels_no_explicit_ordering(async);

        AssertSql(
"""
SELECT `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `t1`.`Name`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Name0`, `t1`.`Id10`, `t1`.`Id20`, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Level3_Optional_Id1`, `t1`.`Level3_Optional_Id2`, `t1`.`Level3_Required_Id1`, `t1`.`Level3_Required_Id2`, `t1`.`Name00`, `t1`.`OneToMany_Optional_Inverse4Id1`, `t1`.`OneToMany_Optional_Inverse4Id2`, `t1`.`OneToMany_Optional_Self_Inverse4Id1`, `t1`.`OneToMany_Optional_Self_Inverse4Id2`, `t1`.`OneToMany_Required_Inverse4Id1`, `t1`.`OneToMany_Required_Inverse4Id2`, `t1`.`OneToMany_Required_Self_Inverse4Id1`, `t1`.`OneToMany_Required_Self_Inverse4Id2`, `t1`.`OneToOne_Optional_PK_Inverse4Id1`, `t1`.`OneToOne_Optional_PK_Inverse4Id2`, `t1`.`OneToOne_Optional_Self4Id1`, `t1`.`OneToOne_Optional_Self4Id2`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Level3_Optional_Id10`, `t1`.`Level3_Optional_Id20`, `t1`.`Level3_Required_Id10`, `t1`.`Level3_Required_Id20`, `t1`.`Name1`, `t1`.`OneToMany_Optional_Inverse4Id10`, `t1`.`OneToMany_Optional_Inverse4Id20`, `t1`.`OneToMany_Optional_Self_Inverse4Id10`, `t1`.`OneToMany_Optional_Self_Inverse4Id20`, `t1`.`OneToMany_Required_Inverse4Id10`, `t1`.`OneToMany_Required_Inverse4Id20`, `t1`.`OneToMany_Required_Self_Inverse4Id10`, `t1`.`OneToMany_Required_Self_Inverse4Id20`, `t1`.`OneToOne_Optional_PK_Inverse4Id10`, `t1`.`OneToOne_Optional_PK_Inverse4Id20`, `t1`.`OneToOne_Optional_Self4Id10`, `t1`.`OneToOne_Optional_Self4Id20`, `t1`.`Name2`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Level3_Optional_Id11`, `t1`.`Level3_Optional_Id21`, `t1`.`Level3_Required_Id11`, `t1`.`Level3_Required_Id21`, `t1`.`Name01`, `t1`.`OneToMany_Optional_Inverse4Id11`, `t1`.`OneToMany_Optional_Inverse4Id21`, `t1`.`OneToMany_Optional_Self_Inverse4Id11`, `t1`.`OneToMany_Optional_Self_Inverse4Id21`, `t1`.`OneToMany_Required_Inverse4Id11`, `t1`.`OneToMany_Required_Inverse4Id21`, `t1`.`OneToMany_Required_Self_Inverse4Id11`, `t1`.`OneToMany_Required_Self_Inverse4Id21`, `t1`.`OneToOne_Optional_PK_Inverse4Id11`, `t1`.`OneToOne_Optional_PK_Inverse4Id21`, `t1`.`OneToOne_Optional_Self4Id11`, `t1`.`OneToOne_Optional_Self4Id21`, `t1`.`Id110`, `t1`.`Id210`, `t1`.`Level3_Optional_Id100`, `t1`.`Level3_Optional_Id200`, `t1`.`Level3_Required_Id100`, `t1`.`Level3_Required_Id200`, `t1`.`Name10`, `t1`.`OneToMany_Optional_Inverse4Id100`, `t1`.`OneToMany_Optional_Inverse4Id200`, `t1`.`OneToMany_Optional_Self_Inverse4Id100`, `t1`.`OneToMany_Optional_Self_Inverse4Id200`, `t1`.`OneToMany_Required_Inverse4Id100`, `t1`.`OneToMany_Required_Inverse4Id200`, `t1`.`OneToMany_Required_Self_Inverse4Id100`, `t1`.`OneToMany_Required_Self_Inverse4Id200`, `t1`.`OneToOne_Optional_PK_Inverse4Id100`, `t1`.`OneToOne_Optional_PK_Inverse4Id200`, `t1`.`OneToOne_Optional_Self4Id100`, `t1`.`OneToOne_Optional_Self4Id200`, `t2`.`Name`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Name0`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Level3_Optional_Id1`, `t2`.`Level3_Optional_Id2`, `t2`.`Level3_Required_Id1`, `t2`.`Level3_Required_Id2`, `t2`.`Name00`, `t2`.`OneToMany_Optional_Inverse4Id1`, `t2`.`OneToMany_Optional_Inverse4Id2`, `t2`.`OneToMany_Optional_Self_Inverse4Id1`, `t2`.`OneToMany_Optional_Self_Inverse4Id2`, `t2`.`OneToMany_Required_Inverse4Id1`, `t2`.`OneToMany_Required_Inverse4Id2`, `t2`.`OneToMany_Required_Self_Inverse4Id1`, `t2`.`OneToMany_Required_Self_Inverse4Id2`, `t2`.`OneToOne_Optional_PK_Inverse4Id1`, `t2`.`OneToOne_Optional_PK_Inverse4Id2`, `t2`.`OneToOne_Optional_Self4Id1`, `t2`.`OneToOne_Optional_Self4Id2`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Level3_Optional_Id10`, `t2`.`Level3_Optional_Id20`, `t2`.`Level3_Required_Id10`, `t2`.`Level3_Required_Id20`, `t2`.`Name1`, `t2`.`OneToMany_Optional_Inverse4Id10`, `t2`.`OneToMany_Optional_Inverse4Id20`, `t2`.`OneToMany_Optional_Self_Inverse4Id10`, `t2`.`OneToMany_Optional_Self_Inverse4Id20`, `t2`.`OneToMany_Required_Inverse4Id10`, `t2`.`OneToMany_Required_Inverse4Id20`, `t2`.`OneToMany_Required_Self_Inverse4Id10`, `t2`.`OneToMany_Required_Self_Inverse4Id20`, `t2`.`OneToOne_Optional_PK_Inverse4Id10`, `t2`.`OneToOne_Optional_PK_Inverse4Id20`, `t2`.`OneToOne_Optional_Self4Id10`, `t2`.`OneToOne_Optional_Self4Id20`, `t2`.`Name2`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`Level3_Optional_Id11`, `t2`.`Level3_Optional_Id21`, `t2`.`Level3_Required_Id11`, `t2`.`Level3_Required_Id21`, `t2`.`Name01`, `t2`.`OneToMany_Optional_Inverse4Id11`, `t2`.`OneToMany_Optional_Inverse4Id21`, `t2`.`OneToMany_Optional_Self_Inverse4Id11`, `t2`.`OneToMany_Optional_Self_Inverse4Id21`, `t2`.`OneToMany_Required_Inverse4Id11`, `t2`.`OneToMany_Required_Inverse4Id21`, `t2`.`OneToMany_Required_Self_Inverse4Id11`, `t2`.`OneToMany_Required_Self_Inverse4Id21`, `t2`.`OneToOne_Optional_PK_Inverse4Id11`, `t2`.`OneToOne_Optional_PK_Inverse4Id21`, `t2`.`OneToOne_Optional_Self4Id11`, `t2`.`OneToOne_Optional_Self4Id21`, `t2`.`Id110`, `t2`.`Id210`, `t2`.`Level3_Optional_Id100`, `t2`.`Level3_Optional_Id200`, `t2`.`Level3_Required_Id100`, `t2`.`Level3_Required_Id200`, `t2`.`Name10`, `t2`.`OneToMany_Optional_Inverse4Id100`, `t2`.`OneToMany_Optional_Inverse4Id200`, `t2`.`OneToMany_Optional_Self_Inverse4Id100`, `t2`.`OneToMany_Optional_Self_Inverse4Id200`, `t2`.`OneToMany_Required_Inverse4Id100`, `t2`.`OneToMany_Required_Inverse4Id200`, `t2`.`OneToMany_Required_Self_Inverse4Id100`, `t2`.`OneToMany_Required_Self_Inverse4Id200`, `t2`.`OneToOne_Optional_PK_Inverse4Id100`, `t2`.`OneToOne_Optional_PK_Inverse4Id200`, `t2`.`OneToOne_Optional_Self4Id100`, `t2`.`OneToOne_Optional_Self4Id200`
FROM (`CompositeOnes` AS `c`
LEFT JOIN (
    SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `t`.`Name` AS `Name0`, `t`.`Id1` AS `Id10`, `t`.`Id2` AS `Id20`, `t`.`Id10` AS `Id100`, `t`.`Id20` AS `Id200`, `t`.`Level3_Optional_Id1`, `t`.`Level3_Optional_Id2`, `t`.`Level3_Required_Id1`, `t`.`Level3_Required_Id2`, `t`.`Name0` AS `Name00`, `t`.`OneToMany_Optional_Inverse4Id1`, `t`.`OneToMany_Optional_Inverse4Id2`, `t`.`OneToMany_Optional_Self_Inverse4Id1`, `t`.`OneToMany_Optional_Self_Inverse4Id2`, `t`.`OneToMany_Required_Inverse4Id1`, `t`.`OneToMany_Required_Inverse4Id2`, `t`.`OneToMany_Required_Self_Inverse4Id1`, `t`.`OneToMany_Required_Self_Inverse4Id2`, `t`.`OneToOne_Optional_PK_Inverse4Id1`, `t`.`OneToOne_Optional_PK_Inverse4Id2`, `t`.`OneToOne_Optional_Self4Id1`, `t`.`OneToOne_Optional_Self4Id2`, `t`.`Id11`, `t`.`Id21`, `t`.`Level3_Optional_Id10`, `t`.`Level3_Optional_Id20`, `t`.`Level3_Required_Id10`, `t`.`Level3_Required_Id20`, `t`.`Name1`, `t`.`OneToMany_Optional_Inverse4Id10`, `t`.`OneToMany_Optional_Inverse4Id20`, `t`.`OneToMany_Optional_Self_Inverse4Id10`, `t`.`OneToMany_Optional_Self_Inverse4Id20`, `t`.`OneToMany_Required_Inverse4Id10`, `t`.`OneToMany_Required_Inverse4Id20`, `t`.`OneToMany_Required_Self_Inverse4Id10`, `t`.`OneToMany_Required_Self_Inverse4Id20`, `t`.`OneToOne_Optional_PK_Inverse4Id10`, `t`.`OneToOne_Optional_PK_Inverse4Id20`, `t`.`OneToOne_Optional_Self4Id10`, `t`.`OneToOne_Optional_Self4Id20`, `t0`.`Name` AS `Name2`, `t0`.`Id1` AS `Id12`, `t0`.`Id2` AS `Id22`, `t0`.`Id10` AS `Id101`, `t0`.`Id20` AS `Id201`, `t0`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t0`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t0`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t0`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t0`.`Name0` AS `Name01`, `t0`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t0`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t0`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t0`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t0`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t0`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t0`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t0`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t0`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t0`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t0`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t0`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t0`.`Id11` AS `Id110`, `t0`.`Id21` AS `Id210`, `t0`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t0`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t0`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t0`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t0`.`Name1` AS `Name10`, `t0`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t0`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t0`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t0`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t0`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t0`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t0`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t0`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t0`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t0`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t0`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t0`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`
    FROM (`CompositeTwos` AS `c0`
    LEFT JOIN (
        SELECT `c1`.`Name`, `c1`.`Id1`, `c1`.`Id2`, `c2`.`Id1` AS `Id10`, `c2`.`Id2` AS `Id20`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name` AS `Name0`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c3`.`Id1` AS `Id11`, `c3`.`Id2` AS `Id21`, `c3`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c3`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c3`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c3`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c3`.`Name` AS `Name1`, `c3`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c3`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c3`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c3`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c3`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c3`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c3`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c3`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c3`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c3`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c3`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c3`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c1`.`OneToMany_Required_Inverse3Id1`, `c1`.`OneToMany_Required_Inverse3Id2`
        FROM (`CompositeThrees` AS `c1`
        LEFT JOIN `CompositeFours` AS `c2` ON `c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1` AND `c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c3` ON `c1`.`Id1` = `c3`.`OneToMany_Required_Inverse4Id1` AND `c1`.`Id2` = `c3`.`OneToMany_Required_Inverse4Id2`
    ) AS `t` ON `c0`.`Id1` = `t`.`OneToMany_Required_Inverse3Id1` AND `c0`.`Id2` = `t`.`OneToMany_Required_Inverse3Id2`)
    LEFT JOIN (
        SELECT `c4`.`Name`, `c4`.`Id1`, `c4`.`Id2`, `c5`.`Id1` AS `Id10`, `c5`.`Id2` AS `Id20`, `c5`.`Level3_Optional_Id1`, `c5`.`Level3_Optional_Id2`, `c5`.`Level3_Required_Id1`, `c5`.`Level3_Required_Id2`, `c5`.`Name` AS `Name0`, `c5`.`OneToMany_Optional_Inverse4Id1`, `c5`.`OneToMany_Optional_Inverse4Id2`, `c5`.`OneToMany_Optional_Self_Inverse4Id1`, `c5`.`OneToMany_Optional_Self_Inverse4Id2`, `c5`.`OneToMany_Required_Inverse4Id1`, `c5`.`OneToMany_Required_Inverse4Id2`, `c5`.`OneToMany_Required_Self_Inverse4Id1`, `c5`.`OneToMany_Required_Self_Inverse4Id2`, `c5`.`OneToOne_Optional_PK_Inverse4Id1`, `c5`.`OneToOne_Optional_PK_Inverse4Id2`, `c5`.`OneToOne_Optional_Self4Id1`, `c5`.`OneToOne_Optional_Self4Id2`, `c6`.`Id1` AS `Id11`, `c6`.`Id2` AS `Id21`, `c6`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c6`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c6`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c6`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c6`.`Name` AS `Name1`, `c6`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c6`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c6`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c6`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c6`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c6`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c6`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c6`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c6`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c6`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c6`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c6`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c4`.`OneToMany_Optional_Inverse3Id1`, `c4`.`OneToMany_Optional_Inverse3Id2`
        FROM (`CompositeThrees` AS `c4`
        LEFT JOIN `CompositeFours` AS `c5` ON `c4`.`Id1` = `c5`.`OneToMany_Required_Inverse4Id1` AND `c4`.`Id2` = `c5`.`OneToMany_Required_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c6` ON `c4`.`Id1` = `c6`.`OneToMany_Optional_Inverse4Id1` AND `c4`.`Id2` = `c6`.`OneToMany_Optional_Inverse4Id2`
    ) AS `t0` ON `c0`.`Id1` = `t0`.`OneToMany_Optional_Inverse3Id1` AND `c0`.`Id2` = `t0`.`OneToMany_Optional_Inverse3Id2`
) AS `t1` ON `c`.`Id1` = `t1`.`OneToMany_Optional_Inverse2Id1` AND `c`.`Id2` = `t1`.`OneToMany_Optional_Inverse2Id2`)
LEFT JOIN (
    SELECT `c7`.`Name`, `c7`.`Id1`, `c7`.`Id2`, `t3`.`Name` AS `Name0`, `t3`.`Id1` AS `Id10`, `t3`.`Id2` AS `Id20`, `t3`.`Id10` AS `Id100`, `t3`.`Id20` AS `Id200`, `t3`.`Level3_Optional_Id1`, `t3`.`Level3_Optional_Id2`, `t3`.`Level3_Required_Id1`, `t3`.`Level3_Required_Id2`, `t3`.`Name0` AS `Name00`, `t3`.`OneToMany_Optional_Inverse4Id1`, `t3`.`OneToMany_Optional_Inverse4Id2`, `t3`.`OneToMany_Optional_Self_Inverse4Id1`, `t3`.`OneToMany_Optional_Self_Inverse4Id2`, `t3`.`OneToMany_Required_Inverse4Id1`, `t3`.`OneToMany_Required_Inverse4Id2`, `t3`.`OneToMany_Required_Self_Inverse4Id1`, `t3`.`OneToMany_Required_Self_Inverse4Id2`, `t3`.`OneToOne_Optional_PK_Inverse4Id1`, `t3`.`OneToOne_Optional_PK_Inverse4Id2`, `t3`.`OneToOne_Optional_Self4Id1`, `t3`.`OneToOne_Optional_Self4Id2`, `t3`.`Id11`, `t3`.`Id21`, `t3`.`Level3_Optional_Id10`, `t3`.`Level3_Optional_Id20`, `t3`.`Level3_Required_Id10`, `t3`.`Level3_Required_Id20`, `t3`.`Name1`, `t3`.`OneToMany_Optional_Inverse4Id10`, `t3`.`OneToMany_Optional_Inverse4Id20`, `t3`.`OneToMany_Optional_Self_Inverse4Id10`, `t3`.`OneToMany_Optional_Self_Inverse4Id20`, `t3`.`OneToMany_Required_Inverse4Id10`, `t3`.`OneToMany_Required_Inverse4Id20`, `t3`.`OneToMany_Required_Self_Inverse4Id10`, `t3`.`OneToMany_Required_Self_Inverse4Id20`, `t3`.`OneToOne_Optional_PK_Inverse4Id10`, `t3`.`OneToOne_Optional_PK_Inverse4Id20`, `t3`.`OneToOne_Optional_Self4Id10`, `t3`.`OneToOne_Optional_Self4Id20`, `t4`.`Name` AS `Name2`, `t4`.`Id1` AS `Id12`, `t4`.`Id2` AS `Id22`, `t4`.`Id10` AS `Id101`, `t4`.`Id20` AS `Id201`, `t4`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t4`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t4`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t4`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t4`.`Name0` AS `Name01`, `t4`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t4`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t4`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t4`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t4`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t4`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t4`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t4`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t4`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t4`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t4`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t4`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t4`.`Id11` AS `Id110`, `t4`.`Id21` AS `Id210`, `t4`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t4`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t4`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t4`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t4`.`Name1` AS `Name10`, `t4`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t4`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t4`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t4`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t4`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t4`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t4`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t4`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t4`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t4`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t4`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t4`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c7`.`OneToMany_Required_Inverse2Id1`, `c7`.`OneToMany_Required_Inverse2Id2`
    FROM (`CompositeTwos` AS `c7`
    LEFT JOIN (
        SELECT `c8`.`Name`, `c8`.`Id1`, `c8`.`Id2`, `c9`.`Id1` AS `Id10`, `c9`.`Id2` AS `Id20`, `c9`.`Level3_Optional_Id1`, `c9`.`Level3_Optional_Id2`, `c9`.`Level3_Required_Id1`, `c9`.`Level3_Required_Id2`, `c9`.`Name` AS `Name0`, `c9`.`OneToMany_Optional_Inverse4Id1`, `c9`.`OneToMany_Optional_Inverse4Id2`, `c9`.`OneToMany_Optional_Self_Inverse4Id1`, `c9`.`OneToMany_Optional_Self_Inverse4Id2`, `c9`.`OneToMany_Required_Inverse4Id1`, `c9`.`OneToMany_Required_Inverse4Id2`, `c9`.`OneToMany_Required_Self_Inverse4Id1`, `c9`.`OneToMany_Required_Self_Inverse4Id2`, `c9`.`OneToOne_Optional_PK_Inverse4Id1`, `c9`.`OneToOne_Optional_PK_Inverse4Id2`, `c9`.`OneToOne_Optional_Self4Id1`, `c9`.`OneToOne_Optional_Self4Id2`, `c10`.`Id1` AS `Id11`, `c10`.`Id2` AS `Id21`, `c10`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c10`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c10`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c10`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c10`.`Name` AS `Name1`, `c10`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c10`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c10`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c10`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c10`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c10`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c10`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c10`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c10`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c10`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c10`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c10`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c8`.`OneToMany_Optional_Inverse3Id1`, `c8`.`OneToMany_Optional_Inverse3Id2`
        FROM (`CompositeThrees` AS `c8`
        LEFT JOIN `CompositeFours` AS `c9` ON `c8`.`Id1` = `c9`.`OneToMany_Required_Inverse4Id1` AND `c8`.`Id2` = `c9`.`OneToMany_Required_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c10` ON `c8`.`Id1` = `c10`.`OneToMany_Optional_Inverse4Id1` AND `c8`.`Id2` = `c10`.`OneToMany_Optional_Inverse4Id2`
    ) AS `t3` ON `c7`.`Id1` = `t3`.`OneToMany_Optional_Inverse3Id1` AND `c7`.`Id2` = `t3`.`OneToMany_Optional_Inverse3Id2`)
    LEFT JOIN (
        SELECT `c11`.`Name`, `c11`.`Id1`, `c11`.`Id2`, `c12`.`Id1` AS `Id10`, `c12`.`Id2` AS `Id20`, `c12`.`Level3_Optional_Id1`, `c12`.`Level3_Optional_Id2`, `c12`.`Level3_Required_Id1`, `c12`.`Level3_Required_Id2`, `c12`.`Name` AS `Name0`, `c12`.`OneToMany_Optional_Inverse4Id1`, `c12`.`OneToMany_Optional_Inverse4Id2`, `c12`.`OneToMany_Optional_Self_Inverse4Id1`, `c12`.`OneToMany_Optional_Self_Inverse4Id2`, `c12`.`OneToMany_Required_Inverse4Id1`, `c12`.`OneToMany_Required_Inverse4Id2`, `c12`.`OneToMany_Required_Self_Inverse4Id1`, `c12`.`OneToMany_Required_Self_Inverse4Id2`, `c12`.`OneToOne_Optional_PK_Inverse4Id1`, `c12`.`OneToOne_Optional_PK_Inverse4Id2`, `c12`.`OneToOne_Optional_Self4Id1`, `c12`.`OneToOne_Optional_Self4Id2`, `c13`.`Id1` AS `Id11`, `c13`.`Id2` AS `Id21`, `c13`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c13`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c13`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c13`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c13`.`Name` AS `Name1`, `c13`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c13`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c13`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c13`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c13`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c13`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c13`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c13`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c13`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c13`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c13`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c13`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c11`.`OneToMany_Optional_Inverse3Id1`, `c11`.`OneToMany_Optional_Inverse3Id2`
        FROM (`CompositeThrees` AS `c11`
        LEFT JOIN `CompositeFours` AS `c12` ON `c11`.`Id1` = `c12`.`OneToMany_Optional_Inverse4Id1` AND `c11`.`Id2` = `c12`.`OneToMany_Optional_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c13` ON `c11`.`Id1` = `c13`.`OneToMany_Required_Inverse4Id1` AND `c11`.`Id2` = `c13`.`OneToMany_Required_Inverse4Id2`
    ) AS `t4` ON `c7`.`Id1` = `t4`.`OneToMany_Optional_Inverse3Id1` AND `c7`.`Id2` = `t4`.`OneToMany_Optional_Inverse3Id2`
) AS `t2` ON `c`.`Id1` = `t2`.`OneToMany_Required_Inverse2Id1` AND `c`.`Id2` = `t2`.`OneToMany_Required_Inverse2Id2`
ORDER BY `c`.`Id1`, `c`.`Id2`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Id10`, `t1`.`Id20`, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Id110`, `t1`.`Id210`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`Id110`
""");
    }

    public override async Task Projecting_multiple_collections_on_multiple_levels_some_explicit_ordering(bool async)
    {
        await base.Projecting_multiple_collections_on_multiple_levels_some_explicit_ordering(async);

        AssertSql(
"""
SELECT `c`.`Id1`, `c`.`Id2`, `t1`.`Name`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Id10`, `t1`.`Id20`, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Level3_Optional_Id1`, `t1`.`Level3_Optional_Id2`, `t1`.`Level3_Required_Id1`, `t1`.`Level3_Required_Id2`, `t1`.`Name0`, `t1`.`OneToMany_Optional_Inverse4Id1`, `t1`.`OneToMany_Optional_Inverse4Id2`, `t1`.`OneToMany_Optional_Self_Inverse4Id1`, `t1`.`OneToMany_Optional_Self_Inverse4Id2`, `t1`.`OneToMany_Required_Inverse4Id1`, `t1`.`OneToMany_Required_Inverse4Id2`, `t1`.`OneToMany_Required_Self_Inverse4Id1`, `t1`.`OneToMany_Required_Self_Inverse4Id2`, `t1`.`OneToOne_Optional_PK_Inverse4Id1`, `t1`.`OneToOne_Optional_PK_Inverse4Id2`, `t1`.`OneToOne_Optional_Self4Id1`, `t1`.`OneToOne_Optional_Self4Id2`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Level3_Optional_Id10`, `t1`.`Level3_Optional_Id20`, `t1`.`Level3_Required_Id10`, `t1`.`Level3_Required_Id20`, `t1`.`Name00`, `t1`.`OneToMany_Optional_Inverse4Id10`, `t1`.`OneToMany_Optional_Inverse4Id20`, `t1`.`OneToMany_Optional_Self_Inverse4Id10`, `t1`.`OneToMany_Optional_Self_Inverse4Id20`, `t1`.`OneToMany_Required_Inverse4Id10`, `t1`.`OneToMany_Required_Inverse4Id20`, `t1`.`OneToMany_Required_Self_Inverse4Id10`, `t1`.`OneToMany_Required_Self_Inverse4Id20`, `t1`.`OneToOne_Optional_PK_Inverse4Id10`, `t1`.`OneToOne_Optional_PK_Inverse4Id20`, `t1`.`OneToOne_Optional_Self4Id10`, `t1`.`OneToOne_Optional_Self4Id20`, `t1`.`Name1`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Level3_Optional_Id11`, `t1`.`Level3_Optional_Id21`, `t1`.`Level3_Required_Id11`, `t1`.`Level3_Required_Id21`, `t1`.`Name01`, `t1`.`OneToMany_Optional_Inverse4Id11`, `t1`.`OneToMany_Optional_Inverse4Id21`, `t1`.`OneToMany_Optional_Self_Inverse4Id11`, `t1`.`OneToMany_Optional_Self_Inverse4Id21`, `t1`.`OneToMany_Required_Inverse4Id11`, `t1`.`OneToMany_Required_Inverse4Id21`, `t1`.`OneToMany_Required_Self_Inverse4Id11`, `t1`.`OneToMany_Required_Self_Inverse4Id21`, `t1`.`OneToOne_Optional_PK_Inverse4Id11`, `t1`.`OneToOne_Optional_PK_Inverse4Id21`, `t1`.`OneToOne_Optional_Self4Id11`, `t1`.`OneToOne_Optional_Self4Id21`, `t1`.`Id110`, `t1`.`Id210`, `t1`.`Level3_Optional_Id100`, `t1`.`Level3_Optional_Id200`, `t1`.`Level3_Required_Id100`, `t1`.`Level3_Required_Id200`, `t1`.`Name10`, `t1`.`OneToMany_Optional_Inverse4Id100`, `t1`.`OneToMany_Optional_Inverse4Id200`, `t1`.`OneToMany_Optional_Self_Inverse4Id100`, `t1`.`OneToMany_Optional_Self_Inverse4Id200`, `t1`.`OneToMany_Required_Inverse4Id100`, `t1`.`OneToMany_Required_Inverse4Id200`, `t1`.`OneToMany_Required_Self_Inverse4Id100`, `t1`.`OneToMany_Required_Self_Inverse4Id200`, `t1`.`OneToOne_Optional_PK_Inverse4Id100`, `t1`.`OneToOne_Optional_PK_Inverse4Id200`, `t1`.`OneToOne_Optional_Self4Id100`, `t1`.`OneToOne_Optional_Self4Id200`, `t2`.`Name`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Name0`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Level3_Optional_Id1`, `t2`.`Level3_Optional_Id2`, `t2`.`Level3_Required_Id1`, `t2`.`Level3_Required_Id2`, `t2`.`Name00`, `t2`.`OneToMany_Optional_Inverse4Id1`, `t2`.`OneToMany_Optional_Inverse4Id2`, `t2`.`OneToMany_Optional_Self_Inverse4Id1`, `t2`.`OneToMany_Optional_Self_Inverse4Id2`, `t2`.`OneToMany_Required_Inverse4Id1`, `t2`.`OneToMany_Required_Inverse4Id2`, `t2`.`OneToMany_Required_Self_Inverse4Id1`, `t2`.`OneToMany_Required_Self_Inverse4Id2`, `t2`.`OneToOne_Optional_PK_Inverse4Id1`, `t2`.`OneToOne_Optional_PK_Inverse4Id2`, `t2`.`OneToOne_Optional_Self4Id1`, `t2`.`OneToOne_Optional_Self4Id2`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Level3_Optional_Id10`, `t2`.`Level3_Optional_Id20`, `t2`.`Level3_Required_Id10`, `t2`.`Level3_Required_Id20`, `t2`.`Name1`, `t2`.`OneToMany_Optional_Inverse4Id10`, `t2`.`OneToMany_Optional_Inverse4Id20`, `t2`.`OneToMany_Optional_Self_Inverse4Id10`, `t2`.`OneToMany_Optional_Self_Inverse4Id20`, `t2`.`OneToMany_Required_Inverse4Id10`, `t2`.`OneToMany_Required_Inverse4Id20`, `t2`.`OneToMany_Required_Self_Inverse4Id10`, `t2`.`OneToMany_Required_Self_Inverse4Id20`, `t2`.`OneToOne_Optional_PK_Inverse4Id10`, `t2`.`OneToOne_Optional_PK_Inverse4Id20`, `t2`.`OneToOne_Optional_Self4Id10`, `t2`.`OneToOne_Optional_Self4Id20`, `t2`.`Name2`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`Level3_Optional_Id11`, `t2`.`Level3_Optional_Id21`, `t2`.`Level3_Required_Id11`, `t2`.`Level3_Required_Id21`, `t2`.`Name01`, `t2`.`OneToMany_Optional_Inverse4Id11`, `t2`.`OneToMany_Optional_Inverse4Id21`, `t2`.`OneToMany_Optional_Self_Inverse4Id11`, `t2`.`OneToMany_Optional_Self_Inverse4Id21`, `t2`.`OneToMany_Required_Inverse4Id11`, `t2`.`OneToMany_Required_Inverse4Id21`, `t2`.`OneToMany_Required_Self_Inverse4Id11`, `t2`.`OneToMany_Required_Self_Inverse4Id21`, `t2`.`OneToOne_Optional_PK_Inverse4Id11`, `t2`.`OneToOne_Optional_PK_Inverse4Id21`, `t2`.`OneToOne_Optional_Self4Id11`, `t2`.`OneToOne_Optional_Self4Id21`, `t2`.`Id110`, `t2`.`Id210`, `t2`.`Level3_Optional_Id100`, `t2`.`Level3_Optional_Id200`, `t2`.`Level3_Required_Id100`, `t2`.`Level3_Required_Id200`, `t2`.`Name10`, `t2`.`OneToMany_Optional_Inverse4Id100`, `t2`.`OneToMany_Optional_Inverse4Id200`, `t2`.`OneToMany_Optional_Self_Inverse4Id100`, `t2`.`OneToMany_Optional_Self_Inverse4Id200`, `t2`.`OneToMany_Required_Inverse4Id100`, `t2`.`OneToMany_Required_Inverse4Id200`, `t2`.`OneToMany_Required_Self_Inverse4Id100`, `t2`.`OneToMany_Required_Self_Inverse4Id200`, `t2`.`OneToOne_Optional_PK_Inverse4Id100`, `t2`.`OneToOne_Optional_PK_Inverse4Id200`, `t2`.`OneToOne_Optional_Self4Id100`, `t2`.`OneToOne_Optional_Self4Id200`
FROM (`CompositeOnes` AS `c`
LEFT JOIN (
    SELECT `c0`.`Name`, `c0`.`Id1`, `c0`.`Id2`, `t`.`Id1` AS `Id10`, `t`.`Id2` AS `Id20`, `t`.`Id10` AS `Id100`, `t`.`Id20` AS `Id200`, `t`.`Level3_Optional_Id1`, `t`.`Level3_Optional_Id2`, `t`.`Level3_Required_Id1`, `t`.`Level3_Required_Id2`, `t`.`Name` AS `Name0`, `t`.`OneToMany_Optional_Inverse4Id1`, `t`.`OneToMany_Optional_Inverse4Id2`, `t`.`OneToMany_Optional_Self_Inverse4Id1`, `t`.`OneToMany_Optional_Self_Inverse4Id2`, `t`.`OneToMany_Required_Inverse4Id1`, `t`.`OneToMany_Required_Inverse4Id2`, `t`.`OneToMany_Required_Self_Inverse4Id1`, `t`.`OneToMany_Required_Self_Inverse4Id2`, `t`.`OneToOne_Optional_PK_Inverse4Id1`, `t`.`OneToOne_Optional_PK_Inverse4Id2`, `t`.`OneToOne_Optional_Self4Id1`, `t`.`OneToOne_Optional_Self4Id2`, `t`.`Id11`, `t`.`Id21`, `t`.`Level3_Optional_Id10`, `t`.`Level3_Optional_Id20`, `t`.`Level3_Required_Id10`, `t`.`Level3_Required_Id20`, `t`.`Name0` AS `Name00`, `t`.`OneToMany_Optional_Inverse4Id10`, `t`.`OneToMany_Optional_Inverse4Id20`, `t`.`OneToMany_Optional_Self_Inverse4Id10`, `t`.`OneToMany_Optional_Self_Inverse4Id20`, `t`.`OneToMany_Required_Inverse4Id10`, `t`.`OneToMany_Required_Inverse4Id20`, `t`.`OneToMany_Required_Self_Inverse4Id10`, `t`.`OneToMany_Required_Self_Inverse4Id20`, `t`.`OneToOne_Optional_PK_Inverse4Id10`, `t`.`OneToOne_Optional_PK_Inverse4Id20`, `t`.`OneToOne_Optional_Self4Id10`, `t`.`OneToOne_Optional_Self4Id20`, `t0`.`Name` AS `Name1`, `t0`.`Id1` AS `Id12`, `t0`.`Id2` AS `Id22`, `t0`.`Id10` AS `Id101`, `t0`.`Id20` AS `Id201`, `t0`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t0`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t0`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t0`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t0`.`Name0` AS `Name01`, `t0`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t0`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t0`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t0`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t0`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t0`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t0`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t0`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t0`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t0`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t0`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t0`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t0`.`Id11` AS `Id110`, `t0`.`Id21` AS `Id210`, `t0`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t0`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t0`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t0`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t0`.`Name1` AS `Name10`, `t0`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t0`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t0`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t0`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t0`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t0`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t0`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t0`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t0`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t0`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t0`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t0`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, `c0`.`OneToMany_Optional_Inverse2Id1`, `c0`.`OneToMany_Optional_Inverse2Id2`
    FROM (`CompositeTwos` AS `c0`
    LEFT JOIN (
        SELECT `c1`.`Id1`, `c1`.`Id2`, `c2`.`Id1` AS `Id10`, `c2`.`Id2` AS `Id20`, `c2`.`Level3_Optional_Id1`, `c2`.`Level3_Optional_Id2`, `c2`.`Level3_Required_Id1`, `c2`.`Level3_Required_Id2`, `c2`.`Name`, `c2`.`OneToMany_Optional_Inverse4Id1`, `c2`.`OneToMany_Optional_Inverse4Id2`, `c2`.`OneToMany_Optional_Self_Inverse4Id1`, `c2`.`OneToMany_Optional_Self_Inverse4Id2`, `c2`.`OneToMany_Required_Inverse4Id1`, `c2`.`OneToMany_Required_Inverse4Id2`, `c2`.`OneToMany_Required_Self_Inverse4Id1`, `c2`.`OneToMany_Required_Self_Inverse4Id2`, `c2`.`OneToOne_Optional_PK_Inverse4Id1`, `c2`.`OneToOne_Optional_PK_Inverse4Id2`, `c2`.`OneToOne_Optional_Self4Id1`, `c2`.`OneToOne_Optional_Self4Id2`, `c3`.`Id1` AS `Id11`, `c3`.`Id2` AS `Id21`, `c3`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c3`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c3`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c3`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c3`.`Name` AS `Name0`, `c3`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c3`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c3`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c3`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c3`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c3`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c3`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c3`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c3`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c3`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c3`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c3`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c1`.`OneToMany_Required_Inverse3Id1`, `c1`.`OneToMany_Required_Inverse3Id2`
        FROM (`CompositeThrees` AS `c1`
        LEFT JOIN `CompositeFours` AS `c2` ON `c1`.`Id1` = `c2`.`OneToMany_Optional_Inverse4Id1` AND `c1`.`Id2` = `c2`.`OneToMany_Optional_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c3` ON `c1`.`Id1` = `c3`.`OneToMany_Required_Inverse4Id1` AND `c1`.`Id2` = `c3`.`OneToMany_Required_Inverse4Id2`
    ) AS `t` ON `c0`.`Id1` = `t`.`OneToMany_Required_Inverse3Id1` AND `c0`.`Id2` = `t`.`OneToMany_Required_Inverse3Id2`)
    LEFT JOIN (
        SELECT `c4`.`Name`, `c4`.`Id1`, `c4`.`Id2`, `c5`.`Id1` AS `Id10`, `c5`.`Id2` AS `Id20`, `c5`.`Level3_Optional_Id1`, `c5`.`Level3_Optional_Id2`, `c5`.`Level3_Required_Id1`, `c5`.`Level3_Required_Id2`, `c5`.`Name` AS `Name0`, `c5`.`OneToMany_Optional_Inverse4Id1`, `c5`.`OneToMany_Optional_Inverse4Id2`, `c5`.`OneToMany_Optional_Self_Inverse4Id1`, `c5`.`OneToMany_Optional_Self_Inverse4Id2`, `c5`.`OneToMany_Required_Inverse4Id1`, `c5`.`OneToMany_Required_Inverse4Id2`, `c5`.`OneToMany_Required_Self_Inverse4Id1`, `c5`.`OneToMany_Required_Self_Inverse4Id2`, `c5`.`OneToOne_Optional_PK_Inverse4Id1`, `c5`.`OneToOne_Optional_PK_Inverse4Id2`, `c5`.`OneToOne_Optional_Self4Id1`, `c5`.`OneToOne_Optional_Self4Id2`, `c6`.`Id1` AS `Id11`, `c6`.`Id2` AS `Id21`, `c6`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c6`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c6`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c6`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c6`.`Name` AS `Name1`, `c6`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c6`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c6`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c6`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c6`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c6`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c6`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c6`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c6`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c6`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c6`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c6`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c4`.`OneToMany_Optional_Inverse3Id1`, `c4`.`OneToMany_Optional_Inverse3Id2`
        FROM (`CompositeThrees` AS `c4`
        LEFT JOIN `CompositeFours` AS `c5` ON `c4`.`Id1` = `c5`.`OneToMany_Required_Inverse4Id1` AND `c4`.`Id2` = `c5`.`OneToMany_Required_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c6` ON `c4`.`Id1` = `c6`.`OneToMany_Optional_Inverse4Id1` AND `c4`.`Id2` = `c6`.`OneToMany_Optional_Inverse4Id2`
    ) AS `t0` ON `c0`.`Id1` = `t0`.`OneToMany_Optional_Inverse3Id1` AND `c0`.`Id2` = `t0`.`OneToMany_Optional_Inverse3Id2`
) AS `t1` ON `c`.`Id1` = `t1`.`OneToMany_Optional_Inverse2Id1` AND `c`.`Id2` = `t1`.`OneToMany_Optional_Inverse2Id2`)
LEFT JOIN (
    SELECT `c7`.`Name`, `c7`.`Id1`, `c7`.`Id2`, `t3`.`Name` AS `Name0`, `t3`.`Id1` AS `Id10`, `t3`.`Id2` AS `Id20`, `t3`.`Id10` AS `Id100`, `t3`.`Id20` AS `Id200`, `t3`.`Level3_Optional_Id1`, `t3`.`Level3_Optional_Id2`, `t3`.`Level3_Required_Id1`, `t3`.`Level3_Required_Id2`, `t3`.`Name0` AS `Name00`, `t3`.`OneToMany_Optional_Inverse4Id1`, `t3`.`OneToMany_Optional_Inverse4Id2`, `t3`.`OneToMany_Optional_Self_Inverse4Id1`, `t3`.`OneToMany_Optional_Self_Inverse4Id2`, `t3`.`OneToMany_Required_Inverse4Id1`, `t3`.`OneToMany_Required_Inverse4Id2`, `t3`.`OneToMany_Required_Self_Inverse4Id1`, `t3`.`OneToMany_Required_Self_Inverse4Id2`, `t3`.`OneToOne_Optional_PK_Inverse4Id1`, `t3`.`OneToOne_Optional_PK_Inverse4Id2`, `t3`.`OneToOne_Optional_Self4Id1`, `t3`.`OneToOne_Optional_Self4Id2`, `t3`.`Id11`, `t3`.`Id21`, `t3`.`Level3_Optional_Id10`, `t3`.`Level3_Optional_Id20`, `t3`.`Level3_Required_Id10`, `t3`.`Level3_Required_Id20`, `t3`.`Name1`, `t3`.`OneToMany_Optional_Inverse4Id10`, `t3`.`OneToMany_Optional_Inverse4Id20`, `t3`.`OneToMany_Optional_Self_Inverse4Id10`, `t3`.`OneToMany_Optional_Self_Inverse4Id20`, `t3`.`OneToMany_Required_Inverse4Id10`, `t3`.`OneToMany_Required_Inverse4Id20`, `t3`.`OneToMany_Required_Self_Inverse4Id10`, `t3`.`OneToMany_Required_Self_Inverse4Id20`, `t3`.`OneToOne_Optional_PK_Inverse4Id10`, `t3`.`OneToOne_Optional_PK_Inverse4Id20`, `t3`.`OneToOne_Optional_Self4Id10`, `t3`.`OneToOne_Optional_Self4Id20`, `t4`.`Name` AS `Name2`, `t4`.`Id1` AS `Id12`, `t4`.`Id2` AS `Id22`, `t4`.`Id10` AS `Id101`, `t4`.`Id20` AS `Id201`, `t4`.`Level3_Optional_Id1` AS `Level3_Optional_Id11`, `t4`.`Level3_Optional_Id2` AS `Level3_Optional_Id21`, `t4`.`Level3_Required_Id1` AS `Level3_Required_Id11`, `t4`.`Level3_Required_Id2` AS `Level3_Required_Id21`, `t4`.`Name0` AS `Name01`, `t4`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id11`, `t4`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id21`, `t4`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id11`, `t4`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id21`, `t4`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id11`, `t4`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id21`, `t4`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id11`, `t4`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id21`, `t4`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id11`, `t4`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id21`, `t4`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id11`, `t4`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id21`, `t4`.`Id11` AS `Id110`, `t4`.`Id21` AS `Id210`, `t4`.`Level3_Optional_Id10` AS `Level3_Optional_Id100`, `t4`.`Level3_Optional_Id20` AS `Level3_Optional_Id200`, `t4`.`Level3_Required_Id10` AS `Level3_Required_Id100`, `t4`.`Level3_Required_Id20` AS `Level3_Required_Id200`, `t4`.`Name1` AS `Name10`, `t4`.`OneToMany_Optional_Inverse4Id10` AS `OneToMany_Optional_Inverse4Id100`, `t4`.`OneToMany_Optional_Inverse4Id20` AS `OneToMany_Optional_Inverse4Id200`, `t4`.`OneToMany_Optional_Self_Inverse4Id10` AS `OneToMany_Optional_Self_Inverse4Id100`, `t4`.`OneToMany_Optional_Self_Inverse4Id20` AS `OneToMany_Optional_Self_Inverse4Id200`, `t4`.`OneToMany_Required_Inverse4Id10` AS `OneToMany_Required_Inverse4Id100`, `t4`.`OneToMany_Required_Inverse4Id20` AS `OneToMany_Required_Inverse4Id200`, `t4`.`OneToMany_Required_Self_Inverse4Id10` AS `OneToMany_Required_Self_Inverse4Id100`, `t4`.`OneToMany_Required_Self_Inverse4Id20` AS `OneToMany_Required_Self_Inverse4Id200`, `t4`.`OneToOne_Optional_PK_Inverse4Id10` AS `OneToOne_Optional_PK_Inverse4Id100`, `t4`.`OneToOne_Optional_PK_Inverse4Id20` AS `OneToOne_Optional_PK_Inverse4Id200`, `t4`.`OneToOne_Optional_Self4Id10` AS `OneToOne_Optional_Self4Id100`, `t4`.`OneToOne_Optional_Self4Id20` AS `OneToOne_Optional_Self4Id200`, IIF(LEN(`c7`.`Name`) IS NULL, NULL, CLNG(LEN(`c7`.`Name`))) AS `c`, `t4`.`c` AS `c0`, `c7`.`OneToMany_Required_Inverse2Id1`, `c7`.`OneToMany_Required_Inverse2Id2`
    FROM (`CompositeTwos` AS `c7`
    LEFT JOIN (
        SELECT `c8`.`Name`, `c8`.`Id1`, `c8`.`Id2`, `c9`.`Id1` AS `Id10`, `c9`.`Id2` AS `Id20`, `c9`.`Level3_Optional_Id1`, `c9`.`Level3_Optional_Id2`, `c9`.`Level3_Required_Id1`, `c9`.`Level3_Required_Id2`, `c9`.`Name` AS `Name0`, `c9`.`OneToMany_Optional_Inverse4Id1`, `c9`.`OneToMany_Optional_Inverse4Id2`, `c9`.`OneToMany_Optional_Self_Inverse4Id1`, `c9`.`OneToMany_Optional_Self_Inverse4Id2`, `c9`.`OneToMany_Required_Inverse4Id1`, `c9`.`OneToMany_Required_Inverse4Id2`, `c9`.`OneToMany_Required_Self_Inverse4Id1`, `c9`.`OneToMany_Required_Self_Inverse4Id2`, `c9`.`OneToOne_Optional_PK_Inverse4Id1`, `c9`.`OneToOne_Optional_PK_Inverse4Id2`, `c9`.`OneToOne_Optional_Self4Id1`, `c9`.`OneToOne_Optional_Self4Id2`, `c10`.`Id1` AS `Id11`, `c10`.`Id2` AS `Id21`, `c10`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c10`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c10`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c10`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c10`.`Name` AS `Name1`, `c10`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c10`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c10`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c10`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c10`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c10`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c10`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c10`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c10`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c10`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c10`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c10`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c8`.`OneToMany_Optional_Inverse3Id1`, `c8`.`OneToMany_Optional_Inverse3Id2`
        FROM (`CompositeThrees` AS `c8`
        LEFT JOIN `CompositeFours` AS `c9` ON `c8`.`Id1` = `c9`.`OneToMany_Required_Inverse4Id1` AND `c8`.`Id2` = `c9`.`OneToMany_Required_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c10` ON `c8`.`Id1` = `c10`.`OneToMany_Optional_Inverse4Id1` AND `c8`.`Id2` = `c10`.`OneToMany_Optional_Inverse4Id2`
    ) AS `t3` ON `c7`.`Id1` = `t3`.`OneToMany_Optional_Inverse3Id1` AND `c7`.`Id2` = `t3`.`OneToMany_Optional_Inverse3Id2`)
    LEFT JOIN (
        SELECT `c11`.`Name`, `c11`.`Id1`, `c11`.`Id2`, `c12`.`Id1` AS `Id10`, `c12`.`Id2` AS `Id20`, `c12`.`Level3_Optional_Id1`, `c12`.`Level3_Optional_Id2`, `c12`.`Level3_Required_Id1`, `c12`.`Level3_Required_Id2`, `c12`.`Name` AS `Name0`, `c12`.`OneToMany_Optional_Inverse4Id1`, `c12`.`OneToMany_Optional_Inverse4Id2`, `c12`.`OneToMany_Optional_Self_Inverse4Id1`, `c12`.`OneToMany_Optional_Self_Inverse4Id2`, `c12`.`OneToMany_Required_Inverse4Id1`, `c12`.`OneToMany_Required_Inverse4Id2`, `c12`.`OneToMany_Required_Self_Inverse4Id1`, `c12`.`OneToMany_Required_Self_Inverse4Id2`, `c12`.`OneToOne_Optional_PK_Inverse4Id1`, `c12`.`OneToOne_Optional_PK_Inverse4Id2`, `c12`.`OneToOne_Optional_Self4Id1`, `c12`.`OneToOne_Optional_Self4Id2`, `c13`.`Id1` AS `Id11`, `c13`.`Id2` AS `Id21`, `c13`.`Level3_Optional_Id1` AS `Level3_Optional_Id10`, `c13`.`Level3_Optional_Id2` AS `Level3_Optional_Id20`, `c13`.`Level3_Required_Id1` AS `Level3_Required_Id10`, `c13`.`Level3_Required_Id2` AS `Level3_Required_Id20`, `c13`.`Name` AS `Name1`, `c13`.`OneToMany_Optional_Inverse4Id1` AS `OneToMany_Optional_Inverse4Id10`, `c13`.`OneToMany_Optional_Inverse4Id2` AS `OneToMany_Optional_Inverse4Id20`, `c13`.`OneToMany_Optional_Self_Inverse4Id1` AS `OneToMany_Optional_Self_Inverse4Id10`, `c13`.`OneToMany_Optional_Self_Inverse4Id2` AS `OneToMany_Optional_Self_Inverse4Id20`, `c13`.`OneToMany_Required_Inverse4Id1` AS `OneToMany_Required_Inverse4Id10`, `c13`.`OneToMany_Required_Inverse4Id2` AS `OneToMany_Required_Inverse4Id20`, `c13`.`OneToMany_Required_Self_Inverse4Id1` AS `OneToMany_Required_Self_Inverse4Id10`, `c13`.`OneToMany_Required_Self_Inverse4Id2` AS `OneToMany_Required_Self_Inverse4Id20`, `c13`.`OneToOne_Optional_PK_Inverse4Id1` AS `OneToOne_Optional_PK_Inverse4Id10`, `c13`.`OneToOne_Optional_PK_Inverse4Id2` AS `OneToOne_Optional_PK_Inverse4Id20`, `c13`.`OneToOne_Optional_Self4Id1` AS `OneToOne_Optional_Self4Id10`, `c13`.`OneToOne_Optional_Self4Id2` AS `OneToOne_Optional_Self4Id20`, `c13`.`Id1` & (`c13`.`Id2` & '') AS `c`, `c11`.`OneToMany_Optional_Inverse3Id1`, `c11`.`OneToMany_Optional_Inverse3Id2`
        FROM (`CompositeThrees` AS `c11`
        LEFT JOIN `CompositeFours` AS `c12` ON `c11`.`Id1` = `c12`.`OneToMany_Optional_Inverse4Id1` AND `c11`.`Id2` = `c12`.`OneToMany_Optional_Inverse4Id2`)
        LEFT JOIN `CompositeFours` AS `c13` ON `c11`.`Id1` = `c13`.`OneToMany_Required_Inverse4Id1` AND `c11`.`Id2` = `c13`.`OneToMany_Required_Inverse4Id2`
    ) AS `t4` ON `c7`.`Id1` = `t4`.`OneToMany_Optional_Inverse3Id1` AND `c7`.`Id2` = `t4`.`OneToMany_Optional_Inverse3Id2`
) AS `t2` ON `c`.`Id1` = `t2`.`OneToMany_Required_Inverse2Id1` AND `c`.`Id2` = `t2`.`OneToMany_Required_Inverse2Id2`
ORDER BY `c`.`Name`, `c`.`Id1`, `c`.`Id2`, `t1`.`Id1`, `t1`.`Id2`, `t1`.`Id20` DESC, `t1`.`Id10` DESC, `t1`.`Id100`, `t1`.`Id200`, `t1`.`Id11`, `t1`.`Id21`, `t1`.`Id12`, `t1`.`Id22`, `t1`.`Id101`, `t1`.`Id201`, `t1`.`Id110`, `t1`.`Id210`, `t2`.`c`, `t2`.`Id1`, `t2`.`Id2`, `t2`.`Id10`, `t2`.`Id20`, `t2`.`Id100`, `t2`.`Id200`, `t2`.`Id11`, `t2`.`Id21`, `t2`.`Id12`, `t2`.`Id22`, `t2`.`Id101`, `t2`.`Id201`, `t2`.`c0` DESC, `t2`.`Id110`
""");
    }

    private void AssertSql(params string[] expected)
        => Fixture.TestSqlLoggerFactory.AssertBaseline(expected);
}
