ObjectContext.CreateObjectSet Method

 

Creates an ObjectSet based on the EntitySet that is defined for TEntity.

Namespace:   System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

NameDescription
System_CAPS_pubmethodCreateObjectSet<TEntity>()

Creates a new ObjectSet<TEntity> instance that is used to query, add, modify, and delete objects of the specified entity type.

System_CAPS_pubmethodCreateObjectSet<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.

public virtual ObjectSet<TEntity> CreateObjectSet<TEntity>()
where TEntity : class

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 .

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.