File tree Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Expand file tree Collapse file tree 3 files changed +31
-1
lines changed Original file line number Diff line number Diff line change 60
60
name : BestGuessEntityName
61
61
containingTypeName : ISessionImplementor
62
62
- conversion : Ignore
63
- name : Contains
63
+ name : CloseSessionFromSystemTransaction
64
64
containingTypeName : ISessionImplementor
65
+ # TODO 6.0: Remove ignore rule for IStatelessSession.Close
66
+ - conversion : Ignore
67
+ name : Close
68
+ containingTypeName : IStatelessSession
65
69
- conversion : Ignore
66
70
name : GetUnsavedVersionValue
67
71
containingTypeName : UnsavedValueFactory
Original file line number Diff line number Diff line change @@ -322,6 +322,24 @@ public async Task ManagedFlushAsync(CancellationToken cancellationToken)
322
322
323
323
#region IStatelessSession Members
324
324
325
+ public async Task ManagedCloseAsync ( CancellationToken cancellationToken )
326
+ {
327
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
328
+ using ( BeginContext ( ) )
329
+ {
330
+ if ( IsClosed )
331
+ {
332
+ throw new SessionException ( "Session was already closed!" ) ;
333
+ }
334
+ // We need to flush the batcher. Otherwise it may have pending operations which will never reach the database,
335
+ // although a stateless session is not supposed to retain anything in memory and so should not need any explicit
336
+ // flush from users.
337
+ await ( FlushAsync ( cancellationToken ) ) . ConfigureAwait ( false ) ;
338
+ CloseConnectionManager ( ) ;
339
+ SetClosed ( ) ;
340
+ }
341
+ }
342
+
325
343
/// <summary> Insert a entity.</summary>
326
344
/// <param name="entity">A new transient instance </param>
327
345
/// <param name="cancellationToken">A cancellation token that can be used to cancel the work</param>
Original file line number Diff line number Diff line change @@ -438,6 +438,10 @@ public void ManagedClose()
438
438
{
439
439
throw new SessionException ( "Session was already closed!" ) ;
440
440
}
441
+ // We need to flush the batcher. Otherwise it may have pending operations which will never reach the database,
442
+ // although a stateless session is not supposed to retain anything in memory and so should not need any explicit
443
+ // flush from users.
444
+ Flush ( ) ;
441
445
CloseConnectionManager ( ) ;
442
446
SetClosed ( ) ;
443
447
}
@@ -786,6 +790,10 @@ public void Dispose()
786
790
// with a null ref rather than silently leaking a session. And then fix the synchronization.
787
791
if ( TransactionContext != null && TransactionContext . CanFlushOnSystemTransactionCompleted )
788
792
{
793
+ // We need to flush the batcher. Otherwise it may have pending operations which will never reach the database,
794
+ // although a stateless session is not supposed to retain anything in memory and so should not need any explicit
795
+ // flush from users.
796
+ Flush ( ) ;
789
797
TransactionContext . ShouldCloseSessionOnSystemTransactionCompleted = true ;
790
798
return ;
791
799
}
You can’t perform that action at this time.
0 commit comments