Class FindFluentBase<TDocument, TProjection>
Base class for implementors of IFindFluent<TDocument, TProjection>.
public abstract class FindFluentBase<TDocument, TProjection> : IOrderedFindFluent<TDocument, TProjection>, 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).
- Inheritance
-
FindFluentBase<TDocument, TProjection>
- Implements
-
IOrderedFindFluent<TDocument, TProjection>IFindFluent<TDocument, TProjection>IAsyncCursorSource<TProjection>
- Inherited Members
- Extension Methods
Properties
Filter
Gets or sets the filter.
public abstract FilterDefinition<TDocument> Filter { get; set; }
Property Value
- FilterDefinition<TDocument>
Options
Gets the options.
public abstract 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.
public abstract IFindFluent<TDocument, TResult> As<TResult>(IBsonSerializer<TResult> resultSerializer)
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.")]
public virtual long Count(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- long
The count.
CountAsync(CancellationToken)
Counts the number of documents.
[Obsolete("Use CountDocumentsAsync instead.")]
public abstract Task<long> CountAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
CountDocuments(CancellationToken)
Counts the number of documents.
public virtual 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.
public virtual 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.
public abstract 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.
public abstract 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.
public abstract 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.
public abstract IFindFluent<TDocument, TProjection> Sort(SortDefinition<TDocument> sort)
Parameters
sortSortDefinition<TDocument>The sort.
Returns
- IFindFluent<TDocument, TProjection>
The fluent find interface.
ToCursor(CancellationToken)
Executes the operation and returns a cursor to the results.
public virtual IAsyncCursor<TProjection> ToCursor(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- IAsyncCursor<TProjection>
A cursor.
ToCursorAsync(CancellationToken)
Executes the operation and returns a cursor to the results.
public abstract Task<IAsyncCursor<TProjection>> ToCursorAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe cancellation token.
Returns
- Task<IAsyncCursor<TProjection>>
A Task whose result is a cursor.