RelationalDatabaseFacadeExtensions.UseTransactionAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
UseTransactionAsync(DatabaseFacade, DbTransaction, CancellationToken) |
Sets the DbTransaction to be used by database operations on the DbContext. |
UseTransactionAsync(DatabaseFacade, DbTransaction, Guid, CancellationToken) |
Sets the DbTransaction to be used by database operations on the DbContext. |
UseTransactionAsync(DatabaseFacade, DbTransaction, CancellationToken)
Sets the DbTransaction to be used by database operations on the DbContext.
public static System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction> UseTransactionAsync (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, System.Data.Common.DbTransaction transaction, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction?> UseTransactionAsync (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, System.Data.Common.DbTransaction? transaction, System.Threading.CancellationToken cancellationToken = default);
static member UseTransactionAsync : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade * System.Data.Common.DbTransaction * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction>
<Extension()>
Public Function UseTransactionAsync (databaseFacade As DatabaseFacade, transaction As DbTransaction, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IDbContextTransaction)
Parameters
- databaseFacade
- DatabaseFacade
The DatabaseFacade for the context.
- transaction
- DbTransaction
The DbTransaction to use.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A Task containing the IDbContextTransaction for the given transaction.
Exceptions
If the CancellationToken is canceled.
Remarks
See Transactions in EF Core for more information and examples.
Applies to
UseTransactionAsync(DatabaseFacade, DbTransaction, Guid, CancellationToken)
Sets the DbTransaction to be used by database operations on the DbContext.
public static System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction> UseTransactionAsync (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, System.Data.Common.DbTransaction transaction, Guid transactionId, System.Threading.CancellationToken cancellationToken = default);
public static System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction?> UseTransactionAsync (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, System.Data.Common.DbTransaction? transaction, Guid transactionId, System.Threading.CancellationToken cancellationToken = default);
static member UseTransactionAsync : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade * System.Data.Common.DbTransaction * Guid * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction>
<Extension()>
Public Function UseTransactionAsync (databaseFacade As DatabaseFacade, transaction As DbTransaction, transactionId As Guid, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IDbContextTransaction)
Parameters
- databaseFacade
- DatabaseFacade
The DatabaseFacade for the context.
- transaction
- DbTransaction
The DbTransaction to use.
- transactionId
- Guid
The unique identifier for the transaction.
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A Task containing the IDbContextTransaction for the given transaction.
Exceptions
If the CancellationToken is canceled.
Remarks
See Transactions in EF Core for more information and examples.
Applies to
Entity Framework