Table of Contents

Method FindAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

FindAsync<TDocument>(IMongoCollection<TDocument>, FilterDefinition<TDocument>, FindOptions<TDocument, TDocument>, CancellationToken)

Finds the documents matching the filter.

public static Task<IAsyncCursor<TDocument>> FindAsync<TDocument>(this IMongoCollection<TDocument> collection, FilterDefinition<TDocument> filter, FindOptions<TDocument, TDocument> options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

filter FilterDefinition<TDocument>

The filter.

options FindOptions<TDocument, TDocument>

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TDocument>>

A Task whose result is a cursor.

Type Parameters

TDocument

The type of the document.

FindAsync<TDocument>(IMongoCollection<TDocument>, Expression<Func<TDocument, bool>>, FindOptions<TDocument, TDocument>, CancellationToken)

Finds the documents matching the filter.

public static Task<IAsyncCursor<TDocument>> FindAsync<TDocument>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, bool>> filter, FindOptions<TDocument, TDocument> options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

filter Expression<Func<TDocument, bool>>

The filter.

options FindOptions<TDocument, TDocument>

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TDocument>>

A Task whose result is a cursor.

Type Parameters

TDocument

The type of the document.

FindAsync<TDocument>(IMongoCollection<TDocument>, IClientSessionHandle, FilterDefinition<TDocument>, FindOptions<TDocument, TDocument>, CancellationToken)

Finds the documents matching the filter.

public static Task<IAsyncCursor<TDocument>> FindAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, FilterDefinition<TDocument> filter, FindOptions<TDocument, TDocument> options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

session IClientSessionHandle

The session.

filter FilterDefinition<TDocument>

The filter.

options FindOptions<TDocument, TDocument>

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TDocument>>

A Task whose result is a cursor.

Type Parameters

TDocument

The type of the document.

FindAsync<TDocument>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, bool>>, FindOptions<TDocument, TDocument>, CancellationToken)

Finds the documents matching the filter.

public static Task<IAsyncCursor<TDocument>> FindAsync<TDocument>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, bool>> filter, FindOptions<TDocument, TDocument> options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

session IClientSessionHandle

The session.

filter Expression<Func<TDocument, bool>>

The filter.

options FindOptions<TDocument, TDocument>

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TDocument>>

A Task whose result is a cursor.

Type Parameters

TDocument

The type of the document.