@@ -813,6 +813,15 @@ public class TestInclude_OneToManyModel3 {
813813
814814 public int model2111Idaaa { get ; set ; }
815815 public string title { get ; set ; }
816+
817+ public List < TestInclude_OneToManyModel4 > childs2 { get ; set ; }
818+ }
819+ public class TestInclude_OneToManyModel4 {
820+ [ Column ( IsIdentity = true ) ]
821+ public int id { get ; set ; }
822+
823+ public int model3333Id333 { get ; set ; }
824+ public string title444 { get ; set ; }
816825 }
817826
818827 [ Fact ]
@@ -822,17 +831,32 @@ public void Include_OneToMany() {
822831 var model2 = new TestInclude_OneToManyModel2 { model2id = model1 . id , m2setting = DateTime . Now . Second . ToString ( ) } ;
823832 _sqlserverFixture . SqlServer . Insert ( model2 ) . ExecuteAffrows ( ) ;
824833
825- var model3s = new [ ] {
826- new TestInclude_OneToManyModel3 { model2111Idaaa = model1 . id , title = "testmodel3__111" } ,
827- new TestInclude_OneToManyModel3 { model2111Idaaa = model1 . id , title = "testmodel3__222" } ,
828- new TestInclude_OneToManyModel3 { model2111Idaaa = model1 . id , title = "testmodel3__333" }
834+ var model3_1 = new TestInclude_OneToManyModel3 { model2111Idaaa = model1 . id , title = "testmodel3__111" } ;
835+ model3_1 . id = ( int ) _sqlserverFixture . SqlServer . Insert ( model3_1 ) . ExecuteIdentity ( ) ;
836+ var model3_2 = new TestInclude_OneToManyModel3 { model2111Idaaa = model1 . id , title = "testmodel3__222" } ;
837+ model3_2 . id = ( int ) _sqlserverFixture . SqlServer . Insert ( model3_2 ) . ExecuteIdentity ( ) ;
838+ var model3_3 = new TestInclude_OneToManyModel3 { model2111Idaaa = model1 . id , title = "testmodel3__333" } ;
839+ model3_3 . id = ( int ) _sqlserverFixture . SqlServer . Insert ( model3_2 ) . ExecuteIdentity ( ) ;
840+
841+ var model4s = new [ ] {
842+ new TestInclude_OneToManyModel4 { model3333Id333 = model3_1 . id , title444 = "testmodel3_4__111" } ,
843+ new TestInclude_OneToManyModel4 { model3333Id333 = model3_1 . id , title444 = "testmodel3_4__222" } ,
844+ new TestInclude_OneToManyModel4 { model3333Id333 = model3_2 . id , title444 = "testmodel3_4__111" } ,
845+ new TestInclude_OneToManyModel4 { model3333Id333 = model3_2 . id , title444 = "testmodel3_4__222" } ,
846+ new TestInclude_OneToManyModel4 { model3333Id333 = model3_2 . id , title444 = "testmodel3_4__333" }
829847 } ;
830- Assert . Equal ( 3 , _sqlserverFixture . SqlServer . Insert ( model3s ) . ExecuteAffrows ( ) ) ;
848+ Assert . Equal ( 5 , _sqlserverFixture . SqlServer . Insert ( model4s ) . ExecuteAffrows ( ) ) ;
831849
832850 var t1 = _sqlserverFixture . SqlServer . Select < TestInclude_OneToManyModel1 > ( )
833851 . IncludeMany ( a => a . model2 . childs . Where ( m3 => m3 . model2111Idaaa == a . model2 . model2id ) )
834852 . Where ( a => a . id <= model1 . id )
835853 . ToList ( ) ;
854+
855+ var t2 = _sqlserverFixture . SqlServer . Select < TestInclude_OneToManyModel1 > ( )
856+ . IncludeMany ( a => a . model2 . childs . Where ( m3 => m3 . model2111Idaaa == a . model2 . model2id ) ,
857+ then => then . IncludeMany ( m3 => m3 . childs2 . Where ( m4 => m4 . model3333Id333 == m3 . id ) ) )
858+ . Where ( a => a . id <= model1 . id )
859+ . ToList ( ) ;
836860 }
837861 [ Fact ]
838862 public void Include_OneToChilds ( ) {
0 commit comments