Table of Contents

Class NavigationEntry

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

Provides access to change tracking and loading information for a navigation property that associates this entity to one or more other entities.

public abstract class NavigationEntry : MemberEntry, IInfrastructure<InternalEntityEntry>
Inheritance
NavigationEntry
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 and Loading related entities for more information and examples.

Constructors

NavigationEntry(InternalEntityEntry, INavigationBase, bool)

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 NavigationEntry(InternalEntityEntry internalEntry, INavigationBase navigationBase, bool collection)

Parameters

internalEntry InternalEntityEntry
navigationBase INavigationBase
collection bool

NavigationEntry(InternalEntityEntry, string, bool)

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 NavigationEntry(InternalEntityEntry internalEntry, string name, bool collection)

Parameters

internalEntry InternalEntityEntry
name string
collection bool

Properties

IsLoaded

Gets or sets a value indicating whether the entity or entities referenced by this navigation property are known to be loaded.

public virtual bool IsLoaded { get; set; }

Property Value

bool

true if all the related entities are loaded or the IsLoaded has been explicitly set to true.

Remarks

Loading entities from the database using Include<TEntity, TProperty>(IQueryable<TEntity>, Expression<Func<TEntity, TProperty>>) or ThenInclude<TEntity, TPreviousProperty, TProperty>(IIncludableQueryable<TEntity, IEnumerable<TPreviousProperty>>, Expression<Func<TPreviousProperty, TProperty>>) , Load(), or LoadAsync(CancellationToken) will set this flag. Subsequent calls to Load() or LoadAsync(CancellationToken) will then be a no-op.

It is possible for IsLoaded to be false even if all related entities are loaded. This is because, depending on how entities are loaded, it is not always possible to know for sure that all entities in a related collection have been loaded. In such cases, calling Load() or LoadAsync(CancellationToken) will ensure all related entities are loaded and will set this flag to true.

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

Metadata

Gets the metadata that describes the facets of this property and how it maps to the database.

public virtual INavigationBase Metadata { get; }

Property Value

INavigationBase

Methods

Load()

Loads the entities referenced by this navigation property, unless IsLoaded is already set to true.

public abstract void Load()

Remarks

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

Load(LoadOptions)

Loads the entities referenced by this navigation property, unless IsLoaded is already set to true.

public abstract void Load(LoadOptions options)

Parameters

options LoadOptions

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

Loads entities referenced by this navigation property, unless IsLoaded is already set to true.

public abstract Task LoadAsync(LoadOptions options, CancellationToken cancellationToken = default)

Parameters

options LoadOptions

Options to control the way related entities are loaded.

cancellationToken CancellationToken

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

Loads entities referenced by this navigation property, unless IsLoaded is already set to true.

public abstract Task LoadAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A 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 abstract IQueryable Query()

Returns

IQueryable

The query to load related entities.

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.