Method FindAsync
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
CancellationTokenThe 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
CancellationTokenThe 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
IClientSessionHandleThe session.
filter
FilterDefinition<TDocument>The filter.
options
FindOptions<TDocument, TDocument>The options.
cancellationToken
CancellationTokenThe 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
IClientSessionHandleThe session.
filter
Expression<Func<TDocument, bool>>The filter.
options
FindOptions<TDocument, TDocument>The options.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<TDocument>>
A Task whose result is a cursor.
Type Parameters
TDocument
The type of the document.