DbCompiledModel.CreateObjectContext<TContext>(DbConnection) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
创建 ObjectContext 的实例或派生自 ObjectContext 的类。 请注意,可使用适当的 DbContext 构造函数来改为创建 DbContext 的实例。 如果使用派生的 ObjectContext,则它必须具有带单个 EntityConnection 参数的公共构造函数。 传递的连接由创建的 ObjectContext 使用,但不属于上下文。 在释放上下文后,调用方必须释放连接。
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
上下文。
- 属性