Table of Contents

Method Distinct

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

Distinct<TField>(FieldDefinition<TDocument, TField>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

public virtual IAsyncCursor<TField> Distinct<TField>(FieldDefinition<TDocument, TField> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)

Parameters

field FieldDefinition<TDocument, TField>

The field.

filter FilterDefinition<TDocument>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

IAsyncCursor<TField>

A cursor.

Type Parameters

TField

The type of the result.

Distinct<TField>(IClientSessionHandle, FieldDefinition<TDocument, TField>, FilterDefinition<TDocument>, DistinctOptions, CancellationToken)

Gets the distinct values for a specified field.

public virtual IAsyncCursor<TField> Distinct<TField>(IClientSessionHandle session, FieldDefinition<TDocument, TField> field, FilterDefinition<TDocument> filter, DistinctOptions options = null, CancellationToken cancellationToken = default)

Parameters

session IClientSessionHandle

The session.

field FieldDefinition<TDocument, TField>

The field.

filter FilterDefinition<TDocument>

The filter.

options DistinctOptions

The options.

cancellationToken CancellationToken

The cancellation token.

Returns

IAsyncCursor<TField>

A cursor.

Type Parameters

TField

The type of the result.