Method FirstOrDefaultAsync
FirstOrDefaultAsync<TDocument>(IAsyncCursorSource<TDocument>, CancellationToken)
Returns the first document of a cursor returned by a cursor source, or a default value if the cursor contains no documents.
public static Task<TDocument> FirstOrDefaultAsync<TDocument>(this IAsyncCursorSource<TDocument> source, CancellationToken cancellationToken = default)
Parameters
source
IAsyncCursorSource<TDocument>The source.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<TDocument>
A Task whose result is the first document of the cursor, or a default value if the cursor contains no documents.
Type Parameters
TDocument
The type of the document.