ChangeTracker.TrackGraph Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
TrackGraph(Object, Action<EntityEntryGraphNode>) |
Begins tracking an entity and any entities that are reachable by traversing its navigation properties.
Traversal is recursive so the navigation properties of any discovered entities will also be scanned.
The specified |
TrackGraph<TState>(Object, TState, Func<EntityEntryGraphNode<TState>,Boolean>) |
Begins tracking an entity and any entities that are reachable by traversing its navigation properties.
Traversal is recursive so the navigation properties of any discovered entities will also be scanned.
The specified |
TrackGraph<TState>(Object, TState, Func<EntityEntryGraphNode,TState,Boolean>) |
Begins tracking an entity and any entities that are reachable by traversing it's navigation properties.
Traversal is recursive so the navigation properties of any discovered entities will also be scanned.
The specified This method is designed for use in disconnected scenarios where entities are retrieved using one instance of the context and then changes are saved using a different instance of the context. An example of this is a web service where one service call retrieves entities from the database and another service call persists any changes to the entities. Each service call uses a new instance of the context that is disposed when the call is complete. Typically traversal of the graph should stop whenever an already tracked entity is encountered or when an entity is reached that should not be tracked. For this typical behavior, use the TrackGraph(Object, Action<EntityEntryGraphNode>) overload. This overload, on the other hand, allows the callback to decide when traversal will end, but the onus is then on the caller to ensure that traversal will not enter an infinite loop. |
TrackGraph(Object, Action<EntityEntryGraphNode>)
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
Begins tracking an entity and any entities that are reachable by traversing its navigation properties.
Traversal is recursive so the navigation properties of any discovered entities will also be scanned.
The specified callback
is called for each discovered entity and must set the
State that each entity should be tracked in. If no state is set, the entity
remains untracked.
public virtual void TrackGraph (object rootEntity, Action<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode> callback);
abstract member TrackGraph : obj * Action<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode> -> unit
override this.TrackGraph : obj * Action<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode> -> unit
Public Overridable Sub TrackGraph (rootEntity As Object, callback As Action(Of EntityEntryGraphNode))
Parameters
- rootEntity
- Object
The entity to begin traversal from.
- callback
- Action<EntityEntryGraphNode>
An action to configure the change tracking information for each entity. For the entity to begin being tracked, the State must be set.
Remarks
This method is designed for use in disconnected scenarios where entities are retrieved using one instance of the context and then changes are saved using a different instance of the context. An example of this is a web service where one service call retrieves entities from the database and another service call persists any changes to the entities. Each service call uses a new instance of the context that is disposed when the call is complete.
If an entity is discovered that is already tracked by the context, that entity is not processed (and its navigation properties are not traversed).
See EF Core change tracking for more information and examples.
Applies to
TrackGraph<TState>(Object, TState, Func<EntityEntryGraphNode<TState>,Boolean>)
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
Begins tracking an entity and any entities that are reachable by traversing its navigation properties.
Traversal is recursive so the navigation properties of any discovered entities will also be scanned.
The specified callback
is called for each discovered entity and must set the
State that each entity should be tracked in. If no state is set, the entity
remains untracked.
public virtual void TrackGraph<TState> (object rootEntity, TState state, Func<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode<TState>,bool> callback);
public virtual void TrackGraph<TState> (object rootEntity, TState? state, Func<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode<TState>,bool> callback);
abstract member TrackGraph : obj * 'State * Func<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode<'State>, bool> -> unit
override this.TrackGraph : obj * 'State * Func<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode<'State>, bool> -> unit
Public Overridable Sub TrackGraph(Of TState) (rootEntity As Object, state As TState, callback As Func(Of EntityEntryGraphNode(Of TState), Boolean))
Type Parameters
- TState
The type of the state object.
Parameters
- rootEntity
- Object
The entity to begin traversal from.
- state
- TState
An arbitrary state object passed to the callback.
- callback
- Func<EntityEntryGraphNode<TState>,Boolean>
An delegate to configure the change tracking information for each entity. The second parameter to the
callback is the arbitrary state object passed above. Iteration of the graph will not continue down the graph
if the callback returns false
.
Remarks
This method is designed for use in disconnected scenarios where entities are retrieved using one instance of the context and then changes are saved using a different instance of the context. An example of this is a web service where one service call retrieves entities from the database and another service call persists any changes to the entities. Each service call uses a new instance of the context that is disposed when the call is complete.
Typically traversal of the graph should stop whenever an already tracked entity is encountered or when an entity is reached that should not be tracked. For this typical behavior, use the TrackGraph(Object, Action<EntityEntryGraphNode>) overload. This overload, on the other hand, allows the callback to decide when traversal will end, but the onus is then on the caller to ensure that traversal will not enter an infinite loop.
See EF Core change tracking for more information and examples.
Applies to
TrackGraph<TState>(Object, TState, Func<EntityEntryGraphNode,TState,Boolean>)
- Source:
- ChangeTracker.cs
- Source:
- ChangeTracker.cs
Begins tracking an entity and any entities that are reachable by traversing it's navigation properties.
Traversal is recursive so the navigation properties of any discovered entities will also be scanned.
The specified callback
is called for each discovered entity and must set the
State that each entity should be tracked in. If no state is set, the entity
remains untracked.
This method is designed for use in disconnected scenarios where entities are retrieved using one instance of the context and then changes are saved using a different instance of the context. An example of this is a web service where one service call retrieves entities from the database and another service call persists any changes to the entities. Each service call uses a new instance of the context that is disposed when the call is complete.
Typically traversal of the graph should stop whenever an already tracked entity is encountered or when an entity is reached that should not be tracked. For this typical behavior, use the TrackGraph(Object, Action<EntityEntryGraphNode>) overload. This overload, on the other hand, allows the callback to decide when traversal will end, but the onus is then on the caller to ensure that traversal will not enter an infinite loop.
public virtual void TrackGraph<TState> (object rootEntity, TState state, Func<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode,TState,bool> callback);
abstract member TrackGraph : obj * 'State * Func<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode, 'State, bool> -> unit
override this.TrackGraph : obj * 'State * Func<Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntryGraphNode, 'State, bool> -> unit
Public Overridable Sub TrackGraph(Of TState) (rootEntity As Object, state As TState, callback As Func(Of EntityEntryGraphNode, TState, Boolean))
Type Parameters
- TState
The type of the state object.
Parameters
- rootEntity
- Object
The entity to begin traversal from.
- state
- TState
An arbitrary state object passed to the callback.
- callback
- Func<EntityEntryGraphNode,TState,Boolean>
An delegate to configure the change tracking information for each entity. The second parameter to the
callback is the arbitrary state object passed above. Iteration of the graph will not continue down the graph
if the callback returns false
.
Applies to
Entity Framework