Skip to content

Commit 54d2190

Browse files
authored
fix(Dispatcher): fix transaction rollback (#135)
1 parent f60ff9b commit 54d2190

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Data/Masa.Contrib.Data.UoW.EF/UnitOfWork.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,10 @@ public async Task CommitAsync(CancellationToken cancellationToken = default)
6666
public async Task RollbackAsync(CancellationToken cancellationToken = default)
6767
{
6868
if (!UseTransaction || !TransactionHasBegun)
69-
throw new NotSupportedException("Transactions are not opened and rollback is not supported");
69+
return;
7070

71-
await Context.Database.RollbackTransactionAsync(cancellationToken);
71+
if (TransactionHasBegun)
72+
await Context.Database.RollbackTransactionAsync(cancellationToken);
7273
}
7374

7475
public Task AddDomainEventAsync<TDomainEvent>(TDomainEvent @event) where TDomainEvent : class

0 commit comments

Comments
 (0)