2

How do i use the C# driver to sort by a nested object (from a mapreduce query)

{"_id": { "date" : "02/01/2001"} }"

SortBy.Descending("_id")  'Sorts by "_id" descending
SortBy.Descending("???")  'Sorts by "date" descending

But Im not sure what to put in value to make this happen

1 Answer 1

2

In the case you have given, it will not be necessary to specify the nested object since sorting by the _id field will functionally sort on the date contained in that field.

You can however reach into nested objects using the dot notation when needed. This would look like:

SortBy.Descending("_id.date")
Sign up to request clarification or add additional context in comments.

1 Comment

Although this doesn't work in a mapreduce situation it is still the correct way to sort by nested attributes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.