ObjectStateManager::TryGetObjectStateEntry Method (EntityKey^, ObjectStateEntry^%)

 

Tries to retrieve the corresponding ObjectStateEntry for the object or relationship with the specified EntityKey.

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

public:
bool TryGetObjectStateEntry(
	EntityKey^ key,
	[OutAttribute] ObjectStateEntry^% entry
)

Parameters

key
Type: System.Data::EntityKey^

The given EntityKey.

entry
Type: System.Data.Objects::ObjectStateEntry^%

When this method returns, contains an ObjectStateEntry for the given EntityKey This parameter is passed uninitialized.

Return Value

Type: System::Boolean

A Boolean value that is true if there is a corresponding ObjectStateEntry for the given EntityKey; otherwise, false.

Exception Condition
ArgumentNullException

A null (Nothing in Visual Basic) value is provided for key.

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

The examples in this topic are based on the AdventureWorks Sales Model.

The example attempts to retrieve the corresponding ObjectStateEntry for the given EntityKey.

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

The following example uses the TryGetObjectStateEntry(EntityKey^, ObjectStateEntry^%) method on the returned ObjectStateManager to get an object based on its entity key.

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

.NET Framework
Available since 3.5
Return to top
Show: