[CSHARP-2723] Select() inside Project() does not properly reference the Project lambda variable Created: 31/Aug/19 Updated: 28/Oct/23 Resolved: 13/Oct/21 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq |
| Affects Version/s: | None |
| Fix Version/s: | 2.14.0 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Richard Collette | Assignee: | Robert Stam |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Epic Link: | CSHARP-3615 | ||||||||
| Description |
|
When a Select() is used inside a Project(), and the Select() expression refers to the Project() lambda variable, the generated projection does not properly reference the Project() lambda variable and its properties. Given a local database named "test" and
And query method GetTree()
The following MongoDb aggregate is generated (2 lines commented with // incorrect)
But the proper aggregate would be (2 lines commented with // correct)
Attached is the .NET Core solution, and database archive |
| Comments |
| Comment by Robert Stam [ 13/Oct/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This issue has been fixed in the new LINQ provider (known as LINQ3) which will be included in the upcoming 2.14 release. Configure your MongoClientSettings to use LinqProvider.V3 if you want to use this functionality. To configure a client to use the LINQ3 provider use code like the following
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 13/Oct/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 13/Oct/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'rstam', 'email': 'robert@robertstam.org', 'username': 'rstam'}Message: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 24/Sep/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
With one minor change to the LINQ3 implementation I was able to get this scenario working using LINQ3. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 24/Sep/21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Richard Collette [ 02/Sep/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I attempting to debug, this but having difficult for a couple reasons. It seems the dotnet debugger is crashing (I'm using rider on a Mac). And the code inside AggregateProjectTranslator is recursive (maybe?). It takes a lot to step through it. What I can see definitively at the moment is that in AggregateProjectTranslator, the returned Expression from PipelineBindingContext.Bind() incorrectly maps the "child" lambda parameter to document
The debugger crash I am getting is (and I'm not saying this is a driver issue necessarily):
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Richard Collette [ 31/Aug/19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I just noticed that this may be related to |