Table of Contents

Method Single

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Single<TDocument>(IAsyncCursorSource<TDocument>, CancellationToken)

Returns the only document of a cursor returned by a cursor source. This method throws an exception if the cursor does not contain exactly one document.

public static TDocument Single<TDocument>(this IAsyncCursorSource<TDocument> source, CancellationToken cancellationToken = default)

Parameters

source IAsyncCursorSource<TDocument>

The source.

cancellationToken CancellationToken

The cancellation token.

Returns

TDocument

The only document of a cursor.

Type Parameters

TDocument

The type of the document.