ObjectContext.CreateObjectSet Method
Creates an ObjectSet based on the EntitySet that is defined for TEntity.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() | CreateObjectSet<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) | 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. |
ObjectContext.CreateObjectSet<TEntity> Method ()
Creates a new ObjectSet<TEntity> instance that is used to query, add, modify, and delete objects of the specified entity type.
Return Value
Type: System.Data.Entity.Core.Objects.ObjectSet<TEntity>The new ObjectSet<TEntity> instance.
Type Parameters
- TEntity
Entity type of the requested ObjectSet<TEntity>.
Exception | Condition |
---|---|
InvalidOperationException | The DefaultContainerName property is not set on the ObjectContext or the specified type belongs to more than one entity set. |
ObjectContext.CreateObjectSet<TEntity> Method (String)
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 virtual ObjectSet<TEntity> CreateObjectSet<TEntity>( string entitySetName ) where TEntity : class
Parameters
- entitySetName
-
Type:
System.String
Name of the entity set for the returned ObjectSet<TEntity>. The string must be qualified by the default container name if the DefaultContainerName property is not set on the ObjectContext .
Return Value
Type: System.Data.Entity.Core.Objects.ObjectSet<TEntity>The new ObjectSet<TEntity> instance.
Type Parameters
- TEntity
Entity type of the requested ObjectSet<TEntity>.
Exception | Condition |
---|---|
InvalidOperationException | The EntitySet from entitySetName does not match the EntitySet of the object EntityKey or 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. |