Table of Contents

Method AnyAsync

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

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

Determines whether a sequence contains any elements.

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

Parameters

source IQueryable<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>(IQueryable<TSource>, Expression<Func<TSource, bool>>, CancellationToken)

Determines whether any element of a sequence satisfies a condition.

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

Parameters

source IQueryable<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.