DbSet.Find(Object[]) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Finds an entity with the given primary key values. If an entity with the given primary key values exists in the context, then it is returned immediately without making a request to the store. Otherwise, a request is made to the store for an entity with the given primary key values and this entity, if found, is attached to the context and returned. If no entity is found in the context or the store, then null is returned.
public virtual object Find (params object[] keyValues);
abstract member Find : obj[] -> obj
override this.Find : obj[] -> obj
Public Overridable Function Find (ParamArray keyValues As Object()) As Object
Parameters
- keyValues
- Object[]
The values of the primary key for the entity to be found.
Returns
The entity found, or null.
Exceptions
Thrown if the context has been disposed.
Remarks
The ordering of composite key values is as defined in the EDM, which is in turn as defined in the designer, by the Code First fluent API, or by the DataMember attribute.
Applies to
Entity Framework