ObjectStateManager::GetObjectStateEntry Method (EntityKey^)
Returns an ObjectStateEntry for the object or relationship entry with the specified key.
Assembly: System.Data.Entity (in System.Data.Entity.dll)
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.
Available since 3.5