Table of Contents

Method DistinctAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

DistinctAsync<TDocument, TField>(IMongoCollection<TDocument>, Expression<Func<TDocument, TField>>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

public static Task<IAsyncCursor<TField>> DistinctAsync<TDocument, TField>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, TField>> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

field Expression<Func<TDocument, TField>>

The field.

filter FilterDefinition<TDocument>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TField>>

The distinct values for the specified field.

Type Parameters

TDocument

The type of the document.

TField

The type of the result.

DistinctAsync<TDocument, TField>(IMongoCollection<TDocument>, FieldDefinition<TDocument, TField>, Expression<Func<TDocument, bool>>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

public static Task<IAsyncCursor<TField>> DistinctAsync<TDocument, TField>(this IMongoCollection<TDocument> collection, FieldDefinition<TDocument, TField> field, Expression<Func<TDocument, bool>> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

field FieldDefinition<TDocument, TField>

The field.

filter Expression<Func<TDocument, bool>>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TField>>

The distinct values for the specified field.

Type Parameters

TDocument

The type of the document.

TField

The type of the result.

DistinctAsync<TDocument, TField>(IMongoCollection<TDocument>, Expression<Func<TDocument, TField>>, Expression<Func<TDocument, bool>>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

public static Task<IAsyncCursor<TField>> DistinctAsync<TDocument, TField>(this IMongoCollection<TDocument> collection, Expression<Func<TDocument, TField>> field, Expression<Func<TDocument, bool>> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

field Expression<Func<TDocument, TField>>

The field.

filter Expression<Func<TDocument, bool>>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TField>>

The distinct values for the specified field.

Type Parameters

TDocument

The type of the document.

TField

The type of the result.

DistinctAsync<TDocument, TField>(IMongoCollection<TDocument>, IClientSessionHandle, Expression<Func<TDocument, TField>>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

public static Task<IAsyncCursor<TField>> DistinctAsync<TDocument, TField>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, Expression<Func<TDocument, TField>> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

session IClientSessionHandle

The session.

field Expression<Func<TDocument, TField>>

The field.

filter FilterDefinition<TDocument>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TField>>

The distinct values for the specified field.

Type Parameters

TDocument

The type of the document.

TField

The type of the result.

DistinctAsync<TDocument, TField>(IMongoCollection<TDocument>, IClientSessionHandle, FieldDefinition<TDocument, TField>, Expression<Func<TDocument, bool>>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

public static Task<IAsyncCursor<TField>> DistinctAsync<TDocument, TField>(this IMongoCollection<TDocument> collection, IClientSessionHandle session, FieldDefinition<TDocument, TField> field, Expression<Func<TDocument, bool>> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)

Parameters

collection IMongoCollection<TDocument>

The collection.

session IClientSessionHandle

The session.

field FieldDefinition<TDocument, TField>

The field.

filter Expression<Func<TDocument, bool>>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TField>>

The distinct values for the specified field.

Type Parameters

TDocument

The type of the document.

TField

The type of the result.

DistinctAsync<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 Task<IAsyncCursor<TField>> DistinctAsync<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

collection IMongoCollection<TDocument>

The collection.

session IClientSessionHandle

The session.

field Expression<Func<TDocument, TField>>

The field.

filter Expression<Func<TDocument, bool>>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<IAsyncCursor<TField>>

The distinct values for the specified field.

Type Parameters

TDocument

The type of the document.

TField

The type of the result.