ObjectStateManager.ChangeObjectState(Object, EntityState) 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.
Changes state of the ObjectStateEntry for a specific object to the specified entityState .
public virtual System.Data.Entity.Core.Objects.ObjectStateEntry ChangeObjectState (object entity, System.Data.Entity.EntityState entityState);
abstract member ChangeObjectState : obj * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry
override this.ChangeObjectState : obj * System.Data.Entity.EntityState -> System.Data.Entity.Core.Objects.ObjectStateEntry
Parameters
- entity
- Object
The object for which the state must be changed.
- entityState
- EntityState
The new state of the object.
Returns
The ObjectStateEntry for the supplied entity .
Exceptions
When entity is null.
When the object is not detached and does not have an entry in the state manager or when you try to change the state to Detached from any other System.Data.Entity.EntityState. or when state is not a valid EntityState value.
Applies to
Entity Framework