title: MongoDB Map class from nested elements in C#
body: <p>I've registered a class to pull addresses out of the a restaurants collection:</p>
  
  <pre><code>BsonClassMap.RegisterClassMap&lt;RestaurantAddress&gt;(map =&gt;
  {
      map.MapMember(c =&gt; c.Id).SetElementName(("_id"));
      map.MapMember(c =&gt; c.Building).SetElementName("address.building");
      map.MapMember(c =&gt; c.Street).SetElementName("address.street");
      map.MapMember(c =&gt; c.ZipCode).SetElementName("address.zipcode");
  });
  </code></pre>
  
  <p>The Mongo document looks like:</p>
  
  <pre><code>{
      "_id" : ObjectId("56bb82621ff72e0d9ba267cb"),
      "address" : {
          "building" : "6409",
          "coord" : [ 
              -74.005289, 
              40.628886
          ],
          "street" : "11 Avenue",
          "zipcode" : "11219"
      },
      "borough" : "Brooklyn",
      "cuisine" : "American ",
      "grades" : [ 
          {
              "date" : ISODate("2014-07-18T00:00:00.000Z"),
              "grade" : "A",
              "score" : 12
          }, 
          {
              "date" : ISODate("2013-07-30T00:00:00.000Z"),
              "grade" : "A",
              "score" : 12
          }
      ],
      "name" : "Regina Caterers",
      "restaurant_id" : "40356649"
  }
  </code></pre>
  
  <p>When I get the document, the nested elements are all null though:</p>
  
  <pre><code>[Test]
  public void DeserializeToAddress()
  {
      var collection = _database.GetCollection&lt;RestaurantAddress&gt;("grades");
  
      var address = collection.Find(a =&gt; a.Id == new ObjectId("56bb82621ff72e0d9ba267cb")).Limit(1).Single();
  
      Assert.That(address.Id, Is.Not.Null);
      Assert.That(address.Building, Is.Not.Null);
      Assert.That(address.Street, Is.Not.Null);
  }
  </code></pre>
  
  <p>How should I be referencing nested elements?</p>
  
  <p>The class to serialize into is:</p>
  
  <pre><code>internal class RestaurantAddress
  {
      public ObjectId Id { get; set; }
      public string Building { get; set; }
      public string Street { get; set; }
      public string ZipCode { get; set; }
      public Point CoordsPoint { get; set; }
  }
  </code></pre>
  
  <p>Currenlty, I don't have anything for hyrating the <code>CoordsPoint</code> object.  That's for a later excercise.</p>