Reputation: 19
This is a code segment where I will insert PLC data into MongoDB but I am not sure as to where must WriteConcern be implemented?
var connectionString = "mongodb://10.52.124.186:27017/";
// Establish connection from the client to the server
var client = new MongoClient(connectionString);
var server = client.GetServer();
// Connect to the MongoDB specified for the GDS on the Mongodb
var mongoDB = server.GetDatabase("test_database");
// create a collection called sample
var collection = mongoDB.GetCollection<sample>("sample");
sample a = new sample();
// Access the socket via which PLC has sent the data
a.Parameter = data;
collection.Insert(a);
Upvotes: 1
Views: 538
Reputation: 69683
There are several levels on which you can state your desired default WriteConcern level.
mongoClient.Settings.WriteConcern
laterdatabase.Settings.WriteConcern
collection.Settings.WriteConcern
WriteConcern
object.Each of these settings can of course be overridden by a different setting on a lower level. So which level you choose does depend on what you want to do.
Upvotes: 1