EntityFrameworkQueryableExtensions.AsTracking Method

Definition

Overloads

AsTracking<TEntity>(IQueryable<TEntity>)

Returns a new query where the change tracker will keep track of changes for all entities that are returned. Any modification to the entity instances will be detected and persisted to the database during SaveChanges().

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

AsTracking<TEntity>(IQueryable<TEntity>, QueryTrackingBehavior)

Returns a new query where the change tracker will either keep track of changes or not for all entities that are returned, depending on the value of the 'track' parameter. When tracking, Any modification to the entity instances will be detected and persisted to the database during SaveChanges(). When not tracking, 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().

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

AsTracking<TEntity>(IQueryable<TEntity>)

Returns a new query where the change tracker will keep track of changes for all entities that are returned. Any modification to the entity instances will be detected and persisted to the database during SaveChanges().

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

public static System.Linq.IQueryable<TEntity> AsTracking<TEntity> (this System.Linq.IQueryable<TEntity> source) where TEntity : class;
static member AsTracking : System.Linq.IQueryable<'Entity (requires 'Entity : null)> -> System.Linq.IQueryable<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function AsTracking(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

AsTracking<TEntity>(IQueryable<TEntity>, QueryTrackingBehavior)

Returns a new query where the change tracker will either keep track of changes or not for all entities that are returned, depending on the value of the 'track' parameter. When tracking, Any modification to the entity instances will be detected and persisted to the database during SaveChanges(). When not tracking, 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().

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

public static System.Linq.IQueryable<TEntity> AsTracking<TEntity> (this System.Linq.IQueryable<TEntity> source, Microsoft.EntityFrameworkCore.QueryTrackingBehavior track) where TEntity : class;
static member AsTracking : System.Linq.IQueryable<'Entity (requires 'Entity : null)> * Microsoft.EntityFrameworkCore.QueryTrackingBehavior -> System.Linq.IQueryable<'Entity (requires 'Entity : null)> (requires 'Entity : null)
<Extension()>
Public Function AsTracking(Of TEntity As Class) (source As IQueryable(Of TEntity), track As QueryTrackingBehavior) As IQueryable(Of TEntity)

Type Parameters

TEntity

The type of entity being queried.

Parameters

source
IQueryable<TEntity>

The source query.

track
QueryTrackingBehavior

Indicates whether the query will track results or not.

Returns

Applies to