EntityFrameworkQueryableExtensions.AsNoTrackingWithIdentityResolution<TEntity>(IQueryable<TEntity>) Method

Definition

The change tracker will not track any of the entities that are returned from a LINQ query. If the entity instances are modified, this will not be detected by the change tracker and SaveChanges() will not persist those changes to the database.

Disabling change tracking is useful for read-only scenarios because it avoids the overhead of setting up change tracking for each entity instance. You should not disable change tracking if you want to manipulate entity instances and persist those changes to the database using SaveChanges().

Identity resolution will be performed to ensure that all occurrences of an entity with a given key in the result set are represented by the same entity instance.

The default tracking behavior for queries can be controlled by QueryTrackingBehavior.

public static System.Linq.IQueryable<TEntity> AsNoTrackingWithIdentityResolution<TEntity> (this System.Linq.IQueryable<TEntity> source) where TEntity : class;
static member AsNoTrackingWithIdentityResolution : System.Linq.IQueryable<'Entity (requires 'Entity : null)> -> System.Linq.IQueryable<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function AsNoTrackingWithIdentityResolution(Of TEntity As Class) (source As IQueryable(Of TEntity)) As IQueryable(Of TEntity)

Type Parameters

TEntity

The type of entity being queried.

Parameters

source
IQueryable<TEntity>

The source query.

Returns

IQueryable<TEntity>

A new query where the result set will not be tracked by the context.

Exceptions

source is null.

Applies to