[CSHARP-2480] The call is ambiguous between the following methods or properties: 'IMongoCollectionExtensions.FindOneAndReplace<TDocument> Created: 11/Jan/19 Updated: 31/Mar/22 |
|
| Status: | Backlog |
| Project: | C# Driver |
| Component/s: | Command Operations |
| Affects Version/s: | 2.7.2 |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Charles Lindsay | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
C# |
||
| Attachments: |
|
| Description |
|
I'm getting an ambiguous error with the following code but only when I used the FindOneAndReplaceOptions<T> options as outlined in my picture below.
|
| Comments |
| Comment by Robert Stam [ 27/Feb/19 ] | ||||||||||||||
|
FindOneAndUpdate has the same issue. | ||||||||||||||
| Comment by Robert Stam [ 14/Jan/19 ] | ||||||||||||||
|
By the way, the following also compiles:
but results in the other extension method being called. The end result is the same either way. | ||||||||||||||
| Comment by Robert Stam [ 14/Jan/19 ] | ||||||||||||||
|
That's unfortunate... we certainly didn't intend for this call to be ambiguous. The ambiguous call matches both of the following extension methods:
I'm not sure how we will fix this without making a backward breaking change, but I can offer you an immediate workaround. To resolve the ambiguity, simply provide the generic type which will result in only one of the two methods matching, thus resolving the ambiguity:
|