Hello,
I am new in MongoDB.
The InsertOne And InsertMany return null,
How can I be sure data were inserted ?
Hello,
I am new in MongoDB.
The InsertOne And InsertMany return null,
How can I be sure data were inserted ?
Hi @omid_mirzaei, welcome!
For write operations such as InsertOne
and InsertMany
, you need to catch for MongoWriteException. There are two properties of this exception:
For more information please see: MongoDB .NET/C# driver: Write Exceptions and MongoDB .NET/C# driver WriteConcern.
I would also suggest to review Write Concern concept in the documentation to understand the concept of write acknowledgement.
I would recommend to enrol in MongoDB free online courses to learn more about MongoDB. Especially M220N: MongoDB for .NET developers to learn the essentials .NET application development. The next session starts soon on April 28th.
Regards,
Wan.