InsertMany Document in a MongoDB Collection using C# BsonArray

前端 未结 1 1996
攒了一身酷
攒了一身酷 2021-01-21 12:07

How to Insert more than one document in a Single statement using InsertMany() MongoDB Method in C#

My MongoDB Database and Connections

IMongoClient _clie         


        
相关标签:
1条回答
  • 2021-01-21 12:36

    Off the top of my head, the build error is most probably because the InsertMany method is expecting a collection (IEnumerable,List or Array..) of BsonDocument instead of a BsonArray.

    try :

    var EmpInfoArray = new List<BsonDocument>() { //Changed BsonArray to List<BsonDocument>
        new BsonDocument
        {
            {"EmpID", "100"},
            {"EmpName", "John"},
            {"EmpMobile", new BsonArray
            .
            .
            .
    
    0 讨论(0)
提交回复
热议问题