title: MongoDB - Mapping map-reduce collections in C#
body: <p>I am running a map reduce job that dumps the resulting data into a collection, the elements in the "products" collection look like this (the structure is generated by Mongo and I'm not aware if it can be controlled):</p>
  
  <pre><code>{
      "_id" : { "ProductId" : "1:000001", "ProductTitle" : "Some product with ID 1:000001" }, 
      "value" : { "TotalImpressions" : 3, "TotalClicks" : 40 } 
  }
  </code></pre>
  
  <p>Ideally, I want to map each entry to the following flat object:</p>
  
  <pre><code>public class Product 
  {
      public string ProductId { get; set; }
      public string ProductTitle { get; set; }
      public int TotalImpressions { get; set; }
  }
  </code></pre>
  
  <p>This obviously doesn't work as the serializer looks for properties "id" and "value" at the root level, which don't exist on that class. The workaround I have in place is to model the object as they appear, e.g.:</p>
  
  <pre><code>public class ProductRow
  {
      /* implementation of these objects excluded, but they just reflect the json objects */
      public ProductIdentifier Id { get; set; }
      public Product value { get; set; }
  }
  </code></pre>
  
  <p>Which maps fine, however it's a little verbose and I'd rather avoid having all those extra objects. </p>
  
  <p>Is it possible to configure the BSON deserializer to support this mapping? I've had a look through the documentation, but haven't seen any obvious solution.</p>
  
  <p>NB: I am restricted by working environment to .NET 3.5, so please bear that in mind when considering an answer.</p>