Table of Contents

Interface IFindFluent<TDocument, TProjection>

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Fluent interface for find.

public interface IFindFluent<TDocument, TProjection> : IAsyncCursorSource<TProjection>

Type Parameters

TDocument

The type of the document.

TProjection

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

Inherited Members
Extension Methods

Remarks

This interface is not guaranteed to remain stable. Implementors should use FindFluentBase<TDocument, TProjection>.

Properties

Filter

Gets or sets the filter.

FilterDefinition<TDocument> Filter { get; set; }

Property Value

FilterDefinition<TDocument>

Options

Gets the options.

FindOptions<TDocument, TProjection> Options { get; }

Property Value

FindOptions<TDocument, TProjection>

Methods

As<TResult>(IBsonSerializer<TResult>)

A simplified type of projection that changes the result type by using a different serializer.

IFindFluent<TDocument, TResult> As<TResult>(IBsonSerializer<TResult> resultSerializer = null)

Parameters

resultSerializer IBsonSerializer<TResult>

The result serializer.

Returns

IFindFluent<TDocument, TResult>

The fluent find interface.

Type Parameters

TResult

The type of the result.

Count(CancellationToken)

Counts the number of documents.

[Obsolete("Use CountDocuments instead.")]
long Count(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

long

The count.

CountAsync(CancellationToken)

Counts the number of documents.

[Obsolete("Use CountDocumentsAsync instead.")]
Task<long> CountAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<long>

A Task whose result is the count.

CountDocuments(CancellationToken)

Counts the number of documents.

long CountDocuments(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

long

The count.

Remarks

Note: when migrating from Count to CountDocuments the following query operations must be replaced:

+-------------+--------------------------------+
| Operator    | Replacement                    |
+=============+================================+
| $where      |  $expr                         |
+-------------+--------------------------------+
| $near       |  $geoWithin with $center       |
+-------------+--------------------------------+
| $nearSphere |  $geoWithin with $centerSphere |
+-------------+--------------------------------+

CountDocumentsAsync(CancellationToken)

Counts the number of documents.

Task<long> CountDocumentsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

The cancellation token.

Returns

Task<long>

A Task whose result is the count.

Remarks

Note: when migrating from CountAsync to CountDocumentsAsync the following query operations must be replaced:

+-------------+--------------------------------+
| Operator    | Replacement                    |
+=============+================================+
| $where      |  $expr                         |
+-------------+--------------------------------+
| $near       |  $geoWithin with $center       |
+-------------+--------------------------------+
| $nearSphere |  $geoWithin with $centerSphere |
+-------------+--------------------------------+

Limit(int?)

Limits the number of documents.

IFindFluent<TDocument, TProjection> Limit(int? limit)

Parameters

limit int?

The limit.

Returns

IFindFluent<TDocument, TProjection>

The fluent find interface.

Remarks

Limit of zero or null is equivalent to setting no limit.

Project<TNewProjection>(ProjectionDefinition<TDocument, TNewProjection>)

Projects the the result.

IFindFluent<TDocument, TNewProjection> Project<TNewProjection>(ProjectionDefinition<TDocument, TNewProjection> projection)

Parameters

projection ProjectionDefinition<TDocument, TNewProjection>

The projection.

Returns

IFindFluent<TDocument, TNewProjection>

The fluent find interface.

Type Parameters

TNewProjection

The type of the projection.

Skip(int?)

Skips the the specified number of documents.

IFindFluent<TDocument, TProjection> Skip(int? skip)

Parameters

skip int?

The skip.

Returns

IFindFluent<TDocument, TProjection>

The fluent find interface.

Sort(SortDefinition<TDocument>)

Sorts the the documents.

IFindFluent<TDocument, TProjection> Sort(SortDefinition<TDocument> sort)

Parameters

sort SortDefinition<TDocument>

The sort.

Returns

IFindFluent<TDocument, TProjection>

The fluent find interface.