In MongoDB 3.0 with the C# 2.0 driver, how do you get a distinct list of values using DistinctAsync
from a document's array of sub documents?
I'm looking for the C# equivalent of this in the shell:
db.cars.distinct("parts.name", {"make":"Ford"})
After admitting defeat, I resorted to this shell-ish code:
var distinctParts = await db.RunCommandAsync<BsonDocument>(new BsonDocument {
{ "distinct", "cars"},
{"key", "parts.name"},
{"query", new BsonDocument { { "make", "Ford" }} } });
Thanks!