File tree 3 files changed +20
-0
lines changed 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -155,6 +155,7 @@ private void CloseConnection()
155
155
{
156
156
Factory . ConnectionProvider . CloseConnection ( _connection ) ;
157
157
_connection = null ;
158
+ _connectionAmbientTransaction = null ;
158
159
}
159
160
160
161
public DbConnection GetConnection ( )
@@ -374,10 +375,17 @@ public void EnlistIfRequired()
374
375
var tran = System . Transactions . Transaction . Current ;
375
376
if ( tran == _connectionAmbientTransaction )
376
377
return ;
378
+
379
+ if ( tran == null && ! Factory . Dialect . RequiresNullEnlistment )
380
+ {
381
+ _connectionAmbientTransaction = null ;
382
+ return ;
383
+ }
377
384
// Will fail if the connection is already enlisted in another not yet completed transaction.
378
385
// Probable case: nested transaction scope. Supporting this could be done by releasing the
379
386
// connection instead of enlisting.
380
387
_session . Connection . EnlistTransaction ( tran ) ;
388
+ _connectionAmbientTransaction = tran ;
381
389
}
382
390
383
391
private bool RequireConnectionSwapInDtc
Original file line number Diff line number Diff line change @@ -1410,6 +1410,12 @@ public IList<SqlString> GetTokens()
1410
1410
/// </summary>
1411
1411
public virtual bool SupportsConcurrentWritingConnectionsInSameTransaction => SupportsConcurrentWritingConnections ;
1412
1412
1413
+ /// <summary>
1414
+ /// Does this dialect requires null enlistment for reusing a connection after a transaction scope, without
1415
+ /// using a new scope?
1416
+ /// </summary>
1417
+ public virtual bool RequiresNullEnlistment => false ;
1418
+
1413
1419
#endregion
1414
1420
1415
1421
#region Limit/offset support
Original file line number Diff line number Diff line change @@ -464,6 +464,12 @@ public override long TimestampResolutionInTicks
464
464
}
465
465
}
466
466
467
+ /// <summary>
468
+ /// Does this dialect requires null enlistment for reusing a connection after a transaction scope, without
469
+ /// using a new scope?
470
+ /// </summary>
471
+ public override bool RequiresNullEnlistment => true ;
472
+
467
473
#region Overridden informational metadata
468
474
469
475
public override bool SupportsEmptyInList
You can’t perform that action at this time.
0 commit comments