File tree Expand file tree Collapse file tree 4 files changed +70
-7
lines changed
NHibernate/Collection/Generic Expand file tree Collapse file tree 4 files changed +70
-7
lines changed Original file line number Diff line number Diff line change 1- //------------------------------------------------------------------------------
1+ //------------------------------------------------------------------------------
22// <auto-generated>
33// This code was generated by AsyncGenerator.
44//
@@ -306,5 +306,38 @@ public async Task SQLQueryAsync()
306306 await ( t . CommitAsync ( ) ) ;
307307 }
308308 }
309+
310+ [ Test ]
311+ public async Task AddToUninitializedSetWithLaterLazyLoadAsync ( )
312+ {
313+ User gavin ;
314+
315+ using ( var s = OpenSession ( ) )
316+ using ( var t = s . BeginTransaction ( ) )
317+ {
318+ gavin = new User ( "gavin" , "secret" ) ;
319+ var hia = new Document ( "HiA" , "blah blah blah" , gavin ) ;
320+ gavin . Documents . Add ( hia ) ;
321+ await ( s . PersistAsync ( gavin ) ) ;
322+ await ( t . CommitAsync ( ) ) ;
323+ }
324+
325+ using ( var s = OpenSession ( ) )
326+ using ( var t = s . BeginTransaction ( ) )
327+ {
328+ gavin = await ( s . GetAsync < User > ( "gavin" ) ) ;
329+ var hia2 = new Document ( "HiA2" , "blah blah blah blah" , gavin ) ;
330+ gavin . Documents . Add ( hia2 ) ;
331+
332+ foreach ( var _ in gavin . Documents )
333+ {
334+ //Force Iteration
335+ }
336+
337+ Assert . That ( gavin . Documents . Contains ( hia2 ) ) ;
338+ await ( s . DeleteAsync ( gavin ) ) ;
339+ await ( t . CommitAsync ( ) ) ;
340+ }
341+ }
309342 }
310343}
Original file line number Diff line number Diff line change 99
1010
1111using System ;
12- using System . Data . Common ;
13- using NUnit . Framework ;
1412using NHibernate . Dialect ;
15-
13+ using NUnit . Framework ;
1614
1715namespace NHibernate . Test . NHSpecificTest . NH1316
1816{
Original file line number Diff line number Diff line change @@ -295,5 +295,38 @@ public void SQLQuery()
295295 t . Commit ( ) ;
296296 }
297297 }
298+
299+ [ Test ]
300+ public void AddToUninitializedSetWithLaterLazyLoad ( )
301+ {
302+ User gavin ;
303+
304+ using ( var s = OpenSession ( ) )
305+ using ( var t = s . BeginTransaction ( ) )
306+ {
307+ gavin = new User ( "gavin" , "secret" ) ;
308+ var hia = new Document ( "HiA" , "blah blah blah" , gavin ) ;
309+ gavin . Documents . Add ( hia ) ;
310+ s . Persist ( gavin ) ;
311+ t . Commit ( ) ;
312+ }
313+
314+ using ( var s = OpenSession ( ) )
315+ using ( var t = s . BeginTransaction ( ) )
316+ {
317+ gavin = s . Get < User > ( "gavin" ) ;
318+ var hia2 = new Document ( "HiA2" , "blah blah blah blah" , gavin ) ;
319+ gavin . Documents . Add ( hia2 ) ;
320+
321+ foreach ( var _ in gavin . Documents )
322+ {
323+ //Force Iteration
324+ }
325+
326+ Assert . That ( gavin . Documents . Contains ( hia2 ) ) ;
327+ s . Delete ( gavin ) ;
328+ t . Commit ( ) ;
329+ }
330+ }
298331 }
299332}
Original file line number Diff line number Diff line change @@ -191,13 +191,12 @@ public override void BeginRead()
191191 /// </summary>
192192 public override bool EndRead ( ICollectionPersister persister )
193193 {
194- foreach ( T item in _tempList )
194+ foreach ( var item in _tempList )
195195 {
196196 WrappedSet . Add ( item ) ;
197197 }
198198 _tempList = null ;
199- SetInitialized ( ) ;
200- return true ;
199+ return base . EndRead ( persister ) ;
201200 }
202201
203202 public override IEnumerable Entries ( ICollectionPersister persister )
You can’t perform that action at this time.
0 commit comments