Class CollectionEntry
- 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 : NavigationEntry, IInfrastructure<InternalEntityEntry>
- Inheritance
-
CollectionEntry
- Implements
- Derived
- 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
InternalEntityEntrynavigationBase
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
InternalEntityEntryname
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? CurrentValue { get; set; }
Property Value
Remarks
See Accessing tracked entities in EF Core and Changing foreign keys and navigations for more information and examples.
IsModified
Gets or sets a value indicating whether any of foreign key property values associated with this navigation property have been modified and should be updated in the database when SaveChanges() is called.
public override bool IsModified { get; set; }
Property Value
Remarks
See Accessing tracked entities in EF Core and Changing foreign keys and navigations for more information and examples.
Methods
FindEntry(object)
The EntityEntry of an entity this navigation targets.
public virtual EntityEntry? FindEntry(object entity)
Parameters
entity
objectThe entity to get the entry for.
Returns
- EntityEntry
An entry for an entity that this navigation targets.
Remarks
See Accessing tracked entities in EF Core for more information and examples.
GetInternalTargetEntry(object)
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]
protected virtual InternalEntityEntry? GetInternalTargetEntry(object entity)
Parameters
entity
object
Returns
Load()
public override void Load()
Remarks
See Accessing tracked entities in EF Core and Loading related entities for more information and examples.
Load(LoadOptions)
public override void Load(LoadOptions options)
Parameters
options
LoadOptionsOptions to control the way related entities are loaded.
Remarks
See Accessing tracked entities in EF Core and Loading related entities for more information and examples.
LoadAsync(LoadOptions, CancellationToken)
public override Task LoadAsync(LoadOptions options, CancellationToken cancellationToken = default)
Parameters
options
LoadOptionsOptions to control the way related entities are loaded.
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- Task
A task that represents the asynchronous save operation.
Remarks
Multiple active operations on the same context instance are not supported. Use await to ensure that any asynchronous operations have completed before calling another method on this context.
See Accessing tracked entities in EF Core and Loading related entities for more information and examples.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
LoadAsync(CancellationToken)
public override Task LoadAsync(CancellationToken cancellationToken = default)
Parameters
cancellationToken
CancellationTokenA CancellationToken to observe while waiting for the task to complete.
Returns
- Task
A task that represents the asynchronous save operation.
Remarks
Multiple active operations on the same context instance are not supported. Use await to ensure that any asynchronous operations have completed before calling another method on this context.
See Accessing tracked entities in EF Core and Loading related entities for more information and examples.
Exceptions
- OperationCanceledException
If the CancellationToken is canceled.
Query()
Returns the query that would be used by Load() to load entities referenced by this navigation property.
public override IQueryable Query()
Returns
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.