Hello,
I have a collection of purchases. Each purchase has an array of subdocuments for the products of the purchase.
I am using the code below to update a property on one of the subdocuments and it works fine most of the time - however in about 2.5% of all cases the update does nothing and the value stays null. If I re-run the program, the update works, so it shouldn’t be a wrong filter definition. Does anyone have a clue?

var filterDefinition = Builders<Purchase>.Filter.And( Builders<Purchase>.Filter.Eq(p => p.Id, purchaseId), Builders<Purchase>.Filter.ElemMatch(p => p.Products, p => p.ProductId == productId) ); var updateDefinition = Builders<Purchase>.Update.Set("Products.$.SomeProperty", value); await _dbContext.Käufe.FindOneAndUpdateAsync(filterDefinition, updateDefinition);