[CSHARP-2924] Consider adding conversion logic into a generated Project query for Aggregate when it's necessary Created: 05/Feb/20 Updated: 28/Oct/23 Resolved: 16/Feb/22 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Linq, LINQ3 |
| Affects Version/s: | None |
| Fix Version/s: | 2.14.0 |
| Type: | New Feature | Priority: | Major - P3 |
| Reporter: | Dmitry Lukyanov (Inactive) | Assignee: | Unassigned |
| 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 |
|
This ticket is related to the user's question in Currently, this projection logic:
will fail with FormatException, because we're trying to convert a double field from server response to int. We need to consider a convert top-level json node to the generated request, for example, to something like this (added `$toInt`):
It's possible that this ticket will be implemented in the scope of LINQ redesign ticket CSHARP-2608 |
| Comments |
| Comment by James Kovacs [ 16/Feb/22 ] | |||||||||
|
This issue has been fixed in the new LINQ provider (known as LINQ3), which is included in the 2.14 release. Fluent Aggregate uses the configured LINQ provider to support expressions. Adding an integer cast with LINQ3 renders a $convert to integer on the server:
The resulting MQL is:
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
|