ObjectSet<TEntity>.CreateObject<T> 方法

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

创建指定类型的实例。

命名空间:  System.Data.Entity.Core.Objects
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
Public Function CreateObject(Of T As {Class, TEntity}) As T
用法
Dim instance As ObjectSet 
Dim returnValue As T

returnValue = instance.CreateObject()
public T CreateObject<T>()
where T : class, TEntity
public:
generic<typename T>
where T : ref class, TEntity
T CreateObject()
member CreateObject : unit -> 'T  when 'T : not struct and 'TEntity
JScript does not support generic types and methods.

类型参数

  • T
    要返回的对象的类型。

返回值

类型:T
所请求类型 T 的实例,或与类型 T 对应的代理类型的实例。

请参阅

参考

ObjectSet<TEntity> 类

CreateObject 重载

System.Data.Entity.Core.Objects 命名空间