[CSHARP-4443] Support LINQ3 queries against all 3 possible representations of Dictionaries Created: 07/Dec/22 Updated: 30/Jun/23 |
|
| Status: | Backlog |
| Project: | C# Driver |
| Component/s: | LINQ3 |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Unknown |
| Reporter: | Robert Stam | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 3 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Description |
|
For example, a `Dictionary<string, int>` could be represented in 3 ways:
Corresponding to `Documents`, `ArrayOfArrays` and `ArrayOfDocuments`. We should support queries against all 3 representations. |
| Comments |
| Comment by Robert Stam [ 31/Mar/23 ] | ||||||||||||||||||||||||||||||||||||||||
|
I haven't had a chance to figure out exactly what your `OrderByDynamic` code is doing, but I can make the following two high level points: 1. If you are going to generate Expressions yourself you should generate exactly the same thing that the C# compiler would generate. You can write the desired expression in C# and run it in a debugger to see what the C# compiler generated. 2. LINQ queries against MongoDB can sometimes return subtly different results than the same query against Linq to Objects. The overall goal of Linq to MongoDB is to be an easy way to write MongoDB queries, not to return exactly the same results as Linq to Objects. When the results differ it will be because of subtle semantic differences between C# and MongoDB (for example, differing support for string comparisons using collations).
| ||||||||||||||||||||||||||||||||||||||||
| Comment by Manuel Kugelmann [ 31/Mar/23 ] | ||||||||||||||||||||||||||||||||||||||||
|
I guess there are subtle differences in the mapping of the LINQ expression between v2 and v3.
or
or something else I didn't think of ... Only the 2nd works with LINQ2. This code block for namepath ( e.g. Blah.Blubb.Foo.Bar ) driven LINQ based filters works with dictionaries as documents in v2 and not in v3:
I know I could directly build a MongoDB filter, but our codebase above the DB access layer is DB agnostic because we target multiple DB implementations. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 29/Mar/23 ] | ||||||||||||||||||||||||||||||||||||||||
|
Thank you for letting us know you are having an issue with LINQ3. In general LINQ3 has way more functionality than LINQ2, but it is true that there is the occasional area where we have missed something in LINQ3, which we will of course address as we find out about it. I believe that dictionaries represented as documents are already fully supported in LINQ3. This ticket is really just about the other two representations for dictionaries (array of documents and array of arrays). When I get a chance I will confirm that dictionaries represented as documents are already supported. Let us know if you are having any issues with dictionaries represented as documents. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Manuel Kugelmann [ 29/Mar/23 ] | ||||||||||||||||||||||||||||||||||||||||
|
Locked to LINQ V2 because of this. V3 imho is NOT production ready if it has less functionality than V2 ... |