I have a document in mongodb that is structured similar to this:
{
\"_id\": \"abcdef01234\",
\"Name\": \"Product A\",
\"Dimensions\": [
{
\"Heigh
I would declare your class with a Dimensions property of type List
ObjectId productId;
var query = Query.EQ("_id", productId);
var fields = Fields.Exclude("Dimensions");
var product = collection.Find(query).SetFields(fields).FirstOrDefault();
// product.Dimensions will be null because there was no data for it
and when you want to read the full product including all of the Dimensions write this:
ObjectId productId;
var query = Query.EQ("_id", productId);
var product = collection.FindOne(query);
// product.Dimensions will be populated this time
This will be much more efficient than reading the Dimensions into a BsonDocument and converting them to a List