File tree Expand file tree Collapse file tree
bitwarden_license/test/Scim.IntegrationTest/Controllers/v2
Infrastructure.EntityFramework/Data Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,8 +29,9 @@ public async Task Post_ConcurrentInvites_DoNotOvershootMaxAutoscaleSeats()
2929 {
3030 TestDatabase = new SqlServerTestDatabase ( )
3131 } ;
32- factory . SubstituteService ( ( IFeatureService f )
33- => f . IsEnabled ( FeatureFlagKeys . ScimInviteUserOptimization ) . Returns ( true ) ) ;
32+
33+ factory . SubstituteService ( ( IFeatureService f ) => f . IsEnabled ( FeatureFlagKeys . ScimInviteUserOptimization )
34+ . Returns ( true ) ) ;
3435
3536 try
3637 {
@@ -74,7 +75,7 @@ public async Task Post_ConcurrentInvites_DoNotOvershootMaxAutoscaleSeats()
7475 }
7576 finally
7677 {
77- factory . Dispose ( ) ;
78+ await factory . DisposeAsync ( ) ;
7879 }
7980 }
8081
Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ public sealed class TransactionHolder : IAsyncDisposable
2121 public bool Committed { get ; set ; }
2222 public bool Doomed { get ; set ; }
2323
24+ /// <summary>
25+ /// True when this holder is responsible for disposing <see cref="Connection"/>.
26+ /// EF reuses the DbContext's connection and must leave its lifetime to the scope;
27+ /// Dapper opens its own connection and must dispose it here.
28+ /// </summary>
29+ public bool OwnsConnection { get ; init ; } = true ;
30+
2431 /// <summary>
2532 /// For EF: the DatabaseContext associated with this transaction.
2633 /// </summary>
@@ -46,7 +53,11 @@ public async ValueTask DisposeAsync()
4653 }
4754
4855 await Transaction . DisposeAsync ( ) ;
49- await Connection . DisposeAsync ( ) ;
56+
57+ if ( OwnsConnection )
58+ {
59+ await Connection . DisposeAsync ( ) ;
60+ }
5061
5162 if ( Scope is not null )
5263 {
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ public async Task<ITransactionScope> BeginTransactionAsync(
4040 {
4141 Connection = connection ,
4242 Transaction = transaction ,
43+ OwnsConnection = false ,
4344 DbContext = dbContext ,
4445 Scope = scope ,
4546 } ;
You can’t perform that action at this time.
0 commit comments