ObjectContext.TryGetObjectByKey Method (EntityKey, Object)

 

Returns an object that has the specified entity key.

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

[SuppressMessageAttribute("Microsoft.Design", "CA1007:UseGenericsWhereAppropriate")]
public virtual bool TryGetObjectByKey(
	EntityKey key,
	out object value
)

Parameters

key
Type: System.Data.Entity.Core.EntityKey

The key of the object to be found.

value
Type: System.Object

When this method returns, contains the object.

Return Value

Type: System.Boolean

true if the object was retrieved successfully. false if the key is temporary, the connection is null, or the value is null.

Exception Condition
ArgumentException

Incompatible metadata for key .

ArgumentNullException

key is null.