共用方式為


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)

實作

例外狀況

適用於