Table of Contents

Class CollectionEntry<TEntity, TRelatedEntity>

Namespace
Microsoft.EntityFrameworkCore.ChangeTracking
Assembly
Microsoft.EntityFrameworkCore.dll

Provides access to change tracking and loading information for a collection navigation property that associates this entity to a collection of another entities.

public class CollectionEntry<TEntity, TRelatedEntity> : CollectionEntry, IInfrastructure<InternalEntityEntry> where TEntity : class where TRelatedEntity : class

Type Parameters

TEntity

The type of the entity the property belongs to.

TRelatedEntity

The type of the property.

Inheritance
CollectionEntry<TEntity, TRelatedEntity>
Implements
Inherited Members
Extension Methods

Remarks

Instances of this class are returned from methods when using the ChangeTracker API and it is not designed to be directly constructed in your application code.

See Accessing tracked entities in EF Core, Changing foreign keys and navigations, and Loading related entities for more information and examples.

Constructors

CollectionEntry(InternalEntityEntry, INavigationBase)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

[EntityFrameworkInternal]
public CollectionEntry(InternalEntityEntry internalEntry, INavigationBase navigationBase)

Parameters

internalEntry InternalEntityEntry
navigationBase INavigationBase

CollectionEntry(InternalEntityEntry, string)

This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.

[EntityFrameworkInternal]
public CollectionEntry(InternalEntityEntry internalEntry, string name)

Parameters

internalEntry InternalEntityEntry
name string

Properties

CurrentValue

Gets or sets the value currently assigned to this property. If the current value is set using this property, the change tracker is aware of the change and DetectChanges() is not required for the context to detect the change.

public virtual IEnumerable<TRelatedEntity>? CurrentValue { get; set; }

Property Value

IEnumerable<TRelatedEntity>

Remarks

EntityEntry

The EntityEntry<TEntity> to which this member belongs.

public virtual EntityEntry<TEntity> EntityEntry { get; }

Property Value

EntityEntry<TEntity>

An entry for the entity that owns this member.

Remarks

See Accessing tracked entities in EF Core for more information and examples.

Methods

FindEntry(object)

The EntityEntry<TEntity> of an entity this navigation targets.

public virtual EntityEntry<TRelatedEntity>? FindEntry(object entity)

Parameters

entity object

The entity to get the entry for.

Returns

EntityEntry<TRelatedEntity>

An entry for an entity that this navigation targets.

Remarks

See Accessing tracked entities in EF Core for more information and examples.

Query()

Returns the query that would be used by Load() to load entities referenced by this navigation property.

public virtual IQueryable<TRelatedEntity> Query()

Returns

IQueryable<TRelatedEntity>

Remarks

The query can be composed over using LINQ to perform filtering, counting, etc. without actually loading all entities from the database.

See Accessing tracked entities in EF Core and Loading related entities for more information and examples.