Details
-
Bug
-
Resolution: Done
-
Critical - P2
-
2.2
-
Client: .Net Driver 2.2.2 on Windows 10 / .Net 4.6.1
Server: 3.2.1 Shard on Debian
Description
Following example shows how to reproduce the Exception
Command find failed: Failed to parse: { find: "bar", filter: {}, skip: 0, readPreference: { mode: "secondaryPreferred", tags: [ { dc: "ny", rack: "1" }, { dc: "sf" } ] }, noCursorTimeout: false, allowPartialResults: false }. Unrecognized field 'readPreference'..
|
Driver from NuGet Package: (Legacy) Official C# driver for MongoDB 2.2.2
var tagSets = new TagSet[]
|
{
|
new TagSet(new [] { new Tag("dc", "ny"), new Tag("rack", "1") }),
|
new TagSet(new [] { new Tag("dc", "sf") })
|
};
|
|
MongoClientSettings clientSettings = new MongoClientSettings
|
{
|
Server = new MongoServerAddress("server"),
|
ReadPreference = ReadPreference.SecondaryPreferred.With(tagSets) <---- Exception
|
//ReadPreference = ReadPreference.SecondaryPreferred <----- Working
|
};
|
|
MongoClient client = new MongoClient(clientSettings);
|
MongoServer server = client.GetServer();
|
MongoDatabase database = server.GetDatabase("foo");
|
MongoCollection<BsonDocument> collection = database.GetCollection<BsonDocument>("bar");
|
|
MongoCursor<BsonDocument> cursor = collection.FindAll();
|
|
foreach (BsonDocument bsonDocument in cursor)
|
{
|
Console.WriteLine(bsonDocument.ToString());
|
}
|