Bagikan melalui


DbCommandInterceptor.ReaderExecutingAsync Metode

Definisi

Dipanggil tepat sebelum EF berniat untuk memanggil ExecuteReaderAsync().

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

Parameter

command
DbCommand

Perintah.

eventData
CommandEventData

Informasi kontekstual tentang perintah dan eksekusi.

result
InterceptionResult<DbDataReader>

Mewakili hasil saat ini jika ada. Nilai ini akan diatur HasResult ke true jika beberapa pencegat sebelumnya menekan eksekusi dengan memanggil SuppressWithResult(TResult). Nilai ini biasanya digunakan sebagai nilai pengembalian untuk implementasi metode ini.

cancellationToken
CancellationToken

A CancellationToken untuk mengamati sambil menunggu tugas selesai.

Mengembalikan

Jika HasResult false, EF akan berlanjut seperti biasa. Jika HasResult benar, maka EF akan menekan operasi yang akan dilakukan dan digunakan Result sebagai gantinya. Implementasi normal dari metode ini untuk setiap pencegat yang tidak mencoba mengubah hasilnya adalah mengembalikan nilai yang result diteruskan, sering menggunakan FromResult<TResult>(TResult)

Penerapan

Pengecualian

Berlaku untuk