Reputation: 55
I am trying to detect if a server in a replica set is a master or slave node using the official MongoDB C# driver. I can't seem to find anything corresponding to the isMaster() method (used in the shell) in the driver. Isn't there any way to detect if a server is master from C#?
Upvotes: 1
Views: 818
Reputation: 5126
If you have a MongoServer s
, I believe you can just say
s.Instance.IsPrimary
or
s.Instance.IsSecondary
if I'm reading the API doc correctly.
Upvotes: 1