title: Mongo C# Driver: Deserialize BsonValue
body: <p>I have a document in mongodb that is structured similar to this:</p>
  
  <pre><code>{
    "_id": "abcdef01234",
    "Name": "Product A",
    "Dimensions": [
      {
        "Height": 32,
        "Width": 64
      },
      {
        "Height": 16,
        "Width": 32
      },
      {
        "Height": 8,
        "Width": 16
      }
    ]
  }
  </code></pre>
  
  <p>I also have a class defined to represent dimensions (the sub document from above)</p>
  
  <pre><code>public class Dimension
  {
    public int Height { get; set; }
    public int Width { get; set; }
  }
  </code></pre>
  
  <p>I am selecting the "Product A" document in this manner:</p>
  
  <pre><code>MongoServer srv = MongoServer.Create(myConnStr);
  BsonDocument doc = srv["db"]["products"].FindOneById(ObjectId.Parse("abcdef01234"));
  BsonValue dimensionsVal = doc["Dimensions"];
  </code></pre>
  
  <p>Now I have a BsonValue named dimensionsVal which is of type BsonArray.  What I really want is a List&lt;Dimension&gt;. How do I convert dimensionsVal to a List&lt;Dimension&gt;?</p>
  
  <p><strong>Edit</strong>
  The dimension class is actually significantly more complex than what I described. I want to keep the Dimensions separate from the Product because of memory concerns. I want to keep the Product in memory, but not the (potentially enormous) list of dimensions. For this reason, I don't want to have a List as a property of the Product class.</p>