public void Test_Select_SourceTraverse() { var store = DatabaseHelper.Default.Store; var model = new DeepModel() { Sub1 = new DeepModel.SubModel1() { Sub2 = new DeepModel.SubModel2() { Sub3 = new List <DeepModel.SubModel3>() { new DeepModel.SubModel3() { Sub4 = new DeepModel.SubModel4() { Sub5 = new List <DeepModel.SubModel5>() { new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 1 }, new DeepModel.SubModel6() { Value = 2 }, new DeepModel.SubModel6() { Value = 3 }, }, }, new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 4 }, new DeepModel.SubModel6() { Value = 5 }, }, }, new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 6 }, }, } }, }, }, new DeepModel.SubModel3() { Sub4 = new DeepModel.SubModel4() { Sub5 = new List <DeepModel.SubModel5>() { new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 7 }, new DeepModel.SubModel6() { Value = 8 }, null, }, }, new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 9 }, }, }, }, }, }, new DeepModel.SubModel3() { Sub4 = new DeepModel.SubModel4() { Sub5 = new List <DeepModel.SubModel5>(), }, }, }, }, }, }; var valueAttr = "Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6.Item.Value"; var rel1 = store.From(model).Select(valueAttr); var rel2 = rel1.Source.Lookup("Sub1").Select(valueAttr); var rel3 = rel2.Source.Lookup("Sub1.Sub2").Select(valueAttr); var rel4 = rel3.Source.Lookup("Sub1.Sub2.Sub3").Select(valueAttr); var rel5 = rel4.Source.Lookup("Sub1.Sub2.Sub3.Item").Select(valueAttr); var rel6 = rel5.Source.Lookup("Sub1.Sub2.Sub3.Item.Sub4").Select(valueAttr); var rel7 = rel6.Source.Lookup("Sub1.Sub2.Sub3.Item.Sub4.Sub5").Select(valueAttr); var rel8 = rel7.Source.Lookup("Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item").Select(valueAttr); var rel9 = rel8.Source.Lookup("Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6").Select(valueAttr); var rel10 = rel9.Source.Lookup("Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6.Item").Select(valueAttr); var rel11 = rel10.Source.Lookup("Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6.Item.Value").Select(valueAttr); rel1.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel2.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel3.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel4.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel5.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6 }); rel6.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6 }); rel7.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6 }); rel8.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3 }); rel9.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1, 2, 3 }); rel10.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1 }); rel11.Column().Select(f => (int?)f.Snapshot).ShouldBe(new int?[] { 1 }); }
public void Test_Reading_OfDeepObjectGraphFromDifferentSources() { DeepModel model = new DeepModel() { Sub1 = new DeepModel.SubModel1() { Sub2 = new DeepModel.SubModel2() { Sub3 = new List <DeepModel.SubModel3>() { new DeepModel.SubModel3() { Sub4 = new DeepModel.SubModel4() { Sub5 = new List <DeepModel.SubModel5>() { new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 1 }, new DeepModel.SubModel6() { Value = 2 }, new DeepModel.SubModel6() { Value = 3 }, }, }, new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 4 }, new DeepModel.SubModel6() { Value = 5 }, }, }, new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 6 }, }, } }, }, }, new DeepModel.SubModel3() { Sub4 = new DeepModel.SubModel4() { Sub5 = new List <DeepModel.SubModel5>() { new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 7 }, new DeepModel.SubModel6() { Value = 8 }, null, }, }, new DeepModel.SubModel5() { Sub6 = new List <DeepModel.SubModel6>() { new DeepModel.SubModel6() { Value = 9 }, }, }, }, }, }, new DeepModel.SubModel3() { Sub4 = new DeepModel.SubModel4() { Sub5 = new List <DeepModel.SubModel5>(), }, }, }, }, }, }; string valueAttr = "Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6.Item.Value"; Relation rel1 = DatabaseHelper.Default.Relation(model, valueAttr); Relation rel2 = new Relation(new Relation(rel1, "Sub1").Scalar(), valueAttr); Relation rel3 = new Relation(new Relation(rel2, "Sub1.Sub2").Scalar(), valueAttr); Relation rel4 = new Relation(new Relation(rel3, "Sub1.Sub2.Sub3").Scalar(), valueAttr); Relation rel5 = new Relation(new Relation(rel4, "Sub1.Sub2.Sub3.Item").Scalar(), valueAttr); Relation rel6 = new Relation(new Relation(rel5, "Sub1.Sub2.Sub3.Item.Sub4").Scalar(), valueAttr); Relation rel7 = new Relation(new Relation(rel6, "Sub1.Sub2.Sub3.Item.Sub4.Sub5").Scalar(), valueAttr); Relation rel8 = new Relation(new Relation(rel7, "Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item").Scalar(), valueAttr); Relation rel9 = new Relation(new Relation(rel8, "Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6").Scalar(), valueAttr); Relation rel10 = new Relation(new Relation(rel9, "Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6.Item").Scalar(), valueAttr); Relation rel11 = new Relation(new Relation(rel10, "Sub1.Sub2.Sub3.Item.Sub4.Sub5.Item.Sub6.Item.Value").Scalar(), valueAttr); rel1.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel2.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel3.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel4.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6, 7, 8, null, 9 }); rel5.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6 }); rel6.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6 }); rel7.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3, 4, 5, 6 }); rel8.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3 }); rel9.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1, 2, 3 }); rel10.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1 }); rel11.Column().Select(f => (int?)f.Value).ShouldBe(new int?[] { 1 }); }