MongoDB Driver 2.0 C# is there a way to find out if the server is down? In the new driver how do we run the Ping command?

前端 未结 3 1660
南方客
南方客 2021-01-17 22:59

How do you call the Ping command with the new C# driver 2.0?
In the old driver it was available via Server.Ping()? Also, Is there a way to find

3条回答
  •  忘掉有多难
    2021-01-17 23:32

    You can check the cluster's status using its Description property:

    var state = _client.Cluster.Description.State
    

    If you want a specific server out of that cluster you can use the Servers property:

    var state = _client.Cluster.Description.Servers.Single().State;
    

提交回复
热议问题