QueryableExtensions.MaxAsync Method
Asynchronously returns the maximum value of a sequence.
Assembly: EntityFramework (in EntityFramework.dll)
Name | Description | |
---|---|---|
![]() ![]() | MaxAsync<TSource>(IQueryable<TSource>) | Asynchronously returns the maximum value of a sequence. |
![]() ![]() | MaxAsync<TSource>(IQueryable<TSource>, CancellationToken) | Asynchronously returns the maximum value of a sequence. |
![]() ![]() | MaxAsync<TSource, TResult>(IQueryable<TSource>, Expression<Func<TSource, TResult>>) | Asynchronously invokes a projection function on each element of a sequence and returns the maximum resulting value. |
![]() ![]() | MaxAsync<TSource, TResult>(IQueryable<TSource>, Expression<Func<TSource, TResult>>, CancellationToken) | Asynchronously invokes a projection function on each element of a sequence and returns the maximum resulting value. |
QueryableExtensions.MaxAsync<TSource> Method (IQueryable<TSource>)
Asynchronously returns the maximum value of a sequence.
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> that contains the elements to determine the maximum of.
Return Value
Type: System.Threading.Tasks.Task<TSource>A task that represents the asynchronous operation. The task result contains the maximum value in the sequence.
Type Parameters
- TSource
The type of the elements of source.
Exception | Condition |
---|---|
ArgumentNullException | source is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
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.
QueryableExtensions.MaxAsync<TSource> Method (IQueryable<TSource>, CancellationToken)
Asynchronously returns the maximum value of a sequence.
public static Task<TSource> MaxAsync<TSource>( this IQueryable<TSource> source, CancellationToken cancellationToken )
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> that contains the elements to determine the maximum of.
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<TSource>A task that represents the asynchronous operation. The task result contains the maximum value in the sequence.
Type Parameters
- TSource
The type of the elements of source.
Exception | Condition |
---|---|
ArgumentNullException | source is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
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.
QueryableExtensions.MaxAsync<TSource, TResult> Method (IQueryable<TSource>, Expression<Func<TSource, TResult>>)
Asynchronously invokes a projection function on each element of a sequence and returns the maximum resulting value.
[SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] public static Task<TResult> MaxAsync<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector )
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> that contains the elements to determine the maximum of.
- selector
-
Type:
System.Linq.Expressions.Expression<Func<TSource, TResult>>
A projection function to apply to each element.
Return Value
Type: System.Threading.Tasks.Task<TResult>A task that represents the asynchronous operation. The task result contains the maximum value in the sequence.
Type Parameters
- TSource
The type of the elements of source.
- TResult
The type of the value returned by the function represented by selector .
Exception | Condition |
---|---|
ArgumentNullException | source or selector is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
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.
QueryableExtensions.MaxAsync<TSource, TResult> Method (IQueryable<TSource>, Expression<Func<TSource, TResult>>, CancellationToken)
Asynchronously invokes a projection function on each element of a sequence and returns the maximum resulting value.
[SuppressMessageAttribute("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] [SuppressMessageAttribute("Microsoft.Design", "CA1006:DoNotNestGenericTypesInMemberSignatures")] public static Task<TResult> MaxAsync<TSource, TResult>( this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken cancellationToken )
Parameters
- source
-
Type:
System.Linq.IQueryable<TSource>
An IQueryable<T> that contains the elements to determine the maximum of.
- selector
-
Type:
System.Linq.Expressions.Expression<Func<TSource, TResult>>
A projection function to apply to each element.
- cancellationToken
-
Type:
System.Threading.CancellationToken
A CancellationToken to observe while waiting for the task to complete.
Return Value
Type: System.Threading.Tasks.Task<TResult>A task that represents the asynchronous operation. The task result contains the maximum value in the sequence.
Type Parameters
- TSource
The type of the elements of source.
- TResult
The type of the value returned by the function represented by selector .
Exception | Condition |
---|---|
ArgumentNullException | source or selector is null . |
InvalidOperationException | source does not implement IDbAsyncQueryProvider . |
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.