Compartir a través de


DbCommandInterceptor.ScalarExecutingAsync Método

Definición

Se llama justo antes de que EF intente llamar ExecuteScalarAsync()a .

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);
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);
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>>
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>>
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))
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))

Parámetros

command
DbCommand

El comando.

eventData
CommandEventData

Información contextual sobre el comando y la ejecución.

result
InterceptionResult<Object>

Representa el resultado actual si existe uno. Este valor se establecerá HasResulttrue en si algún interceptor anterior suprimió la ejecución mediante una llamada a SuppressWithResult(TResult). Este valor se usa normalmente como valor devuelto para la implementación de este método.

cancellationToken
CancellationToken

que CancellationToken se va a observar mientras espera a que se complete la tarea.

Devoluciones

Si HasResult es false, EF continuará de la forma normal. Si HasResult es true, EF suprimirá la operación que estaba a punto de realizar y usar Result en su lugar. Una implementación normal de este método para cualquier interceptor que no intente cambiar el resultado es devolver el result valor pasado, a menudo usando FromResult<TResult>(TResult)

Implementaciones

Excepciones

Se aplica a