Skip to content

Commit

Permalink
Don't dispose current transaction when replaced with new one.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed Sep 14, 2021
1 parent a20b5f5 commit cedcb09
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
10 changes: 0 additions & 10 deletions src/EFCore.Relational/Storage/RelationalConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,6 @@ private IDbContextTransaction CreateRelationalTransaction(DbTransaction transact
{
if (ShouldUseTransaction(transaction))
{
if (CurrentTransaction != null)
{
CurrentTransaction.Dispose();
}

Open();

transaction = Dependencies.TransactionLogger.TransactionUsed(
Expand Down Expand Up @@ -522,11 +517,6 @@ private IDbContextTransaction CreateRelationalTransaction(DbTransaction transact
{
if (ShouldUseTransaction(transaction))
{
if (CurrentTransaction != null)
{
await CurrentTransaction.DisposeAsync();
}

await OpenAsync(cancellationToken).ConfigureAwait(false);

transaction = await Dependencies.TransactionLogger.TransactionUsedAsync(
Expand Down
14 changes: 0 additions & 14 deletions test/EFCore.SqlServer.FunctionalTests/ExecutionStrategyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,13 +446,6 @@ await c.AuditContext.Database.UseTransactionAsync(
Assert.NotSame(currentTransaction, c.AuditContext.Database.CurrentTransaction);
if (currentTransaction != null)
{
Assert.True(
(bool)typeof(RelationalTransaction).GetRuntimeFields().Single(f => f.Name == "_disposed")
.GetValue(currentTransaction)!);
}
await c.AuditContext.Audits.AddAsync(new Audit(), ct);
await c.AuditContext.SaveChangesAsync(ct);
Expand Down Expand Up @@ -497,13 +490,6 @@ await c.AuditContext.Database.UseTransactionAsync(
Assert.NotSame(currentTransaction, c.AuditContext.Database.CurrentTransaction);
if (currentTransaction != null)
{
Assert.True(
(bool)typeof(RelationalTransaction).GetRuntimeFields().Single(f => f.Name == "_disposed")
.GetValue(currentTransaction)!);
}
c.AuditContext.Audits.Add(new Audit());
c.AuditContext.SaveChanges();
Expand Down

0 comments on commit cedcb09

Please sign in to comment.