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

How to delete the nested document using C#

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

      Hi Everyone,

       

       

      This is my DB structure in Mongo, Now I want to delete the nested document based on the attributeValueId as shown above, I used this code in C# but it's not working

      var filter = Builders<DimensionsDL>.Filter.Eq(item => item.Id, id);
      var update = Builders<DimensionsDL>.Update.Pull("columns.$[].values", Builders<AttributeValueDL>.Filter.Eq(x => x.AttributeValueId, attributeValueId));

      UpdateResult updateResult = _mongoCollection.UpdateOne(filter, update);

       

      I am passing the _id and attributeValueId from UI,

      I am getting the Matched count 1 in the result but ModifiedCount is 0, Please help me on this.

            Assignee:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Reporter:
            lawce Lawrence
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: