[CSHARP-4079] Implement positional update operators in LINQ3 Created: 24/Feb/22 Updated: 15/Dec/23 Resolved: 24/Mar/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | LINQ3 |
| Affects Version/s: | 2.14.0 |
| Fix Version/s: | 2.16.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | James Kovacs | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Epic Link: | CSHARP-3615 | ||||||||||||||||
| Description |
|
In LINQ2, you could use the magic number -1 to indicate use of the positional operator, but this no longer works in LINQ3. When calling UpdateOneAsync, UpdateManyAsync, and related operations, the following code works in LINQ2, but fails in LINQ3:
In LINQ3 this fails with the error "Cannot create field '-1' in element [...]". In LINQ2 it successfully translated it into "AnArrayMember.$.Deleted" and the Set command completed fine. |
| Comments |
| Comment by Paul Bowden [ 15/Dec/23 ] | |||
|
An issue that I've come across with this change is that I must now add a reference to the MongoDB library when I didn't need to before as my data layer was abstracted in my business logic. I can't think of a workaround to this, so have had to add the reference which is a bit annoying. | |||
| Comment by Githook User [ 24/Mar/22 ] | |||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||
| Comment by Robert Stam [ 21/Mar/22 ] | |||
|
-1 was not a good choice as way to represent the positional operator. In LINQ3 we are going to be using custom extension methods instead to represent the three different kinds of positional operators available in update specifications:
|