Język

IDbCommandInterceptor.ScalarExecutingAsync Metoda

Definicja

Wywołana tuż przed rozpoczęciem wywołania programu ExecuteScalarAsync()EF .

public virtual System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<object>> ScalarExecutingAsync(System.Data.Common.DbCommand command, Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<object> result, System.Threading.CancellationToken cancellationToken = default);
public System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<object>> ScalarExecutingAsync(System.Data.Common.DbCommand command, Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<object> result, System.Threading.CancellationToken cancellationToken = default);
public System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<object>> ScalarExecutingAsync(System.Data.Common.DbCommand command, Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<object> result, System.Threading.CancellationToken cancellationToken = default);
abstract member ScalarExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj>>
override this.ScalarExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj>>
abstract member ScalarExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj>>
abstract member ScalarExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<obj>>
Public Overridable Function ScalarExecutingAsync (command As DbCommand, eventData As CommandEventData, result As InterceptionResult(Of Object), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of InterceptionResult(Of Object))
Public Function ScalarExecutingAsync (command As DbCommand, eventData As CommandEventData, result As InterceptionResult(Of Object), Optional cancellationToken As CancellationToken = Nothing) As Task(Of InterceptionResult(Of Object))
Public Function ScalarExecutingAsync (command As DbCommand, eventData As CommandEventData, result As InterceptionResult(Of Object), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of InterceptionResult(Of Object))

Parametry

command
DbCommand

Polecenie.

eventData
CommandEventData

Kontekstowe informacje o poleceniu i wykonaniu.

result
InterceptionResult<Object>

Reprezentuje bieżący wynik, jeśli istnieje. Ta wartość będzie miała HasResult wartość , true jeśli niektóre poprzednie przechwytujące operacje pomijane przez wywołanie metody SuppressWithResult(TResult). Ta wartość jest zwykle używana jako wartość zwracana dla implementacji tej metody.

cancellationToken
CancellationToken

Element do CancellationToken obserwowania podczas oczekiwania na ukończenie zadania.

Zwraca

Jeśli HasResult wartość jest fałsz, program EF będzie kontynuowany w normalny sposób. Jeśli HasResult ma wartość true, program EF będzie pomijać operację, która miała wykonać i użyć zamiast tego Result . Implementacja tej metody dla dowolnego przechwytywania, który nie próbuje zmienić wyniku, jest zwrócenie result wartości przekazanej, często przy użyciu FromResult<TResult>(TResult)

Wyjątki

Jeśli element CancellationToken zostanie anulowany.

Dotyczy