DbContext.FindAsync DbContext.FindAsync DbContext.FindAsync Method

Definition

Overloads

FindAsync(Type, Object[]) FindAsync(Type, Object[]) FindAsync(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 database 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.

FindAsync(Type, Object[], CancellationToken) FindAsync(Type, Object[], CancellationToken)

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 database 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.

FindAsync<TEntity>(Object[]) FindAsync<TEntity>(Object[]) FindAsync<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 database 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.

FindAsync<TEntity>(Object[], CancellationToken) FindAsync<TEntity>(Object[], CancellationToken)

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 database 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.

FindAsync(Type, Object[]) FindAsync(Type, Object[]) FindAsync(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 database 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 System.Threading.Tasks.Task<object> FindAsync (Type entityType, params object[] keyValues);
abstract member FindAsync : Type * obj[] -> System.Threading.Tasks.Task<obj>
override this.FindAsync : Type * obj[] -> System.Threading.Tasks.Task<obj>
Public Overridable Function FindAsync (entityType As Type, ParamArray keyValues As Object()) As Task(Of Object)

Parameters

entityType
Type Type Type

The type of entity to find.

keyValues
Object[]

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

Returns

The entity found, or null.

FindAsync(Type, Object[], CancellationToken) FindAsync(Type, Object[], CancellationToken)

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 database 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 System.Threading.Tasks.Task<object> FindAsync (Type entityType, object[] keyValues, System.Threading.CancellationToken cancellationToken);
abstract member FindAsync : Type * obj[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
override this.FindAsync : Type * obj[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>

Parameters

entityType
Type Type Type

The type of entity to find.

keyValues
Object[]

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

cancellationToken
CancellationToken CancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

The entity found, or null.

FindAsync<TEntity>(Object[]) FindAsync<TEntity>(Object[]) FindAsync<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 database 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 System.Threading.Tasks.Task<TEntity> FindAsync<TEntity> (params object[] keyValues) where TEntity : class;
abstract member FindAsync : obj[] -> System.Threading.Tasks.Task<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.FindAsync : obj[] -> System.Threading.Tasks.Task<'Entity (requires 'Entity : null)> (requires 'Entity : null)
Public Overridable Function FindAsync(Of TEntity As Class) (ParamArray keyValues As Object()) As Task(Of TEntity)

Type Parameters

TEntity

The type of entity to find.

Parameters

keyValues
Object[]

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

Returns

Task<TEntity>

The entity found, or null.

FindAsync<TEntity>(Object[], CancellationToken) FindAsync<TEntity>(Object[], CancellationToken)

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 database 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 System.Threading.Tasks.Task<TEntity> FindAsync<TEntity> (object[] keyValues, System.Threading.CancellationToken cancellationToken) where TEntity : class;
abstract member FindAsync : obj[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Entity (requires 'Entity : null)> (requires 'Entity : null)
override this.FindAsync : obj[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Entity (requires 'Entity : null)> (requires 'Entity : null)

Type Parameters

TEntity

The type of entity to find.

Parameters

keyValues
Object[]

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

cancellationToken
CancellationToken CancellationToken CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<TEntity>

The entity found, or null.

Applies to