MongoDB C# driver WithReadPreference vs ConnectionString readprefrence

74 views
Skip to first unread message

siraj....@icloud.com

unread,
Apr 26, 2017, 2:02:12 AM4/26/17
to mongodb-user
I was wondering which setting takes precedence when creating a collection using 
.WithReadPreference(ReadPreference.SecondaryPreferred)
While having a connection string such as :



Craig Wilson

unread,
Apr 26, 2017, 8:22:28 AM4/26/17
to mongodb-user
WithReadPreference will take precedence. Order of precedence for all settings is:

1. Operation
2. Collection Settings
3. Database Settings
4. Connection String

In this case, you are creating a new collection with a specific read preference, so it amounts to a collection setting.

Siraj....@icloud.com

unread,
Apr 26, 2017, 8:53:12 PM4/26/17
to mongodb-user
Cool ! this makes sense. Is this documented somewhere or  maybe it is based on something you've tested ?. I think this definitely should be documented.
Reply all
Reply to author
Forward
0 new messages