Compartilhar via


IDbTransactionInterceptor.TransactionStartingAsync Método

Definição

Chamado pouco antes do EF pretende chamar BeginTransactionAsync(IsolationLevel, CancellationToken).

public System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction>> TransactionStartingAsync (System.Data.Common.DbConnection connection, Microsoft.EntityFrameworkCore.Diagnostics.TransactionStartingEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction> result, System.Threading.CancellationToken cancellationToken = default);
public System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction>> TransactionStartingAsync (System.Data.Common.DbConnection connection, Microsoft.EntityFrameworkCore.Diagnostics.TransactionStartingEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction> result, System.Threading.CancellationToken cancellationToken = default);
public virtual System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction>> TransactionStartingAsync (System.Data.Common.DbConnection connection, Microsoft.EntityFrameworkCore.Diagnostics.TransactionStartingEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction> result, System.Threading.CancellationToken cancellationToken = default);
abstract member TransactionStartingAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionStartingEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction>>
abstract member TransactionStartingAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionStartingEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction>>
abstract member TransactionStartingAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionStartingEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction>>
override this.TransactionStartingAsync : System.Data.Common.DbConnection * Microsoft.EntityFrameworkCore.Diagnostics.TransactionStartingEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbTransaction>>
Public Function TransactionStartingAsync (connection As DbConnection, eventData As TransactionStartingEventData, result As InterceptionResult(Of DbTransaction), Optional cancellationToken As CancellationToken = Nothing) As Task(Of InterceptionResult(Of DbTransaction))
Public Function TransactionStartingAsync (connection As DbConnection, eventData As TransactionStartingEventData, result As InterceptionResult(Of DbTransaction), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of InterceptionResult(Of DbTransaction))
Public Overridable Function TransactionStartingAsync (connection As DbConnection, eventData As TransactionStartingEventData, result As InterceptionResult(Of DbTransaction), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of InterceptionResult(Of DbTransaction))

Parâmetros

connection
DbConnection

A conexão.

eventData
TransactionStartingEventData

Informações contextuais sobre conexão e transação.

result
InterceptionResult<DbTransaction>

Representa o resultado atual se houver um. Esse valor terá HasResult definido como true se algum interceptador anterior suprimiu a execução chamando SuppressWithResult(TResult). Esse valor normalmente é usado como o valor retornado para a implementação desse método.

cancellationToken
CancellationToken

Um CancellationToken a ser observado enquanto aguarda a conclusão da tarefa.

Retornos

Se HasResult for false, o EF continuará normalmente. Se HasResult for true, o EF suprimirá a operação que estava prestes a executar e usar Result . Uma implementação desse método para qualquer interceptador que não esteja tentando alterar o resultado é retornar o result valor passado, muitas vezes usando FromResult<TResult>(TResult)

Exceções

Se o padrão CancellationToken for cancelado.

Aplica-se a