File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
src/NHibernate.Test/Stateless/FetchingLazyCollections Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 11using System ;
22using System . Collections . Generic ;
3+ using System . Linq ;
34using NHibernate . Cfg . MappingSchema ;
45using NHibernate . Mapping . ByCode ;
56using NHibernate . Mapping . ByCode . Conformist ;
7+ using NHibernate . Linq ;
68using NUnit . Framework ;
79using SharpTestsEx ;
810
@@ -129,6 +131,24 @@ public void ShouldWorkLoadingComplexEntities()
129131 tx . Commit ( ) ;
130132 }
131133
134+ using ( IStatelessSession s = sessions . OpenStatelessSession ( ) )
135+ using ( ITransaction tx = s . BeginTransaction ( ) )
136+ {
137+ IList < Family < Human > > hf = s . Query < Family < Human > > ( ) . FetchMany ( f => f . Childs ) . ToList ( ) ;
138+ Assert . That ( hf . Count , Is . EqualTo ( 1 ) ) ;
139+ Assert . That ( hf [ 0 ] . Father . Name , Is . EqualTo ( humanFather ) ) ;
140+ Assert . That ( hf [ 0 ] . Mother . Name , Is . EqualTo ( humanMother ) ) ;
141+ NHibernateUtil . IsInitialized ( hf [ 0 ] . Childs ) . Should ( "Lazy collection should be initialized" ) . Be . True ( ) ;
142+
143+ IList < Family < Reptile > > rf = s . Query < Family < Reptile > > ( ) . FetchMany ( f => f . Childs ) . ToList ( ) ;
144+ Assert . That ( rf . Count , Is . EqualTo ( 1 ) ) ;
145+ Assert . That ( rf [ 0 ] . Father . Description , Is . EqualTo ( crocodileFather ) ) ;
146+ Assert . That ( rf [ 0 ] . Mother . Description , Is . EqualTo ( crocodileMother ) ) ;
147+ NHibernateUtil . IsInitialized ( hf [ 0 ] . Childs ) . Should ( "Lazy collection should be initialized" ) . Be . True ( ) ;
148+
149+ tx . Commit ( ) ;
150+ }
151+
132152 using ( ISession s = sessions . OpenSession ( ) )
133153 using ( ITransaction tx = s . BeginTransaction ( ) )
134154 {
You can’t perform that action at this time.
0 commit comments