Share via


EntityCollection<TEntity> Class

Definition

Collection of entities modeling a particular EDM construct which can either be all entities of a particular type or entities participating in a particular relationship.

[System.Serializable]
public class EntityCollection<TEntity> : System.Data.Entity.Core.Objects.DataClasses.RelatedEnd, System.Collections.Generic.ICollection<TEntity>, System.Collections.Generic.IEnumerable<TEntity>, System.ComponentModel.IListSource where TEntity : class
type EntityCollection<'Entity (requires 'Entity : null)> = class
    inherit RelatedEnd
    interface ICollection<'Entity (requires 'Entity : null)>
    interface seq<'Entity (requires 'Entity : null)>
    interface IEnumerable
    interface IListSource
Public Class EntityCollection(Of TEntity)
Inherits RelatedEnd
Implements ICollection(Of TEntity), IEnumerable(Of TEntity), IListSource

Type Parameters

TEntity

The type of entities in this collection.

Inheritance
EntityCollection<TEntity>
Attributes
Implements

Constructors

EntityCollection<TEntity>()

Initializes a new instance of the EntityCollection<TEntity> class.

Properties

Count

Gets the number of objects that are contained in the collection.

IsLoaded

Gets or sets a value indicating whether the entity (for an EntityReference or all entities in the collection (for an EntityCollection<TEntity> have been loaded from the database.

(Inherited from RelatedEnd)
IsReadOnly

Gets a value that indicates whether the EntityCollection<TEntity> is read-only.

RelationshipName

Gets the name of the relationship in which this related end participates.

(Inherited from RelatedEnd)
RelationshipSet

Gets a reference to the metadata for the related end.

(Inherited from RelatedEnd)
SourceRoleName

Gets the role name at the source end of the relationship.

(Inherited from RelatedEnd)
TargetRoleName

Gets the role name at the target end of the relationship.

(Inherited from RelatedEnd)

Methods

Add(TEntity)

Adds an object to the collection.

Attach(IEnumerable<TEntity>)

Defines relationships between an object and a collection of related objects in an object context.

Attach(TEntity)

Defines a relationship between two attached objects in an object context.

Clear()

Removes all entities from the collection.

Contains(TEntity)

Determines whether a specific object exists in the collection.

CopyTo(TEntity[], Int32)

Copies all the contents of the collection to an array, starting at the specified index of the target array.

CreateSourceQuery()

Returns an object query that, when it is executed, returns the same set of objects that exists in the current collection.

GetEnumerator()

Returns an enumerator that is used to iterate through the objects in the collection.

Load()

Loads the related object or objects into the related end with the default merge option.

(Inherited from RelatedEnd)
Load(MergeOption)

Loads related objects into the collection, using the specified merge option.

LoadAsync(CancellationToken)

Asynchronously loads the related object or objects into the related end with the default merge option.

(Inherited from RelatedEnd)
LoadAsync(MergeOption, CancellationToken)

Asynchronously loads an object or objects from the related end with the specified merge option.

OnCollectionDeserialized(StreamingContext)

Used internally to deserialize entity objects.

OnDeserialized(StreamingContext)

Used internally to deserialize entity objects along with the RelationshipManager instances.

(Inherited from RelatedEnd)
OnSerializing(StreamingContext)

Used internally to serialize entity objects.

Remove(TEntity)

Removes an object from the collection and marks the relationship for deletion.

Events

AssociationChanged

Occurs when a change is made to a related end.

(Inherited from RelatedEnd)

Explicit Interface Implementations

IEnumerable.GetEnumerator()

Returns an enumerator that is used to iterate through the set of values cached by EntityCollection<TEntity> .

IListSource.ContainsListCollection

IListSource.ContainsListCollection implementation. Always returns false. This means that the IList we return is the one which contains our actual data, it is not a list of collections.

IListSource.GetList()

Returns the collection as an IList used for data binding.

IRelatedEnd.Add(IEntityWithRelationships)

Adds an entity to the related end. This method works in exactly the same way as Add(object). It is maintained for backward compatibility with previous versions of IRelatedEnd.

(Inherited from RelatedEnd)
IRelatedEnd.Add(Object)

Adds an entity to the related end. If the owner is attached to a cache then the all the connected ends are added to the object cache and their corresponding relationships are also added to the ObjectStateManager. The RelatedEnd of the relationship is also fixed.

(Inherited from RelatedEnd)
IRelatedEnd.Attach(IEntityWithRelationships)

Attaches an entity to the related end. This method works in exactly the same way as Attach(object). It is maintained for backward compatibility with previous versions of IRelatedEnd.

(Inherited from RelatedEnd)
IRelatedEnd.Attach(Object)

Attaches an entity to the related end. If the related end is already filled or partially filled, this merges the existing entities with the given entity. The given entity is not assumed to be the complete set of related entities. Owner and all entities passed in must be in Unchanged or Modified state. Deleted elements are allowed only when the state manager is already tracking the relationship instance.

(Inherited from RelatedEnd)
IRelatedEnd.CreateSourceQuery()

Returns an IEnumerable that represents the objects that belong to the related end.

(Inherited from RelatedEnd)
IRelatedEnd.Remove(IEntityWithRelationships)

Removes an entity from the related end. This method works in exactly the same way as Remove(object). It is maintained for backward compatibility with previous versions of IRelatedEnd.

(Inherited from RelatedEnd)
IRelatedEnd.Remove(Object)

Removes an entity from the related end. If owner is attached to a cache, marks relationship for deletion and if the relationship is composition also marks the entity for deletion.

(Inherited from RelatedEnd)

Applies to