DbContext.Find DbContext.Find Method

Definition

Overloads

Find(Type, Object[]) Find(Type, Object())

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the dataabse 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, then null is returned.

Find<TEntity>(Object[]) Find(Of TEntity)(Object())

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the dataabse 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, then null is returned.

Find(Type, Object[]) Find(Type, Object())

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the dataabse 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, then null is returned.

public virtual object Find(Type entityType, params object[] keyValues)
Public Overridable Function Find(entityType As Type, ParamArray keyValues As Object()) As Object

Parameters

entityType
System.Type System.Type

The type of entity to find.

keyValues
System.Object[] System.Object()

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

Returns

System.Object System.Object

The entity found, or null.

Find<TEntity>(Object[]) Find(Of TEntity)(Object())

Finds an entity with the given primary key values. If an entity with the given primary key values is being tracked by the context, then it is returned immediately without making a request to the database. Otherwise, a query is made to the dataabse 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, then null is returned.

public virtual TEntity Find<TEntity>(params object[] keyValues)where TEntity : class
Public Overridable Function Find(Of TEntity As Class)(ParamArray keyValues As Object()) As TEntity

Type Parameters

TEntity

The type of entity to find.

Parameters

keyValues
System.Object[] System.Object()

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

Returns

TEntity TEntity

The entity found, or null.