Delen via


RelationalDatabaseFacadeExtensions.BeginTransactionAsync Method

Definition

Asynchronously starts a new transaction with a given IsolationLevel.

public static System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction> BeginTransactionAsync (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade, System.Data.IsolationLevel isolationLevel, System.Threading.CancellationToken cancellationToken = default);
static member BeginTransactionAsync : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade * System.Data.IsolationLevel * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction>
<Extension()>
Public Function BeginTransactionAsync (databaseFacade As DatabaseFacade, isolationLevel As IsolationLevel, Optional cancellationToken As CancellationToken = Nothing) As Task(Of IDbContextTransaction)

Parameters

databaseFacade
DatabaseFacade

The DatabaseFacade for the context.

isolationLevel
IsolationLevel

The IsolationLevel to use.

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

A task that represents the asynchronous transaction initialization. The task result contains a IDbContextTransaction that represents the started transaction.

Exceptions

Remarks

See Transactions in EF Core for more information and examples.

Applies to