Udostępnij za pośrednictwem


IDbConnectionInterceptor.ConnectionOpeningAsync Metoda

Definicja

Wywoływana tuż przed tym, jak ef zamierza wywołać metodę OpenAsync().

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

Parametry

connection
DbConnection

Połączenie.

eventData
ConnectionEventData

Kontekstowe informacje o połączeniu.

result
InterceptionResult

Reprezentuje bieżący wynik, jeśli istnieje. Ta wartość będzie miała IsSuppressed wartość true , jeśli jakiś poprzedni przechwytujący pominięto wykonywanie przez wywołanie metody Suppress(). Ta wartość jest zwykle używana jako wartość zwracana dla implementacji tej metody.

cancellationToken
CancellationToken

Element CancellationToken do obserwowania podczas oczekiwania na ukończenie zadania.

Zwraca

Jeśli IsSuppressed wartość to false, program EF będzie kontynuowany w normalny sposób. Jeśli IsSuppressed parametr ma truewartość , program EF pominie operację, która miała być wykonywana. Implementacja tej metody dla każdego interceptora, który nie próbuje pominąć operacji, jest zwrócenie wartości przekazanej result .

Wyjątki

Jeśli element CancellationToken zostanie anulowany.

Dotyczy