Table of Contents

Class Distinct<T, TProperty>

Namespace
MongoDB.Entities
Assembly
MongoDB.Entities.dll

Represents a MongoDB Distinct command where you can get back distinct values for a given property of a given Entity.

public class Distinct<T, TProperty> where T : IEntity

Type Parameters

T

Any Entity that implements IEntity interface

TProperty

The type of the property of the entity you'd like to get unique values for

Inheritance
Distinct<T, TProperty>
Inherited Members

Methods

ExecuteAsync(CancellationToken)

Run the Distinct command in MongoDB server and get a list of unique property values

public Task<List<TProperty>> ExecuteAsync(CancellationToken cancellation = default)

Parameters

cancellation CancellationToken

An optional cancellation token

Returns

Task<List<TProperty>>

ExecuteCursorAsync(CancellationToken)

Run the Distinct command in MongoDB server and get a cursor instead of materialized results

public Task<IAsyncCursor<TProperty>> ExecuteCursorAsync(CancellationToken cancellation = default)

Parameters

cancellation CancellationToken

An optional cancellation token

Returns

Task<IAsyncCursor<TProperty>>

IgnoreGlobalFilters()

Specify that this operation should ignore any global filters

public Distinct<T, TProperty> IgnoreGlobalFilters()

Returns

Distinct<T, TProperty>

Match(Search, string, bool, bool, string?)

Specify a search term to find results from the text index of this particular collection.

TIP: Make sure to define a text index with DB.Index<T>() before searching

public Distinct<T, TProperty> Match(Search searchType, string searchTerm, bool caseSensitive = false, bool diacriticSensitive = false, string? language = null)

Parameters

searchType Search

The type of text matching to do

searchTerm string

The search term

caseSensitive bool

Case sensitivity of the search (optional)

diacriticSensitive bool

Diacritic sensitivity of the search (optional)

language string

The language for the search (optional)

Returns

Distinct<T, TProperty>

Match(Template)

Specify the matching criteria with a template

public Distinct<T, TProperty> Match(Template template)

Parameters

template Template

A Template with a find query

Returns

Distinct<T, TProperty>

Match(Func<FilterDefinitionBuilder<T>, FilterDefinition<T>>)

Specify the matching criteria with a filter expression

public Distinct<T, TProperty> Match(Func<FilterDefinitionBuilder<T>, FilterDefinition<T>> filter)

Parameters

filter Func<FilterDefinitionBuilder<T>, FilterDefinition<T>>

f => f.Eq(x => x.Prop, Value) & f.Gt(x => x.Prop, Value)

Returns

Distinct<T, TProperty>

Match(Expression<Func<T, bool>>)

Specify the matching criteria with a lambda expression

public Distinct<T, TProperty> Match(Expression<Func<T, bool>> expression)

Parameters

expression Expression<Func<T, bool>>

x => x.Property == Value

Returns

Distinct<T, TProperty>

Match(Expression<Func<T, object?>>, Coordinates2D, double?, double?)

Specify criteria for matching entities based on GeoSpatial data (longitude & latitude)

TIP: Make sure to define a Geo2DSphere index with DB.Index<T>() before searching

Note: DB.FluentGeoNear() supports more advanced options

public Distinct<T, TProperty> Match(Expression<Func<T, object?>> coordinatesProperty, Coordinates2D nearCoordinates, double? maxDistance = null, double? minDistance = null)

Parameters

coordinatesProperty Expression<Func<T, object>>

The property where 2DCoordinates are stored

nearCoordinates Coordinates2D

The search point

maxDistance double?

Maximum distance in meters from the search point

minDistance double?

Minimum distance in meters from the search point

Returns

Distinct<T, TProperty>

MatchExpression(Template)

Specify the matching criteria with a Template

public Distinct<T, TProperty> MatchExpression(Template template)

Parameters

template Template

A Template object

Returns

Distinct<T, TProperty>

MatchExpression(string)

Specify the matching criteria with an aggregation expression (i.e. $expr)

public Distinct<T, TProperty> MatchExpression(string expression)

Parameters

expression string

{ $gt: ['$Property1', '$Property2'] }

Returns

Distinct<T, TProperty>

MatchString(string)

Specify the matching criteria with a JSON string

public Distinct<T, TProperty> MatchString(string jsonString)

Parameters

jsonString string

{ Title : 'The Power Of Now' }

Returns

Distinct<T, TProperty>

Option(Action<DistinctOptions>)

Specify an option for this find command (use multiple times if needed)

public Distinct<T, TProperty> Option(Action<DistinctOptions> option)

Parameters

option Action<DistinctOptions>

x => x.OptionName = OptionValue

Returns

Distinct<T, TProperty>

Property(Expression<Func<T, object?>>)

Specify the property you want to get the unique values for (as a member expression)

public Distinct<T, TProperty> Property(Expression<Func<T, object?>> property)

Parameters

property Expression<Func<T, object>>

x => x.Address.Street

Returns

Distinct<T, TProperty>

Property(string)

Specify the property you want to get the unique values for (as a string path)

public Distinct<T, TProperty> Property(string property)

Parameters

property string

ex: "Address.Street"

Returns

Distinct<T, TProperty>