DbCommandInterceptor.NonQueryExecutingAsync Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Dipanggil tepat sebelum EF berniat untuk memanggil ExecuteNonQueryAsync().
public virtual System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>> NonQueryExecutingAsync (System.Data.Common.DbCommand command, Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> result, System.Threading.CancellationToken cancellationToken = default);
public virtual System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>> NonQueryExecutingAsync (System.Data.Common.DbCommand command, Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> result, System.Threading.CancellationToken cancellationToken = default);
abstract member NonQueryExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>>
override this.NonQueryExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>>
abstract member NonQueryExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>>
override this.NonQueryExecutingAsync : System.Data.Common.DbCommand * Microsoft.EntityFrameworkCore.Diagnostics.CommandEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>>
Public Overridable Function NonQueryExecutingAsync (command As DbCommand, eventData As CommandEventData, result As InterceptionResult(Of Integer), Optional cancellationToken As CancellationToken = Nothing) As Task(Of InterceptionResult(Of Integer))
Public Overridable Function NonQueryExecutingAsync (command As DbCommand, eventData As CommandEventData, result As InterceptionResult(Of Integer), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of InterceptionResult(Of Integer))
Parameter
- command
- DbCommand
Perintah.
- eventData
- CommandEventData
Informasi kontekstual tentang perintah dan eksekusi.
- result
- InterceptionResult<Int32>
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 kali menggunakan FromResult<TResult>(TResult)
Penerapan
Pengecualian
CancellationToken Jika dibatalkan.
Berlaku untuk
Entity Framework