Class TransactionScope
Wraps a MySqlConnector.MySqlTransaction with an async-disposable pattern. When disposed without an explicit CommitAsync(CancellationToken) or RollbackAsync(CancellationToken) call, the transaction is automatically rolled back.
public sealed class TransactionScope : IAsyncDisposable
- Inheritance
-
TransactionScope
- Implements
- Inherited Members
Methods
CommitAsync(CancellationToken)
Commits the transaction.
public Task CommitAsync(CancellationToken ct = default)
Parameters
Returns
Exceptions
- InvalidOperationException
Thrown if already committed or rolled back.
DisposeAsync()
Disposes the transaction. Automatically rolls back if not already committed/rolled back.
public ValueTask DisposeAsync()
Returns
RollbackAsync(CancellationToken)
Rolls back the transaction explicitly.
public Task RollbackAsync(CancellationToken ct = default)
Parameters
Returns
Exceptions
- InvalidOperationException
Thrown if already committed or rolled back.