Table of Contents

Method AverageAsync

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

AverageAsync(IMongoQueryable<decimal>, CancellationToken)

Computes the average of a sequence of decimal values.

public static Task<decimal> AverageAsync(this IMongoQueryable<decimal> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<decimal>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<decimal>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<decimal?>, CancellationToken)

Computes the average of a sequence of Nullable<T> values.

public static Task<decimal?> AverageAsync(this IMongoQueryable<decimal?> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<decimal?>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<decimal?>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<double>, CancellationToken)

Computes the average of a sequence of double values.

public static Task<double> AverageAsync(this IMongoQueryable<double> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<double>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<double?>, CancellationToken)

Computes the average of a sequence of Nullable<T> values.

public static Task<double?> AverageAsync(this IMongoQueryable<double?> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<double?>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double?>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<float>, CancellationToken)

Computes the average of a sequence of float values.

public static Task<float> AverageAsync(this IMongoQueryable<float> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<float>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<float>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<float?>, CancellationToken)

Computes the average of a sequence of Nullable<T> values.

public static Task<float?> AverageAsync(this IMongoQueryable<float?> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<float?>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<float?>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<int>, CancellationToken)

Computes the average of a sequence of int values.

public static Task<double> AverageAsync(this IMongoQueryable<int> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<int>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<int?>, CancellationToken)

Computes the average of a sequence of Nullable<T> values.

public static Task<double?> AverageAsync(this IMongoQueryable<int?> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<int?>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double?>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<long>, CancellationToken)

Computes the average of a sequence of long values.

public static Task<double> AverageAsync(this IMongoQueryable<long> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<long>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double>

The average of the values in the sequence.

AverageAsync(IMongoQueryable<long?>, CancellationToken)

Computes the average of a sequence of Nullable<T> values.

public static Task<double?> AverageAsync(this IMongoQueryable<long?> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<long?>

A sequence of values to calculate the average of.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double?>

The average of the values in the sequence.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, decimal>>, CancellationToken)

Computes the average of the sequence of decimal values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<decimal> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, decimal>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, decimal>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<decimal>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, decimal?>>, CancellationToken)

Computes the average of the sequence of Nullable<T> values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<decimal?> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, decimal?>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, decimal?>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<decimal?>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, double>>, CancellationToken)

Computes the average of the sequence of double values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, double>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, double>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, double?>>, CancellationToken)

Computes the average of the sequence of Nullable<T> values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double?> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, double?>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, double?>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double?>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, float>>, CancellationToken)

Computes the average of the sequence of float values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<float> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, float>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, float>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<float>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, float?>>, CancellationToken)

Computes the average of the sequence of Nullable<T> values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<float?> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, float?>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, float?>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<float?>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, int>>, CancellationToken)

Computes the average of the sequence of int values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, int>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, int>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, int?>>, CancellationToken)

Computes the average of the sequence of Nullable<T> values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double?> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, int?>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, int?>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double?>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, long>>, CancellationToken)

Computes the average of the sequence of long values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, long>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, long>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.

AverageAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, long?>>, CancellationToken)

Computes the average of the sequence of Nullable<T> values that is obtained by invoking a projection function on each element of the input sequence.

public static Task<double?> AverageAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, long?>> selector, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence of values.

selector Expression<Func<TSource, long?>>

A projection function to apply to each element.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<double?>

The average of the projected values.

Type Parameters

TSource

The type of the elements of source.