Class DataContextTransaction
- Namespace
- LinqToDB
- Assembly
- linq2db.dll
Explicit data context DataContext transaction wrapper.
public class DataContextTransaction : IDisposable, IAsyncDisposable
- Inheritance
-
DataContextTransaction
- Implements
- Extension Methods
Constructors
DataContextTransaction(DataContext)
Creates new transaction wrapper.
public DataContextTransaction(DataContext dataContext)
Parameters
dataContext
DataContextData context.
Properties
DataContext
Gets or sets transaction's data context.
public DataContext DataContext { get; set; }
Property Value
Methods
BeginTransaction()
Start new transaction with default isolation level. If underlying connection already has transaction, it will be rolled back.
public void BeginTransaction()
BeginTransaction(IsolationLevel)
Start new transaction with specified isolation level. If underlying connection already has transaction, it will be rolled back.
public void BeginTransaction(IsolationLevel level)
Parameters
level
IsolationLevelTransaction isolation level.
BeginTransactionAsync(IsolationLevel, CancellationToken)
Start new transaction asynchronously with specified isolation level. If underlying connection already has transaction, it will be rolled back.
public Task BeginTransactionAsync(IsolationLevel level, CancellationToken cancellationToken = default)
Parameters
level
IsolationLevelTransaction isolation level.
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
BeginTransactionAsync(CancellationToken)
Start new transaction asynchronously with default isolation level. If underlying connection already has transaction, it will be rolled back.
public Task BeginTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
CommitTransaction()
Commits started transaction.
public void CommitTransaction()
CommitTransactionAsync(CancellationToken)
Commits started transaction. If underlying provider doesn't support asynchronous commit, it will be performed synchronously.
public Task CommitTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task
Asynchronous operation completion task.
Dispose()
Rollbacks started transaction (if any).
public void Dispose()
RollbackTransaction()
Rollbacks started transaction.
public void RollbackTransaction()
RollbackTransactionAsync(CancellationToken)
Rollbacks started transaction asynchronously. If underlying provider doesn't support asynchronous rollback, it will be performed synchronously.
public Task RollbackTransactionAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenAsynchronous operation cancellation token.
Returns
- Task
Asynchronous operation completion task.