InsertMany Document in a MongoDB Collection using C# BsonArray

前端 未结 1 2017
攒了一身酷
攒了一身酷 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() { //Changed BsonArray to List
        new BsonDocument
        {
            {"EmpID", "100"},
            {"EmpName", "John"},
            {"EmpMobile", new BsonArray
            .
            .
            .
    

    0 讨论(0)
提交回复
热议问题