I have been using the new C# beta driver with LINQ3 support, which is fantastic because it supports much more complex queries than the previous one. But I also noticed that being able to use -1
as a positional operator no longer appears to work when calling UpdateOneAsync
(and probably UpdateManyAsync
and its synchronous cousins).
For example, the following code ran just fine in LINQ2:
await collection.UpdateOneAsync(l => l.Id == another.Id && l.AnArrayMember.Any(l => l.Id == anArrayId),
Builders<ModelClass>.Update.Set(l => l.AnArrayMember.ElementAt(-1).Deleted, true));
This now fails with the error Cannot create field '-1' in element [...]
, where before it successfully translated it into AnArrayMember.$.Deleted
and the Set
command completed fine.
Has the use of this changed? Is there another way to perform this operation with LINQ3?
Thanks in advance for your help!