title: How do you add a list of bsondocuments as an element of a bsondocument
body: <p>How do I create the following document using the official c# driver?</p>
  
  <pre><code>{
      "name": "John Doe",
      "classess": [
          {
              "classname": "Class1"
          }
          {
              "classname": "Class2"
          }
      ]
  }
  </code></pre>
  
  <p>The below code doesn't work</p>
  
  <pre><code>string cs = "mongodb://localhost";
  MongoServer server = MongoServer.Create(cs);
  MongoDatabase test = server.GetDatabase("test");
  
  MongoCollection&lt;BsonDocument&gt; students = test.GetCollection("students");
  
  BsonDocument doc = new BsonDocument();
  doc.Add(new BsonElement("name", "John doe"));
  
  //Create the list
  List&lt;BsonDocument&gt; classes = new List&lt;BsonDocument&gt;();
  classes.Add(new BsonDocument(new BsonElement("classname","Test1")));
  classes.Add(new BsonDocument(new BsonElement("classname","Test2")));
  </code></pre>
  
  <p>the following line will throw an error for obvious reason.  What is the proper way of doing this?</p>
  
  <pre><code>doc.Add(new BsonElement("classess",classes));
  students.Insert(doc);
  </code></pre>
  
  <p>Thank you.</p>