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
+ //------------------------------------------------------------------------------
2
2
// <auto-generated>
3
3
// This code was generated by AsyncGenerator.
4
4
//
@@ -306,5 +306,38 @@ public async Task SQLQueryAsync()
306
306
await ( t . CommitAsync ( ) ) ;
307
307
}
308
308
}
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
+ }
309
342
}
310
343
}
Original file line number Diff line number Diff line change 9
9
10
10
11
11
using System ;
12
- using System . Data . Common ;
13
- using NUnit . Framework ;
14
12
using NHibernate . Dialect ;
15
-
13
+ using NUnit . Framework ;
16
14
17
15
namespace NHibernate . Test . NHSpecificTest . NH1316
18
16
{
Original file line number Diff line number Diff line change @@ -295,5 +295,38 @@ public void SQLQuery()
295
295
t . Commit ( ) ;
296
296
}
297
297
}
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
+ }
298
331
}
299
332
}
Original file line number Diff line number Diff line change @@ -191,13 +191,12 @@ public override void BeginRead()
191
191
/// </summary>
192
192
public override bool EndRead ( ICollectionPersister persister )
193
193
{
194
- foreach ( T item in _tempList )
194
+ foreach ( var item in _tempList )
195
195
{
196
196
WrappedSet . Add ( item ) ;
197
197
}
198
198
_tempList = null ;
199
- SetInitialized ( ) ;
200
- return true ;
199
+ return base . EndRead ( persister ) ;
201
200
}
202
201
203
202
public override IEnumerable Entries ( ICollectionPersister persister )
You can’t perform that action at this time.
0 commit comments