Export (0) Print
Expand All

DbSet.Find Method

Entity Framework 5.0

Uses the primary key value to attempt to find an entity tracked by the context. If the entity is not in the context then a query will be executed and evaluated against the data in the data source, and null is returned if the entity is not found in the context or in the data source. Note that the Find also returns entities that have been added to the context but have not yet been saved to the database.

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

abstract Find : 
        keyValues:Object[] -> Object


Type: System.Object[]

The values of the primary key for the entity to be found.

Return Value

Type: System.Object
The entity found, or null.

The Find method takes an array of objects as an argument. When working with composite primary keys, pass the key values separated by commas and in the same order that they are defined in the model.

© 2014 Microsoft