Bagikan melalui


IDbCommandInterceptor.CommandCreating Metode

Definisi

Dipanggil tepat sebelum EF berniat untuk memanggil CreateCommand().

public Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand> CommandCreating (Microsoft.EntityFrameworkCore.Diagnostics.CommandCorrelatedEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand> result);
public virtual Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand> CommandCreating (Microsoft.EntityFrameworkCore.Diagnostics.CommandCorrelatedEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand> result);
abstract member CommandCreating : Microsoft.EntityFrameworkCore.Diagnostics.CommandCorrelatedEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand> -> Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand>
abstract member CommandCreating : Microsoft.EntityFrameworkCore.Diagnostics.CommandCorrelatedEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand> -> Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand>
override this.CommandCreating : Microsoft.EntityFrameworkCore.Diagnostics.CommandCorrelatedEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand> -> Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<System.Data.Common.DbCommand>
Public Function CommandCreating (eventData As CommandCorrelatedEventData, result As InterceptionResult(Of DbCommand)) As InterceptionResult(Of DbCommand)
Public Overridable Function CommandCreating (eventData As CommandCorrelatedEventData, result As InterceptionResult(Of DbCommand)) As InterceptionResult(Of DbCommand)

Parameter

eventData
CommandCorrelatedEventData

Informasi kontekstual tentang perintah dan eksekusi.

result
InterceptionResult<DbCommand>

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.

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 metode ini untuk setiap pencegat yang tidak mencoba mengubah hasilnya adalah mengembalikan nilai yang result diteruskan.

Berlaku untuk