@@ -813,6 +813,15 @@ public class TestInclude_OneToManyModel3 {
813
813
814
814
public int model2111Idaaa { get ; set ; }
815
815
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 ; }
816
825
}
817
826
818
827
[ Fact ]
@@ -822,17 +831,32 @@ public void Include_OneToMany() {
822
831
var model2 = new TestInclude_OneToManyModel2 { model2id = model1 . id , m2setting = DateTime . Now . Second . ToString ( ) } ;
823
832
_sqlserverFixture . SqlServer . Insert ( model2 ) . ExecuteAffrows ( ) ;
824
833
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" }
829
847
} ;
830
- Assert . Equal ( 3 , _sqlserverFixture . SqlServer . Insert ( model3s ) . ExecuteAffrows ( ) ) ;
848
+ Assert . Equal ( 5 , _sqlserverFixture . SqlServer . Insert ( model4s ) . ExecuteAffrows ( ) ) ;
831
849
832
850
var t1 = _sqlserverFixture . SqlServer . Select < TestInclude_OneToManyModel1 > ( )
833
851
. IncludeMany ( a => a . model2 . childs . Where ( m3 => m3 . model2111Idaaa == a . model2 . model2id ) )
834
852
. Where ( a => a . id <= model1 . id )
835
853
. 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 ( ) ;
836
860
}
837
861
[ Fact ]
838
862
public void Include_OneToChilds ( ) {
0 commit comments