Mongo C# JSON reader was expecting a value but found 'replSetGetStatus'

后端 未结 1 1004
悲&欢浪女
悲&欢浪女 2020-12-21 12:43

I was unable to find the proper way to call shell command from Mongo C# driver version 2.7.2

  public async Task RsStatus()
  {
     var          


        
相关标签:
1条回答
  • 2020-12-21 13:13

    db.adminCommand function expects and object to be passed as a parameter (here) so you can take advantage of BsonDocumentCommand generic type and also get a result as a BsonDocument, try:

    var command = new BsonDocumentCommand<BsonDocument>(
                        new BsonDocument() { { "replSetGetStatus", 1 } });
    
    var res = await _admin.RunCommandAsync<BsonDocument>(command);
    
    0 讨论(0)
提交回复
热议问题