EntityFrameworkQueryableExtensions.ElementAtAsync<TSource> 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.
Asynchronously returns the element at a specified index in a sequence.
public static System.Threading.Tasks.Task<TSource> ElementAtAsync<TSource> (this System.Linq.IQueryable<TSource> source, int index, System.Threading.CancellationToken cancellationToken = default);
static member ElementAtAsync : System.Linq.IQueryable<'Source> * int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Source>
<Extension()>
Public Function ElementAtAsync(Of TSource) (source As IQueryable(Of TSource), index As Integer, Optional cancellationToken As CancellationToken = Nothing) As Task(Of TSource)
Type Parameters
- TSource
The type of the elements of source
.
Parameters
- source
- IQueryable<TSource>
An IQueryable<T> to return the element from.
- index
- Int32
The zero-based index of the element to retrieve.
- 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 element at a specified index in a source
sequence.
Exceptions
source
is null
.
index
is less than zero.
If the CancellationToken is canceled.
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. See Avoiding DbContext threading issues for more information and examples.
See Querying data with EF Core for more information and examples.
Applies to
Entity Framework