title: MongoDB c# driver RunCommandAsync
body: <p>I would like to run <code>db.printReplicationInfo()</code> from the c# driver.</p>
  
  <p>As far as I can tell, I can only run the commands listed <a href="https://docs.mongodb.org/manual/reference/command/" rel="nofollow noreferrer">here</a> using <code>MongoDatabase.RunCommandAsync</code>.  To do that, I have code that looks like this:</p>
  
  <pre><code>var command = new BsonDocumentCommand&lt;BsonDocument&gt;(new BsonDocument
  {
      {"replSetGetStatus", 1}
  });
  var result = BsonSerializer.Deserialize&lt;ReplicaSetStatus&gt;(
               client.GetDatabase(ADMIN_DATABASE).RunCommandAsync(command).Result);
  </code></pre>
  
  <p>This lets me run the command and deserialize the response into a <code>ReplicaSetStatus</code> object that we've created. (client is an instance of MongoClient).</p>
  
  <p>My question is can I use <code>RunCommandAsync</code> to perform an operation like <code>db.printReplicationInfo()</code>?  What would the command look like?</p>
  
  <p>If not, what is the best way to run an operation like that from c#?</p>
  
  <p>Looks like someone else had a <a href="https://stackoverflow.com/questions/31393329/c-sharp-mongo-runcommandasync">similar question</a>, but didn't get any helpful answers.</p>
  
  <p>Thanks!</p>