ObjectContext.CreateObjectSet 方法
定义
重载
| CreateObjectSet<TEntity>() |
创建新的 ObjectSet<TEntity> 实例,该实例用于查询、添加、修改和删除指定实体类型的对象。Creates a new ObjectSet<TEntity> instance that is used to query, add, modify, and delete objects of the specified entity type. |
| CreateObjectSet<TEntity>(String) |
创建新的 ObjectSet<TEntity> 实例,该实例用于查询、添加、修改和删除具有指定类型和指定实体集名称的对象。Creates a new ObjectSet<TEntity> instance that is used to query, add, modify, and delete objects of the specified type and with the specified entity set name. |
CreateObjectSet<TEntity>()
创建新的 ObjectSet<TEntity> 实例,该实例用于查询、添加、修改和删除指定实体类型的对象。Creates a new ObjectSet<TEntity> instance that is used to query, add, modify, and delete objects of the specified entity type.
public:
generic <typename TEntity>
where TEntity : class System::Data::Objects::ObjectSet<TEntity> ^ CreateObjectSet();
public System.Data.Objects.ObjectSet<TEntity> CreateObjectSet<TEntity> () where TEntity : class;
member this.CreateObjectSet : unit -> System.Data.Objects.ObjectSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Function CreateObjectSet(Of TEntity As Class) () As ObjectSet(Of TEntity)
类型参数
- TEntity
请求的 ObjectSet<TEntity> 的实体类型。Entity type of the requested ObjectSet<TEntity>.
返回
新的 ObjectSet<TEntity> 实例。The new ObjectSet<TEntity> instance.
例外
DefaultContainerName 属性未在 ObjectContext 上设置。The DefaultContainerName property is not set on the ObjectContext.
- 或 --or-
指定类型属于多个实体集。The specified type belongs to more than one entity set.
适用于
CreateObjectSet<TEntity>(String)
创建新的 ObjectSet<TEntity> 实例,该实例用于查询、添加、修改和删除具有指定类型和指定实体集名称的对象。Creates a new ObjectSet<TEntity> instance that is used to query, add, modify, and delete objects of the specified type and with the specified entity set name.
public:
generic <typename TEntity>
where TEntity : class System::Data::Objects::ObjectSet<TEntity> ^ CreateObjectSet(System::String ^ entitySetName);
public System.Data.Objects.ObjectSet<TEntity> CreateObjectSet<TEntity> (string entitySetName) where TEntity : class;
member this.CreateObjectSet : string -> System.Data.Objects.ObjectSet<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Function CreateObjectSet(Of TEntity As Class) (entitySetName As String) As ObjectSet(Of TEntity)
类型参数
- TEntity
请求的 ObjectSet<TEntity> 的实体类型。Entity type of the requested ObjectSet<TEntity>.
参数
- entitySetName
- String
返回的 ObjectSet<TEntity> 的实体集的名称。Name of the entity set for the returned ObjectSet<TEntity>. 如果未在 DefaultContainerName 上设置 ObjectContext 属性,则字符串必须由默认容器名称进行限定。The string must be qualified by the default container name if the DefaultContainerName property is not set on the ObjectContext.
返回
新的 ObjectSet<TEntity> 实例。The new ObjectSet<TEntity> instance.
例外
来自 entitySetName 的 EntitySet 与对象的 EntityKey 的 EntitySet 不匹配。The EntitySet from entitySetName does not match the EntitySet of the object's EntityKey.
- 或 --or-
在 DefaultContainerName 上没有设置 ObjectContext 属性,且名称未限定为 entitySetName 参数。The DefaultContainerName property is not set on the ObjectContext and the name is not qualified as part of the entitySetName parameter.
- 或 --or-
指定类型属于多个实体集。The specified type belongs to more than one entity set.