Interface IFindFluent<TDocument, TProjection>
Fluent interface for find.
public interface IFindFluent<TDocument, TProjection> : IAsyncCursorSource<TProjection>
Type Parameters
TDocumentThe type of the document.
TProjectionThe 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
resultSerializerIBsonSerializer<TResult>The result serializer.
Returns
- IFindFluent<TDocument, TResult>
The fluent find interface.
Type Parameters
TResultThe type of the result.
Count(CancellationToken)
Counts the number of documents.
[Obsolete("Use CountDocuments instead.")]
long Count(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- long
The count.
CountAsync(CancellationToken)
Counts the number of documents.
[Obsolete("Use CountDocumentsAsync instead.")]
Task<long> CountAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
CountDocuments(CancellationToken)
Counts the number of documents.
long CountDocuments(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe 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
cancellationTokenCancellationTokenThe cancellation token.
Returns
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
limitint?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
projectionProjectionDefinition<TDocument, TNewProjection>The projection.
Returns
- IFindFluent<TDocument, TNewProjection>
The fluent find interface.
Type Parameters
TNewProjectionThe type of the projection.
Skip(int?)
Skips the the specified number of documents.
IFindFluent<TDocument, TProjection> Skip(int? skip)
Parameters
skipint?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
sortSortDefinition<TDocument>The sort.
Returns
- IFindFluent<TDocument, TProjection>
The fluent find interface.