Table of Contents

Method Single

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.Core.dll

Single<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 TDocument Single<TDocument>(this IAsyncCursor<TDocument> cursor, CancellationToken cancellationToken = default)

Parameters

cursor IAsyncCursor<TDocument>

The cursor.

cancellationToken CancellationToken

The cancellation token.

Returns

TDocument

The only document of a cursor.

Type Parameters

TDocument

The type of the document.