通过


ObjectContext.CreateObject<T> 方法

定义

创建并返回所请求类型的实例。

public:
generic <typename T>
 where T : class T CreateObject();
public T CreateObject<T>() where T : class;
member this.CreateObject : unit -> 'T (requires 'T : null)
Public Function CreateObject(Of T As Class) () As T

类型参数

T

要返回的对象的类型。

返回

T

请求类型的 T实例,或可用于 T 实体框架的派生类型的实例。 返回的对象是请求类型的实例,或者是派生类型的实例,该实例使请求的类型能够与 Entity Framework 一起使用。

注解

该方法 CreateObject 与 POCO 自定义数据类一起使用,以确保返回的对象可由 Entity Framework 正确管理。

适用于