Is there a way in C# to run slaveOk() or SetSlaveOK() before querying a mongodb database? I have access only to a secondary replica (backup). It works fine with Robo T3 if I first run rs.slaveOk(). Installed latest version on MongoDb.Driver through nuget, but I can't see this method available.
Thank you, Radu.
Use:
var clientSettings = new MongoClientSettings();
clientSettings.ReadPreference = ReadPreference.SecondaryPreferred; // or ReadPreference.Secondary
See: https://docs.mongodb.com/manual/core/read-preference
also, you can use slaveok=true
option in a connection string