Table of Contents

Method AnyAsync

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

AnyAsync<TSource>(IMongoQueryable<TSource>, CancellationToken)

Determines whether a sequence contains any elements.

public static Task<bool> AnyAsync<TSource>(this IMongoQueryable<TSource> source, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence to check for being empty.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true if the source sequence contains any elements; otherwise, false.

Type Parameters

TSource

The type of the elements of source.

AnyAsync<TSource>(IMongoQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)

Determines whether any element of a sequence satisfies a condition.

public static Task<bool> AnyAsync<TSource>(this IMongoQueryable<TSource> source, Expression<Func<TSource, bool>> predicate, CancellationToken cancellationToken = default)

Parameters

source IMongoQueryable<TSource>

A sequence whose elements to test for a condition.

predicate Expression<Func<TSource, bool>>

A function to test each element for a condition.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

true if any elements in the source sequence pass the test in the specified predicate; otherwise, false.

Type Parameters

TSource

The type of the elements of source.