Table of Contents

Method FindAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

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

Finds the documents matching the filter.

public abstract Task<IAsyncCursor<TProjection>> FindAsync<TProjection>(FilterDefinition<TDocument> filter, FindOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default)

Parameters

filter FilterDefinition<TDocument>

The filter.

options FindOptions<TDocument, TProjection>

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TProjection>>

A Task whose result is a cursor.

Type Parameters

TProjection

The type of the projection (same as TDocument if there is no projection).

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

Finds the documents matching the filter.

public virtual Task<IAsyncCursor<TProjection>> FindAsync<TProjection>(IClientSessionHandle session, FilterDefinition<TDocument> filter, FindOptions<TDocument, TProjection> options = null, CancellationToken cancellationToken = default)

Parameters

session IClientSessionHandle

The session.

filter FilterDefinition<TDocument>

The filter.

options FindOptions<TDocument, TProjection>

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TProjection>>

A Task whose result is a cursor.

Type Parameters

TProjection

The type of the projection (same as TDocument if there is no projection).