Table of Contents

Method SingleOrDefault

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

SingleOrDefault<TDocument, TProjection>(IFindFluent<TDocument, TProjection>, CancellationToken)

Gets a single result or null.

public static TProjection SingleOrDefault<TDocument, TProjection>(this IFindFluent<TDocument, TProjection> find, CancellationToken cancellationToken = default)

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

cancellationToken CancellationToken

The cancellation token.

Returns

TProjection

A Task whose result is the single result or null.

Type Parameters

TDocument

The type of the document.

TProjection

The type of the projection (same as TDocument if there is no projection).