Sdílet prostřednictvím


ISaveChangesInterceptor.SavingChangesAsync Metoda

Definice

Volána na začátku .DbContext.SaveChangesAsync

public System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>> SavingChangesAsync (Microsoft.EntityFrameworkCore.Diagnostics.DbContextEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> result, System.Threading.CancellationToken cancellationToken = default);
public virtual System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>> SavingChangesAsync (Microsoft.EntityFrameworkCore.Diagnostics.DbContextEventData eventData, Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> result, System.Threading.CancellationToken cancellationToken = default);
abstract member SavingChangesAsync : Microsoft.EntityFrameworkCore.Diagnostics.DbContextEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>>
abstract member SavingChangesAsync : Microsoft.EntityFrameworkCore.Diagnostics.DbContextEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>>
override this.SavingChangesAsync : Microsoft.EntityFrameworkCore.Diagnostics.DbContextEventData * Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int> * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<Microsoft.EntityFrameworkCore.Diagnostics.InterceptionResult<int>>
Public Function SavingChangesAsync (eventData As DbContextEventData, result As InterceptionResult(Of Integer), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of InterceptionResult(Of Integer))
Public Overridable Function SavingChangesAsync (eventData As DbContextEventData, result As InterceptionResult(Of Integer), Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of InterceptionResult(Of Integer))

Parametry

eventData
DbContextEventData

Kontextové informace o použitém objektu DbContext

result
InterceptionResult<Int32>

Představuje aktuální výsledek, pokud existuje. Tato hodnota bude nastavená HasResult na , true pokud některý předchozí zachytávací modul potlačil spuštění voláním SuppressWithResult(TResult)metody . Tato hodnota se obvykle používá jako návratová hodnota pro implementaci této metody.

cancellationToken
CancellationToken

K CancellationToken pozorování při čekání na dokončení úlohy.

Návraty

Pokud HasResult je hodnota false, ef bude pokračovat jako obvykle. Pokud HasResult je hodnota true, EF potlačí operaci, kterou se chysl provést, a místo toho použije Result . Implementace této metody pro jakýkoli zachytávací objekt, který se nepokouší změnit výsledek, je vrátit result hodnotu předanou v.

Výjimky

Platí pro