Home:ALL Converter>How to add WriteConcern in options in MongoDB driver in C#?

How to add WriteConcern in options in MongoDB driver in C#?

Ask Time:2022-08-29T21:45:55         Author:NewCSharp

Json Formatter

My task is to create the method AddUnacknowledged where I shoud add item to collection with WriteConcern.Unacknowledged in MongoDB 2.17 and C#.

In previous version there was that option and the code was simple:

GetCollection(GetCollectionName(collectionName), federatedDBKey).Add(item, WriteConcern.Unacknowledged);

In current version I am not sure how to do this as I tried:

GetCollection(GetCollectionName(collectionName), federatedDBKey).InsertOne(item, WriteConcern.Unacknowledged);

But WriteConcern.Unacknowledged should be option parameter for method InsertOne() and I can't find how to write this as option parameter. Is this possible?

Author:NewCSharp,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73529828/how-to-add-writeconcern-in-options-in-mongodb-driver-in-c
yy