title: How to access the first object within a nested BsonArray within a BsonDocument
body: <p>As the title states I'm attempting to access the first object within a nested <code>BsonArray</code>. I'm new to mongodb so still trying wrap my head around it.</p>
  
  <p>Anyways, lets say I have the following data:</p>
  
  <pre><code>{
  "_id" : ObjectId("111111dasd1asdasd1asd1"),
  "data" : [ 
      {
          "name":"John Smith",
          "push ups":20
      },
      {
          "name":"John Smith",
          "push ups":22
      },
      {
          "name":"John Smith",
          "push ups":25
      }
  ]
  }
  </code></pre>
  
  <p>I'm attempting to create a new <code>BsonDocument</code> by taking <code>_id</code> and <code>name</code> where I give the query a parameter for <code>_id</code> but I just grab whatever is in <code>name</code> without giving it a parameter.</p>
  
  <p>ie.</p>
  
  <pre><code>{
    "connect":ObjectId("111111dasd1asdasd1asd1", //assigning the value of id from the original document to this field
    "name":"John Smith"
  }
  </code></pre>
  
  <p>Since my mongo collection is structured so that each <code>Bsondocument</code> only deals with one unique <code>name</code>, I do not want to loop through the <code>data</code> <code>BsonArray</code> of my original document example. I just want to access whatever value <code>name</code> has and move on.</p>
  
  <p>Here is my current code attempting to create a new object from values of <code>id</code> and <code>name</code> from the <code>BsonDocument</code> </p>
  
  <p>(NOTE: This is within a method where an id param is provided).</p>
  
  <pre><code> var query = Query.EQ("_id", id);
   var tempRecord = existing.FindOne(query);
   var record = new
       {
         name = tempRecord["data"]["name"],
         connect = id
       };
   result = record.ToBsonDocument();
  
   return result;
  </code></pre>
  
  <p>At the moment <code>tempRecord</code> is correctly storing the data returned from the query I'm passing it. However how would I properly access the <code>name</code> field of the <code>data</code> array within <code>tempRecord</code>?</p>