Sprache

DbCommandInterceptor.ScalarExecutingAsync Methode

Definition

Wird gerade vor EF aufgerufen, um den Anruf zu tätigen ExecuteScalarAsync().

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 virtual 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);
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>>
override this.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>>
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 Overridable Function ScalarExecutingAsync (command As DbCommand, eventData As CommandEventData, result As InterceptionResult(Of Object), Optional cancellationToken As CancellationToken = Nothing) As Task(Of InterceptionResult(Of Object))

Parameter

command
DbCommand

Der Befehl.

eventData
CommandEventData

Kontextbezogene Informationen zum Befehl und zur Ausführung.

result
InterceptionResult<Object>

Stellt das aktuelle Ergebnis dar, falls vorhanden. Dieser Wert muss festgelegt true werdenHasResult, wenn ein früherer Interceptor die Ausführung durch Aufrufen SuppressWithResult(TResult)unterdrückt hat. Dieser Wert wird in der Regel als Rückgabewert für die Implementierung dieser Methode verwendet.

cancellationToken
CancellationToken

A CancellationToken , um zu beobachten, während sie auf den Abschluss der Aufgabe warten.

Gibt zurück

Ist HasResult "false", wird der EF normal fortgesetzt. Wenn HasResult "true" ist, unterdrückt EF den Vorgang, den er stattdessen ausführen und verwenden Result wollte. Eine normale Implementierung dieser Methode für jeden Interceptor, der nicht versucht, das Ergebnis zu ändern, besteht darin, den result übergebenen Wert zurückzugeben, häufig mit FromResult<TResult>(TResult)

Implementiert

Ausnahmen

Wenn der CancellationToken Vorgang abgebrochen wird.

Gilt für: