How to delete the nested document using C#

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • 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
            Reporter:
            Lawrence
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: