Click or drag to resize

MongoCollection.Distinct<TValue> Method (String, IMongoQuery)

Returns the distinct values for a given field for documents that match a query.

Namespace:  MongoDB.Driver
Assembly:  MongoDB.Driver.Legacy (in MongoDB.Driver.Legacy.dll) Version: 2.21.0+5a9c3311e158910b88195f290e6d4b1b2715d2b2
Syntax
public virtual IEnumerable<TValue> Distinct<TValue>(
	string key,
	IMongoQuery query
)

Parameters

key
Type: System.String
The key of the field.
query
Type: MongoDB.Driver.IMongoQuery
The query (usually a QueryDocument or constructed using the Query builder).

Type Parameters

TValue
The type of the value.

Return Value

Type: IEnumerable<TValue>
The distint values of the field.
See Also