Condividi tramite


DbTransactionInterceptor.TransactionStartingAsync Metodo

Definizione

Chiamato appena prima che EF intenda chiamare BeginTransactionAsync(IsolationLevel, CancellationToken).

public virtual 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 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>>
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.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>>
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 Overridable 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 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))

Parametri

connection
DbConnection

Connessione.

eventData
TransactionStartingEventData

Informazioni contestuali sulla connessione e sulla transazione.

result
InterceptionResult<DbTransaction>

Rappresenta il risultato corrente se esiste. Questo valore sarà HasResult impostato su true se un intercettatore precedente ha eliminato l'esecuzione chiamando SuppressWithResult(TResult). Questo valore viene in genere usato come valore restituito per l'implementazione di questo metodo.

cancellationToken
CancellationToken

Oggetto CancellationToken da osservare durante l'attesa del completamento dell'attività.

Restituisce

Se HasResult è false, l'EF continuerà come normale. Se HasResult è true, EF elimina l'operazione che sta per eseguire e usare Result . Una normale implementazione di questo metodo per qualsiasi intercettatore che non tenta di modificare il risultato consiste nel restituire il result valore passato, spesso usando FromResult<TResult>(TResult)

Implementazioni

Eccezioni

Si applica a