DbRawSqlQuery<TElement>.FirstAsync Method
Asynchronously returns the first element of the query.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() | FirstAsync() | Asynchronously returns the first element of the query. |
![]() | FirstAsync(CancellationToken) | Asynchronously returns the first element of the query. |
![]() | FirstAsync(Func<TElement, Boolean>) | Asynchronously returns the first element of the query that satisfies a specified condition. |
![]() | FirstAsync(Func<TElement, Boolean>, CancellationToken) | Asynchronously returns the first element of the query that satisfies a specified condition. |
DbRawSqlQuery<TElement>.FirstAsync Method ()
Asynchronously returns the first element of the query.
Exception | Condition |
---|---|
InvalidOperationException | The query result is empty. |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
DbRawSqlQuery<TElement>.FirstAsync Method (CancellationToken)
Asynchronously returns the first element of the query.
Parameters
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<TElement>A task that represents the asynchronous operation. The task result contains the first element in the query result.
Exception | Condition |
---|---|
InvalidOperationException | The query result is empty. |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
DbRawSqlQuery<TElement>.FirstAsync Method (Func<TElement, Boolean>)
Asynchronously returns the first element of the query that satisfies a specified condition.
Parameters
- predicate
-
Type:
System.Func<TElement, Boolean>
A function to test each element for a condition.
Return Value
Type: System.Threading.Tasks.Task<TElement>A task that represents the asynchronous operation. The task result contains the first element in the query result that satisfies a specified condition.
Exception | Condition |
---|---|
ArgumentNullException | predicate is null . |
InvalidOperationException | The query result is empty. |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.
DbRawSqlQuery<TElement>.FirstAsync Method (Func<TElement, Boolean>, CancellationToken)
Asynchronously returns the first element of the query that satisfies a specified condition.
public Task<TElement> FirstAsync( Func<TElement, bool> predicate, CancellationToken cancellationToken )
Parameters
- predicate
-
Type:
System.Func<TElement, Boolean>
A function to test each element for a condition.
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<TElement>A task that represents the asynchronous operation. The task result contains the first element in the query result that satisfies a specified condition.
Exception | Condition |
---|---|
ArgumentNullException | predicate is null . |
InvalidOperationException | The query result is empty. |
Multiple active operations on the same context instance are not supported. Use 'await' to ensure that any asynchronous operations have completed before calling another method on this context.