Method FirstOrDefault
FirstOrDefault<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 TDocument FirstOrDefault<TDocument>(this IAsyncCursorSource<TDocument> source, CancellationToken cancellationToken = default)
Parameters
sourceIAsyncCursorSource<TDocument>The source.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- TDocument
The first document of the cursor, or a default value if the cursor contains no documents.
Type Parameters
TDocumentThe type of the document.