ObjectStateManager::GetObjectStateEntry Method (EntityKey^)

 

Returns an ObjectStateEntry for the object or relationship entry with the specified key.

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

public:
ObjectStateEntry^ GetObjectStateEntry(
	EntityKey^ key
)

Parameters

key
Type: System.Data::EntityKey^

The EntityKey.

Return Value

Type: System.Data.Objects::ObjectStateEntry^

The corresponding ObjectStateEntry for the given EntityKey.

Exception Condition
ArgumentNullException

When key is null.

ArgumentException

When the specified key cannot be found in the state manager.

InvalidOperationException

No entity with the specified EntityKey exists in the ObjectStateManager.

Use the TryGetObjectStateEntry(EntityKey^, ObjectStateEntry^%) method to return an ObjectStateEntry object without having to handle the InvalidOperationException raised by the GetObjectStateEntry(EntityKey^) method.

The example in this topic is based on the AdventureWorks Sales Model. The example gets the ObjectStateEntry for the given EntityKey from the ObjectStateManager. Then it gets the current value of the SalesOrderHeader.PurchaseOrderNumber property, changes the property's value, and enumerates through the collection of modified properties.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 3.5
Return to top
Show: