语言

ObjectContext 构造函数

定义

重载

名称 说明
ObjectContext(EntityConnection)

使用给定的连接初始化类的新实例 ObjectContext 。 在构造过程中,元数据工作区将从 EntityConnection 对象中提取。

ObjectContext(String)

使用给定的连接字符串和默认实体容器名称初始化 ObjectContext 类的新实例。

ObjectContext(EntityConnection, Boolean)

使用给定的连接和元数据工作区创建 ObjectContext。

ObjectContext(EntityConnection, String)

使用给定的连接和实体容器名称初始化类的新实例 ObjectContext 。

ObjectContext(String, String)

使用给定连接字符串和实体容器名称初始化 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)

使用给定连接字符串和实体容器名称初始化 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 或元数据工作区无效。

适用于