Table of Contents

Method FirstAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

FirstAsync<TDocument>(IAsyncCursor<TDocument>, CancellationToken)

Returns the first document of a cursor.

public static Task<TDocument> FirstAsync<TDocument>(this IAsyncCursor<TDocument> cursor, CancellationToken cancellationToken = default)

Parameters

cursor IAsyncCursor<TDocument>

The cursor.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TDocument>

A Task whose result is the first document.

Type Parameters

TDocument

The type of the document.