DbRawSqlQuery<TElement>.FirstAsync 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.
Overloads
FirstAsync() |
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(CancellationToken) |
Asynchronously returns the first element of the query. |
FirstAsync(Func<TElement,Boolean>, CancellationToken) |
Asynchronously returns the first element of the query that satisfies a specified condition. |
FirstAsync()
Asynchronously returns the first element of the query.
public System.Threading.Tasks.Task<TElement> FirstAsync ();
member this.FirstAsync : unit -> System.Threading.Tasks.Task<'Element>
Public Function FirstAsync () As Task(Of TElement)
Returns
A task that represents the asynchronous operation. The task result contains the first element in the query result.
Exceptions
The query result is empty.
Remarks
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.
Applies to
FirstAsync(Func<TElement,Boolean>)
Asynchronously returns the first element of the query that satisfies a specified condition.
public System.Threading.Tasks.Task<TElement> FirstAsync (Func<TElement,bool> predicate);
member this.FirstAsync : Func<'Element, bool> -> System.Threading.Tasks.Task<'Element>
Public Function FirstAsync (predicate As Func(Of TElement, Boolean)) As Task(Of TElement)
Parameters
Returns
A task that represents the asynchronous operation. The task result contains the first element in the query result that satisfies a specified condition.
Exceptions
predicate
is
null
.
The query result is empty.
Remarks
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.
Applies to
FirstAsync(CancellationToken)
Asynchronously returns the first element of the query.
public System.Threading.Tasks.Task<TElement> FirstAsync (System.Threading.CancellationToken cancellationToken);
member this.FirstAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Element>
Parameters
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation. The task result contains the first element in the query result.
Exceptions
The query result is empty.
Remarks
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.
Applies to
FirstAsync(Func<TElement,Boolean>, CancellationToken)
Asynchronously returns the first element of the query that satisfies a specified condition.
public System.Threading.Tasks.Task<TElement> FirstAsync (Func<TElement,bool> predicate, System.Threading.CancellationToken cancellationToken);
member this.FirstAsync : Func<'Element, bool> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Element>
Parameters
- cancellationToken
- CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Returns
A task that represents the asynchronous operation. The task result contains the first element in the query result that satisfies a specified condition.
Exceptions
predicate
is
null
.
The query result is empty.
Remarks
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.
Applies to
Entity Framework