i'm trying to update an item in voteResultList by matching item's 'voteId' field.
the document:
{
voteDocumentId: "....",
voteResultList: [
{
voteId: "....",
voteResult: "NA"
},
{
voteId: "....",
voteResult: "Against"
}
....
]
}
if in mongo i can use this command and it works correctly.
db.getCollection('VoteCollection').update({'voteDocumentId': '....', 'voteResultList.voteId': '....'},{'$set': {'voteResultList.$.voteResult': 'Approve'}})
in csharp code using csharp mongo driver, i generated a filter bson document from this json document
{'voteDocumentId': '....', 'voteResultList.voteId': '....'}
then i generated a update bson document by this code
Builders<BsonDocument>.Update.Set("voteResultList.$.voteResult", "Approve")
but apparently i'm not doing it correctly, because after calling MongoCollection.UpdateMany(filter, update), mongoUpdateResult.ModifiedCount = 0, and nothing changes in mongodb document.
so what is the correct way of doing this?
Thanks!