Table of Contents

Method MaxAsync

Namespace
MongoDB.Driver.Linq
Assembly
MongoDB.Driver.dll

MaxAsync<TSource>(IQueryable<TSource>, CancellationToken)

Returns the maximum value in a generic IQueryable<T>.

public static Task<TSource> MaxAsync<TSource>(this IQueryable<TSource> source, CancellationToken cancellationToken = default)

Parameters

source IQueryable<TSource>

A sequence of values to determine the maximum of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TSource>

The maximum value in the sequence.

Type Parameters

TSource

The type of the elements of source.

MaxAsync<TSource, TResult>(IQueryable<TSource>, Expression<Func<TSource, TResult>>, CancellationToken)

Invokes a projection function on each element of a generic IQueryable<T> and returns the maximum resulting value.

public static Task<TResult> MaxAsync<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector, CancellationToken cancellationToken = default)

Parameters

source IQueryable<TSource>

A sequence of values to determine the maximum of.

selector Expression<Func<TSource, TResult>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TResult>

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.