Method FirstOrDefaultAsync
FirstOrDefaultAsync<TDocument, TProjection>(IFindFluent<TDocument, TProjection>, CancellationToken)
Get the first result or null.
public static Task<TProjection> FirstOrDefaultAsync<TDocument, TProjection>(this IFindFluent<TDocument, TProjection> find, CancellationToken cancellationToken = default)
Parameters
find
IFindFluent<TDocument, TProjection>The fluent find.
cancellationToken
CancellationTokenThe cancellation token.
Returns
- Task<TProjection>
A Task whose result is the first 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).