語言

IDbConnectionInterceptor.ConnectionCreating 方法

定義

在 EF 建立 DbConnection. 之前被呼叫。 若應用程式提供連線以供使用,則不會觸發此事件。

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

參數

eventData
ConnectionCreatingEventData

關於這條連結的背景資訊。

result
InterceptionResult<DbConnection>

代表目前的結果(若存在)。 若先前攔截器透過呼叫 SuppressWithResult(TResult)抑制執行,則該值將設HasResult為 。true 此值通常用作此方法實作的回傳值。

傳回

若 HasResult , false則 EF 將照常繼續。 若 HasResult , true則 EF 會抑制它即將執行的操作並改用 Result 。 對於任何未嘗試更改結果的攔截器,使用此方法的實作應回傳 result 傳入的值。

適用於