共用方式為


ObjectContext 建構函式

定義

多載

ObjectContext(EntityConnection)

使用給定的連接,初始化 ObjectContext 類別的新執行個體。 在建構期間,系統會從 EntityConnection 物件中擷取中繼資料工作空間。

ObjectContext(String)

使用給定的連接字串和預設實體容器名稱,初始化 ObjectContext 類別的新執行個體。

ObjectContext(EntityConnection, Boolean)

使用指定的連接和中繼資料工作區建立 ObjectCoNtext。

ObjectContext(EntityConnection, String)

使用給定的連接和實體容器名稱,初始化 ObjectContext 類別的新執行個體。

ObjectContext(String, String)

使用給定的連接字串 (Connection String) 和實體容器 (Container) 名稱,初始化 ObjectContext 類別的新執行個體。

ObjectContext(EntityConnection)

使用給定的連接,初始化 ObjectContext 類別的新執行個體。 在建構期間,系統會從 EntityConnection 物件中擷取中繼資料工作空間。

public ObjectContext (System.Data.Entity.Core.EntityClient.EntityConnection connection);
new System.Data.Entity.Core.Objects.ObjectContext : System.Data.Entity.Core.EntityClient.EntityConnection -> System.Data.Entity.Core.Objects.ObjectContext
Public Sub New (connection As EntityConnection)

參數

connection
EntityConnection

EntityConnection,其中包含模型的參考與資料來源連接的參考。

例外狀況

連接為 Null。

連線無效或中繼資料工作區無效。

適用於

ObjectContext(String)

使用給定的連接字串和預設實體容器名稱,初始化 ObjectContext 類別的新執行個體。

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", Justification="Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")]
public ObjectContext (string connectionString);
new System.Data.Entity.Core.Objects.ObjectContext : string -> System.Data.Entity.Core.Objects.ObjectContext
Public Sub New (connectionString As String)

參數

connectionString
String

連接字串,它也會提供中繼資料資訊的存取權。

屬性

例外狀況

connectionString 是 null。

connectionString 無效或中繼資料工作區無效。

適用於

ObjectContext(EntityConnection, Boolean)

使用指定的連接和中繼資料工作區建立 ObjectCoNtext。

public ObjectContext (System.Data.Entity.Core.EntityClient.EntityConnection connection, bool contextOwnsConnection);
new System.Data.Entity.Core.Objects.ObjectContext : System.Data.Entity.Core.EntityClient.EntityConnection * bool -> System.Data.Entity.Core.Objects.ObjectContext
Public Sub New (connection As EntityConnection, contextOwnsConnection As Boolean)

參數

connection
EntityConnection

與存放區的連線

contextOwnsConnection
Boolean

如果設定為 true,則處置內容時也會處置此連接,否則呼叫端必須處置此連接。

適用於

ObjectContext(EntityConnection, String)

使用給定的連接和實體容器名稱,初始化 ObjectContext 類別的新執行個體。

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification="Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
protected ObjectContext (System.Data.Entity.Core.EntityClient.EntityConnection connection, string defaultContainerName);
new System.Data.Entity.Core.Objects.ObjectContext : System.Data.Entity.Core.EntityClient.EntityConnection * string -> System.Data.Entity.Core.Objects.ObjectContext
Protected Sub New (connection As EntityConnection, defaultContainerName As String)

參數

connection
EntityConnection

EntityConnection,其中包含模型的參考與資料來源連接的參考。

defaultContainerName
String

預設實體容器的名稱。 當您透過這個方法設定 defaultContainerName 時,此屬性會變成唯讀的。

屬性

例外狀況

連接為 Null。

連線 、defaultContainerName 或中繼資料工作區無效。

適用於

ObjectContext(String, String)

使用給定的連接字串 (Connection String) 和實體容器 (Container) 名稱,初始化 ObjectContext 類別的新執行個體。

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification="Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
protected ObjectContext (string connectionString, string defaultContainerName);
new System.Data.Entity.Core.Objects.ObjectContext : string * string -> System.Data.Entity.Core.Objects.ObjectContext
Protected Sub New (connectionString As String, defaultContainerName As String)

參數

connectionString
String

連接字串,它也會提供中繼資料資訊的存取權。

defaultContainerName
String

預設實體容器的名稱。 當您透過這個方法設定 defaultContainerName 時,此屬性會變成唯讀的。

屬性

例外狀況

connectionString 是 null。

connectionString 、defaultContainerName 或中繼資料工作區無效。

適用於