Mongo C#JSON读取器原本需要一个值,但发现"replSetGetStatus" [英] Mongo C# JSON reader was expecting a value but found 'replSetGetStatus'
本文介绍了Mongo C#JSON读取器原本需要一个值,但发现"replSetGetStatus"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到从Mongo C#驱动程序调用Shell命令的正确方法 版本2.7.2
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 res = await _admin.RunCommandAsync<object>("replSetGetStatus");
}
给我一个错误:
JSON reader was expecting a value but found 'replSetGetStatus'
我猜想这根本不是调用shell方法的方法. 有人可以给我提供例子吗?
I'm guessing this simply not the way to call shell methods. Can any one supply me with an example ?
先谢谢了.
推荐答案
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);
这篇关于Mongo C#JSON读取器原本需要一个值,但发现"replSetGetStatus"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文