Method Distinct
Distinct<TDocument, TField>(IMongoCollection<TDocument>, Expression<Func<TDocument, TField>>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)
Gets the distinct values for a specified field.
public static IAsyncCursor<TField> Distinct<TDocument, TField>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, TField>> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
fieldExpression<Func<TDocument, TField>>The field.
filterFilterDefinition<TDocument>The filter.
optionsDistinctOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- IAsyncCursor<TField>
The distinct values for the specified field.
Type Parameters
TDocumentThe type of the document.
TFieldThe type of the result.
Distinct<TDocument, TField>(IMongoCollection<TDocument>, FieldDefinition<TDocument, TField>, Expression<Func<TDocument, bool>>, DistinctOptions, CancellationToken)
Gets the distinct values for a specified field.
public static IAsyncCursor<TField> Distinct<TDocument, TField>(this IMongoCollection<TDocument> collection, FieldDefinition<TDocument, TField> field, Expression<Func<TDocument, bool>> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
fieldFieldDefinition<TDocument, TField>The field.
filterExpression<Func<TDocument, bool>>The filter.
optionsDistinctOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- IAsyncCursor<TField>
The distinct values for the specified field.
Type Parameters
TDocumentThe type of the document.
TFieldThe type of the result.
Distinct<TDocument, TField>(IMongoCollection<TDocument>, Expression<Func<TDocument, TField>>, Expression<Func<TDocument, bool>>, DistinctOptions, CancellationToken)
Gets the distinct values for a specified field.
public static IAsyncCursor<TField> Distinct<TDocument, TField>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, TField>> field, Expression<Func<TDocument, bool>> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
fieldExpression<Func<TDocument, TField>>The field.
filterExpression<Func<TDocument, bool>>The filter.
optionsDistinctOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- IAsyncCursor<TField>
The distinct values for the specified field.
Type Parameters
TDocumentThe type of the document.
TFieldThe type of the result.
Distinct<TDocument, TField>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, TField>>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)
Gets the distinct values for a specified field.
public static IAsyncCursor<TField> Distinct<TDocument, TField>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, TField>> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
sessionIClientSessionHandleThe session.
fieldExpression<Func<TDocument, TField>>The field.
filterFilterDefinition<TDocument>The filter.
optionsDistinctOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- IAsyncCursor<TField>
The distinct values for the specified field.
Type Parameters
TDocumentThe type of the document.
TFieldThe type of the result.
Distinct<TDocument, TField>(IMongoCollection<TDocument>, IClientSessionHandle, FieldDefinition<TDocument, TField>, Expression<Func<TDocument, bool>>, DistinctOptions, CancellationToken)
Gets the distinct values for a specified field.
public static IAsyncCursor<TField> Distinct<TDocument, TField>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, FieldDefinition<TDocument, TField> field, Expression<Func<TDocument, bool>> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
sessionIClientSessionHandleThe session.
fieldFieldDefinition<TDocument, TField>The field.
filterExpression<Func<TDocument, bool>>The filter.
optionsDistinctOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- IAsyncCursor<TField>
The distinct values for the specified field.
Type Parameters
TDocumentThe type of the document.
TFieldThe type of the result.
Distinct<TDocument, TField>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, TField>>, Expression<Func<TDocument, bool>>, DistinctOptions, CancellationToken)
Gets the distinct values for a specified field.
public static IAsyncCursor<TField> Distinct<TDocument, TField>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, TField>> field, Expression<Func<TDocument, bool>> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)
Parameters
collectionIMongoCollection<TDocument>The collection.
sessionIClientSessionHandleThe session.
fieldExpression<Func<TDocument, TField>>The field.
filterExpression<Func<TDocument, bool>>The filter.
optionsDistinctOptionsThe options.
cancellationTokenCancellationTokenThe cancellation token.
Returns
- IAsyncCursor<TField>
The distinct values for the specified field.
Type Parameters
TDocumentThe type of the document.
TFieldThe type of the result.