Beispiel #1
0
        public void Many_Many_Single_Single_Null()
        {
            try
            {
                QueryIncludeOptimizedManager.AllowIncludeSubPath = true;
                QueryIncludeOptimizedHelper.InsertOneToOneAndMany(many1: true, many2: true, single3: true, single4: false);

                using (var ctx = new TestContext())
                {
                    var left = ctx.Association_OneToSingleAndMany_Lefts
                               .IncludeOptimized(x => x.Many_Right.SelectMany(y => y.Many_RightRight.Select(z => z.Single_RightRightRight.Single_RightRightRightRight)))
                               .ToList().First();

                    var list1 = new List <Association_OneToSingleAndMany_Right>();
                    var list2 = new List <Association_OneToSingleAndMany_RightRight>();
                    var list3 = new List <Association_OneToSingleAndMany_RightRightRight>();

                    // Level 1
                    {
                        Assert.IsNull(left.Single_Right);
                        Assert.AreEqual(1, left.Many_Right.Count);

                        list1.AddRange(left.Many_Right);
                    }

                    // Level 2
                    {
                        foreach (var item in list1)
                        {
                            Assert.IsNull(item.Single_RightRight);
                            Assert.AreEqual(1, item.Many_RightRight.Count);

                            list2.AddRange(item.Many_RightRight);
                        }
                    }

                    // Level 3
                    {
                        foreach (var item in list2)
                        {
                            Assert.IsNotNull(item.Single_RightRightRight);
                            Assert.IsNull(item.Many_RightRightRight);

                            list3.Add(item.Single_RightRightRight);
                        }
                    }

                    // Level 4
                    {
                        foreach (var item in list3)
                        {
                            Assert.IsNull(item.Single_RightRightRightRight);
                            Assert.IsNull(item.Many_RightRightRightRight);
                        }
                    }
                }
            }
            finally
            {
                QueryIncludeOptimizedManager.AllowIncludeSubPath = false;
            }
        }