Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3724

BulkWriteResult doesn't have UpsertedCount

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: API
    • None

      The BulkWriteResult contains properties like ModifiedCount, InsertedCount, and so on. But it doesn't have UpsertedCount.

      F.e I have list of updating models:

       

       // some method that creates models for updating
       private static UpdateOneModel<Entity> CreateUpdateModel(Record item)
       {
         var filter = Builders<Entity>.Filter.Eq(a => a.Id, item.Id);
         var update = Builders<Entity>.Update
           .Set(x => x.UserName, item.UserName)
            ...
      
         return new UpdateOneModel<Entity>(filter, update)
           {IsUpsert = true};
       }
      

       

      And then call:

      var bulkResult = await _collection.BulkWriteAsync(bulkOps);

       From the bulkResult I cannot understand how much was upserted, moreover, InsertedCount is 0 also.

       

            Assignee:
            mikalai.mazurenka@mongodb.com Mikalai Mazurenka (Inactive)
            Reporter:
            sharok89@gmail.com Max Drachsh
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: