Method SingleAsync
SingleAsync<TDocument>(IAsyncCursor<TDocument>, CancellationToken)
Returns the only document of a cursor. This method throws an exception if the cursor does not contain exactly one document.
public static Task<TDocument> SingleAsync<TDocument>(this IAsyncCursor<TDocument> cursor, CancellationToken cancellationToken = default)
Parameters
cursorIAsyncCursor<TDocument>The cursor.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<TDocument>
A Task whose result is the only document of a cursor.
Type Parameters
TDocumentThe type of the document.