title: MongoDB C# 2.4 - Find distinct values of nested array
body: <p>I have documents that look like below:</p>
  
  <pre><code>{
      "_id" : ObjectId("58148f4337b1fc09b8c2de9k"),
      "Price" : 69.99,
      "Attributes" : [ 
          {
              "Name" : "Color",
              "Value" : "Grey",
          },
          {
              "Name" : "Gender",
              "Value" : "Mens",
          }
      ]
  }
  </code></pre>
  
  <p>I am looking to get a distinct list of Attributes.Name (so if I just had the one document as above, I would get 'Color' and 'Gender' returned).</p>
  
  <p>I was able to easily get what I needed through mongo shell (db.getCollection('myCollection').distinct('Attributes.Name'), but I'm really struggling with the C# driver (version 2.4). Can someone please help me translate the shell command to C#?</p>
  
  <p>I tried something like below (and many variations). I'm new to the Mongo C# driver and am just feeling a bit lost. Any help would be appreciated.</p>
  
  <pre><code>var database = client.GetDatabase("mymongodb");
  IMongoCollection&lt;BsonDocument&gt; collection = database.GetCollection&lt;BsonDocument&gt;("mycollection");
  var filter = new BsonDocument();
  var distinctAttributeNames = collection.Distinct&lt;BsonDocument&gt;("Attributes.Name", filter);
  var tryAgain = collection.Distinct&lt;BsonDocument&gt;("{Attributes.Name}", filter);
  </code></pre>