ObjectStateManager Class
Maintains object state and identity management for entity type instances and relationship instances.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
The ObjectStateManager type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ChangeObjectState | Changes state of the ObjectStateEntry for a specific object to the specified entityState. |
![]() | ChangeRelationshipState(Object, Object, String, EntityState) | Changes the state of the relationship between two entity objects that is specified based on the two related objects and the name of the navigation property. |
![]() | ChangeRelationshipState(Object, Object, String, String, EntityState) | Changes the state of the relationship between two entity objects that is specified based on the two related objects and the properties of the relationship. |
![]() | ChangeRelationshipState<TEntity>(TEntity, Object, Expression<Func<TEntity, Object>>, EntityState) | Changes the state of the relationship between two entity objects that is specified based on the two related objects and a LINQ expression that defines the navigation property. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetObjectStateEntries | Returns a collection of ObjectStateEntry objects for objects or relationships with the given state. |
![]() | GetObjectStateEntry(EntityKey) | Returns an ObjectStateEntry for the object or relationship entry with the specified key. |
![]() | GetObjectStateEntry(Object) | Returns an ObjectStateEntry for the specified object. |
![]() | GetRelationshipManager | Returns the RelationshipManager that is used by the specified object. |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
![]() | TryGetObjectStateEntry(EntityKey, ObjectStateEntry%) | Tries to retrieve the corresponding ObjectStateEntry for the object or relationship with the specified EntityKey. |
![]() | TryGetObjectStateEntry(Object, ObjectStateEntry%) | Tries to retrieve the corresponding ObjectStateEntry for the specified Object. |
![]() | TryGetRelationshipManager | Returns the RelationshipManager that is used by the specified object. |
| Name | Description | |
|---|---|---|
![]() | ObjectStateManagerChanged | Occurs when entities are added to or removed from the state manager. |
ObjectStateManager tracks query results, and provides logic to merge multiple overlapping query results. It also performs in-memory change tracking when a user inserts, deletes, or modifies objects, and provides the change set for updates. This change set is used by the change processor to persist modifications.
This class is typically used by ObjectContext and not directly in applications.
These examples are based on the Adventure Works Sales Model.
The following example gets the ObjectStateManager from the ObjectContext and uses the state manager to access an object in the context.
The following example uses the TryGetObjectStateEntry(EntityKey, ObjectStateEntry%) method on the returned ObjectStateManager to get an object based on its entity key.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
