Compartir a través de


IDbConnectionInterceptor.ConnectionOpeningAsync Método

Definición

Se llama justo antes de que EF intente llamar OpenAsync()a .

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)

Parámetros

connection
DbConnection

La conexión.

eventData
ConnectionEventData

Información contextual sobre la conexión.

result
InterceptionResult

Representa el resultado actual si existe uno. Este valor se establecerá IsSuppressedtrue en si algún interceptor anterior suprimió la ejecución mediante una llamada a Suppress(). Este valor se usa normalmente como valor devuelto para la implementación de este método.

cancellationToken
CancellationToken

Que CancellationToken se debe observar mientras se espera a que se complete la tarea.

Devoluciones

Si IsSuppressed es false, EF continuará como normal. Si IsSuppressed es true, EF suprimirá la operación que estaba a punto de realizar. Una implementación de este método para cualquier interceptor que no intente suprimir la operación es devolver el result valor pasado.

Excepciones

Se aplica a