title: C#. Fastest way to save list of Objects to Mongo
body: <p>I have several lists of Objects</p>
  
  <pre><code>List&lt;ObjectClass1&gt; ObjectList1;
  List&lt;ObjectClass2&gt; ObjectList2;
  </code></pre>
  
  <p>I would like to write all objects as JSON to Mongo in the end of test run.
  What is the fastest way to do this?
  I am currently doing this:</p>
  
  <pre><code>IMongoClient client = new MongoClient();
  IMongoDatabase db = client.GetDatabase("MyDB");
  db.CreateCollection("ObjectList1");
  var ObjectList1Collection = db.GetCollection&lt;BsonDocument&gt;("ObjectList1");
  foreach(ObjectClass1 obj in ObjectList1)
  {
     var document = BsonSerializer.Deserialize&lt;BsonDocument&gt;(MyJSONSerializer.Serialize(obj));
     ObjectList1Collection.InsertOneAsync(document);          
  }
  
  db.CreateCollection("ObjectList2");
  var ObjectList1Collection = db.GetCollection&lt;BsonDocument&gt;("ObjectList2");
  foreach(ObjectClass2 obj in ObjectList2)
  {
     var document = BsonSerializer.Deserialize&lt;BsonDocument&gt;(MyJSONSerializer.Serialize(obj));
     ObjectList2Collection.InsertOneAsync(document);          
  }
  </code></pre>