ObjectStateManager.ChangeObjectState Method (Object, EntityState)

 

Changes state of the ObjectStateEntry for a specific object to the specified entityState .

Namespace:   System.Data.Entity.Core.Objects
Assembly:  EntityFramework (in EntityFramework.dll)

public virtual ObjectStateEntry ChangeObjectState(
	object entity,
	EntityState entityState
)

Parameters

entity
Type: System.Object

The object for which the state must be changed.

entityState
Type: System.Data.Entity.EntityState

The new state of the object.

Return Value

Type: System.Data.Entity.Core.Objects.ObjectStateEntry

The ObjectStateEntry for the supplied entity .

Exception Condition
ArgumentNullException

When entity is null.

InvalidOperationException

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 T:System.Data.Entity.EntityState. or when state is not a valid EntityState value.