[CSHARP-4498] .Project(c => c.Reference()) not work Created: 30/Jan/23 Updated: 27/Oct/23 Resolved: 30/Jan/23 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | CRUD |
| Affects Version/s: | 2.19.0 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | 宇 杜 | Assignee: | Robert Stam |
| Resolution: | Works as Designed | Votes: | 1 |
| Labels: | Bug | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Description |
SummaryDriver in the new version (2.19.0) MongoDB. Exceptions are thrown when using the Project function. But in version(2.18.0) is normal. MongoDB.Driver.Linq.ExpressionNotSupportedException: Expression not supported: c.Reference(). How to Reproduce_eg: https://github.com/joesdu/MongoIssue_ |
| Comments |
| Comment by 宇 杜 [ 31/Jan/23 ] | |||
|
thanks for your answer. | |||
| Comment by Robert Stam [ 30/Jan/23 ] | |||
|
Thank you for reporting this issue. The problem is this line: https://github.com/joesdu/MongoIssue/blob/master/MongoIssue/Controllers/TestValuesController.cs#L38
is not a valid MongoDB projection because there is no server-side equivalent to the user-defined C# Reference method. This worked in LINQ2 because if something couldn't be translated to server-side MQL we would pull the data down to the client and execute part of the projection client-side. LINQ3 specifically does NOT do that. Note that EF made the same choice some time ago to no longer do any hidden client side evaluation. It is considered an anti-pattern that hides potentially serious performance problems. The solution is to make the client side processing explicit:
| |||
| Comment by 宇 杜 [ 30/Jan/23 ] | |||