Class Distinct<T, TProperty>
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
TAny Entity that implements IEntity interface
TPropertyThe 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
cancellationCancellationTokenAn optional cancellation token
Returns
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
cancellationCancellationTokenAn 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
searchTypeSearchThe type of text matching to do
searchTermstringThe search term
caseSensitiveboolCase sensitivity of the search (optional)
diacriticSensitiveboolDiacritic sensitivity of the search (optional)
languagestringThe 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
templateTemplateA 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
filterFunc<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
expressionExpression<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
coordinatesPropertyExpression<Func<T, object>>The property where 2DCoordinates are stored
nearCoordinatesCoordinates2DThe search point
maxDistancedouble?Maximum distance in meters from the search point
minDistancedouble?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
templateTemplateA 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
expressionstring{ $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
jsonStringstring{ 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
optionAction<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
propertyExpression<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
propertystringex: "Address.Street"
Returns
- Distinct<T, TProperty>