Επεξεργασία

Κοινή χρήση μέσω


ObjectContext.CreateObjectSet Method

Definition

Overloads

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.

CreateObjectSet<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)

Type Parameters

TEntity

Entity type of the requested ObjectSet<TEntity>.

Returns

The new ObjectSet<TEntity> instance.

Exceptions

The DefaultContainerName property is not set on the ObjectContext.

-or-

The specified type belongs to more than one entity set.

Applies to

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.

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)

Type Parameters

TEntity

Entity type of the requested ObjectSet<TEntity>.

Parameters

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

Returns

The new ObjectSet<TEntity> instance.

Exceptions

The EntitySet from entitySetName does not match the EntitySet of the object's 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.

Applies to