Table of Contents

Class SortDefinitionBuilder<TDocument>

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

A builder for a SortDefinition<TDocument>.

public sealed class SortDefinitionBuilder<TDocument>

Type Parameters

TDocument

The type of the document.

Inheritance
SortDefinitionBuilder<TDocument>
Inherited Members

Methods

Ascending()

Creates an ascending sort on a value rather than on a field of a document. For example, "$sort : 1". This is used when sorting primitive values like strings or numbers, but can also be used to sort whole documents.

Ascending(FieldDefinition<TDocument>)

Creates an ascending sort based on a specific field within the document. For example, "$sort : { field : 1 }". This is used when values are documents, and you want to sort by a particular field's value.

Ascending(Expression<Func<TDocument, object>>)

Creates an ascending sort based on a specific field within the document. For example, "$sort : { field : 1 }". This is used when values are documents, and you want to sort by a particular field's value.

Combine(params SortDefinition<TDocument>[])

Creates a combined sort.

Combine(IEnumerable<SortDefinition<TDocument>>)

Creates a combined sort.

Descending()

Creates a descending sort on a value rather than on a field of a document. For example, "$sort : -1". This is used when sorting primitive values like strings or numbers, but can also be used to sort whole documents.

Descending(FieldDefinition<TDocument>)

Creates a descending sort based on a specific field within the document. For example, "$sort: { field: -1 }". This is used when values are documents, and you want to sort by a particular field's value.

Descending(Expression<Func<TDocument, object>>)

Creates a descending sort based on a specific field within the document. For example, "$sort: { field: -1 }". This is used when values are documents, and you want to sort by a particular field's value.

MetaSearchScoreAscending()

Creates a ascending sort on the computed relevance score of atlas search.

MetaSearchScoreDescending()

Creates a descending sort on the computed relevance score of atlas search.

MetaTextScore(string)

Creates a descending sort on the computed relevance score of a text search. The name of the key should be the name of the projected relevance score field.