This question involves getting distinct values of a nested document in Mongo DB using C#. I have a collection of documents, each document having the structure:
{
key1: value1,
key2: value2,
key3: {
nestedKey1: nestedValue1,
nestedKey1: nestedValue1
}
}
I need to query a list of distinct nestedKey1 values based on the value of key1. I can do this (using a shell in Robomongo) by using the command:
db.runCommand({distinct:'collection_name', key:'key3.nestedKey1', query: {key1: 'some_value'}})
But how do I achieve this in C# (tutorial here)