DbCommandInterceptor.ScalarExecutedAsync 方法

定义

在 EF 调用 后立即调用 ExecuteScalarAsync()

如果侦听器在 中 ScalarExecutingAsync(DbCommand, CommandEventData, InterceptionResult<Object>, CancellationToken)禁止执行命令,则仍会调用此方法。 在本例中, result 是 返回 ScalarExecutingAsync(DbCommand, CommandEventData, InterceptionResult<Object>, CancellationToken)的结果。

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

参数

command
DbCommand

命令。

eventData
CommandExecutedEventData

有关命令和执行的上下文信息。

result
Object

调用 ExecuteScalarAsync()的结果。 此值通常用作此方法实现的返回值。

cancellationToken
CancellationToken

等待 CancellationToken 任务完成时要观察的 。

返回

提供 Task EF 将使用的结果的 。 对于未尝试更改结果的任何侦听器,此方法的正常实现是返回 result 传入的值,通常使用 FromResult<TResult>(TResult)

实现

例外

适用于