Summary
After upgrade the driver version to 3.1.0 the positional update operators “LINQ Expression” used to update a specific item in array do not work anymore:
How to Reproduce
the following code was working to update an item in an array
// code placeholder var builder = Builders<Account>.Filter; var filter = builder.Eq(u => u.AccountId, accountId) & builder.ElemMatch(e => e.PoliciesAcceptingStatus, p => p != null && p.PolicyId == policyStatus.PolicyId); var update = Builders<Account>.Update.Set(u => u.PoliciesAcceptingStatus.FirstMatchingElement(), policyStatus); var result = await AccountsCollection.UpdateOneAsync(filter, update);
I have also changed the update statement to the following using the positional operator with the same exception:
// code placeholder var update = Builders<Account>.Update.Set("policiesAcceptingStatus.$", policyStatus);
above fails with the exception below:
// code placeholder MongoDB.Driver.MongoCommandException: Command update failed: Unknown operator: policyId. at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1[TCommandResult].ProcessResponse (MongoDB.Driver.Core.Connections.ConnectionId connectionId, MongoDB.Driver.Core.WireProtocol.Messages.CommandMessage responseMessage) [0x001c9] in <bd3efda028a746ab87825194d4cf8b0d>:0
Please let me know what has changed in LINQ3 regarding these operators. and how do I fix the above code?