Method FirstOrDefaultAsync
FirstOrDefaultAsync<TDocument>(IAsyncCursor<TDocument>, CancellationToken)
Returns the first document of the cursor, or a default value if the cursor contains no documents.
public static Task<TDocument> FirstOrDefaultAsync<TDocument>(this IAsyncCursor<TDocument> cursor, CancellationToken cancellationToken = default)
Parameters
cursor
IAsyncCursor<TDocument>The cursor.
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.