DbCompiledModel.CreateObjectContext<TContext>(DbConnection) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
建立一個 ObjectContext 實例或由 ObjectContext 衍生的類別。 請注意,也可以使用適當的 DbContext 建構子來建立 DbContext 實例。 若使用衍生 ObjectContext,則必須有一個具有單一 EntityConnection 參數的公開建構子。 所傳遞的連線由所建立的 ObjectContext 使用,但不屬於 context 所有。 呼叫者必須在上下文被處理後處理該連線。
public TContext CreateObjectContext<TContext>(System.Data.Common.DbConnection existingConnection) where TContext : System.Data.Entity.Core.Objects.ObjectContext;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
public TContext CreateObjectContext<TContext>(System.Data.Common.DbConnection existingConnection) where TContext : System.Data.Entity.Core.Objects.ObjectContext;
member this.CreateObjectContext : System.Data.Common.DbConnection -> 'Context (requires 'Context :> System.Data.Entity.Core.Objects.ObjectContext)
Public Function CreateObjectContext(Of TContext As ObjectContext) (existingConnection As DbConnection) As TContext
類型參數
- TContext
創造的脈絡類型。
參數
- existingConnection
- DbConnection
一個現有的資料庫連線,供上下文使用。
傳回
TContext
上下文。
- 屬性