Table of Contents

Class IFindFluentExtensions

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll
public static class IFindFluentExtensions
Inheritance
IFindFluentExtensions
Inherited Members

Methods

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

Determine if there are any results.

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

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<bool>

A Task whose result is true if there is at least one document.

Type Parameters

TDocument

The type of the document.

TProjection

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

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

Determine if there are any results.

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

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

cancellationToken CancellationToken

The cancellation token.

Returns

bool

True if there is at least one document.

Type Parameters

TDocument

The type of the document.

TProjection

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

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

Get the first result.

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

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TProjection>

A Task whose result is the first result.

Type Parameters

TDocument

The type of the document.

TProjection

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

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 CancellationToken

The 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).

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

Get the first result or null.

public static TProjection FirstOrDefault<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 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).

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

Get the first result.

public static TProjection First<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 first result.

Type Parameters

TDocument

The type of the document.

TProjection

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

Project<TDocument, TProjection>(IFindFluent<TDocument, TProjection>, ProjectionDefinition<TDocument, BsonDocument>)

Projects the result.

public static IFindFluent<TDocument, BsonDocument> Project<TDocument, TProjection>(this IFindFluent<TDocument, TProjection> find, ProjectionDefinition<TDocument, BsonDocument> projection)

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

projection ProjectionDefinition<TDocument, BsonDocument>

The projection.

Returns

IFindFluent<TDocument, BsonDocument>

The fluent find interface.

Type Parameters

TDocument

The type of the document.

TProjection

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

Project<TDocument, TProjection, TNewProjection>(IFindFluent<TDocument, TProjection>, Expression<Func<TDocument, TNewProjection>>)

Projects the result.

public static IFindFluent<TDocument, TNewProjection> Project<TDocument, TProjection, TNewProjection>(this IFindFluent<TDocument, TProjection> find, Expression<Func<TDocument, TNewProjection>> projection)

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

projection Expression<Func<TDocument, TNewProjection>>

The projection.

Returns

IFindFluent<TDocument, TNewProjection>

The fluent find interface.

Type Parameters

TDocument

The type of the document.

TProjection

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

TNewProjection

The type of the new projection.

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

Gets a single result.

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

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<TProjection>

A Task whose result is the single result.

Type Parameters

TDocument

The type of the document.

TProjection

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

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

Gets a single result or null.

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

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<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).

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).

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

Gets a single result.

public static TProjection Single<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.

Type Parameters

TDocument

The type of the document.

TProjection

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

SortByDescending<TDocument, TProjection>(IFindFluent<TDocument, TProjection>, Expression<Func<TDocument, object>>)

Sorts the results by a descending field.

public static IOrderedFindFluent<TDocument, TProjection> SortByDescending<TDocument, TProjection>(this IFindFluent<TDocument, TProjection> find, Expression<Func<TDocument, object>> field)

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

field Expression<Func<TDocument, object>>

The field.

Returns

IOrderedFindFluent<TDocument, TProjection>

The fluent find interface.

Type Parameters

TDocument

The type of the document.

TProjection

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

SortBy<TDocument, TProjection>(IFindFluent<TDocument, TProjection>, Expression<Func<TDocument, object>>)

Sorts the results by an ascending field.

public static IOrderedFindFluent<TDocument, TProjection> SortBy<TDocument, TProjection>(this IFindFluent<TDocument, TProjection> find, Expression<Func<TDocument, object>> field)

Parameters

find IFindFluent<TDocument, TProjection>

The fluent find.

field Expression<Func<TDocument, object>>

The field.

Returns

IOrderedFindFluent<TDocument, TProjection>

The fluent find interface.

Type Parameters

TDocument

The type of the document.

TProjection

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

ThenByDescending<TDocument, TProjection>(IOrderedFindFluent<TDocument, TProjection>, Expression<Func<TDocument, object>>)

Adds a descending field to the existing sort.

public static IOrderedFindFluent<TDocument, TProjection> ThenByDescending<TDocument, TProjection>(this IOrderedFindFluent<TDocument, TProjection> find, Expression<Func<TDocument, object>> field)

Parameters

find IOrderedFindFluent<TDocument, TProjection>

The fluent find.

field Expression<Func<TDocument, object>>

The field.

Returns

IOrderedFindFluent<TDocument, TProjection>

The fluent find interface.

Type Parameters

TDocument

The type of the document.

TProjection

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

ThenBy<TDocument, TProjection>(IOrderedFindFluent<TDocument, TProjection>, Expression<Func<TDocument, object>>)

Adds an ascending field to the existing sort.

public static IOrderedFindFluent<TDocument, TProjection> ThenBy<TDocument, TProjection>(this IOrderedFindFluent<TDocument, TProjection> find, Expression<Func<TDocument, object>> field)

Parameters

find IOrderedFindFluent<TDocument, TProjection>

The fluent find.

field Expression<Func<TDocument, object>>

The field.

Returns

IOrderedFindFluent<TDocument, TProjection>

The fluent find interface.

Type Parameters

TDocument

The type of the document.

TProjection

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