Allow composing LINQ operators on the results of translated methods
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
The return values of methods currently aren't queryable. For example, there are various functions in PostgreSQL which return arrays, and it should be possible to continue composing LINQ operators on the returrn value of such functions, e.g. `Where(b => EF.Functions.Foo(b.x).Count() == 8`). Here, `unnest` would be applied to the function's return value, at which point regular translation of LINQ operators can proceed as usual. There should at least some cases in other providers (especially around JSON functions return arrays) where this would be relevant.
This is non-trivial; we currently support queryability on primitive collections for columns, parameters and constants only. We have preprocessing logic specifically for identifying these cases, and replacing the enumerable version of the LINQ operators (e.g. composed over a column) with matching queryable version; then, during translation, the queryable operators are recognized and translated. It's not clear how we'd make the Count operator queryable in the above code.
A more radical approach - which may be useful for other purposes - would be to do away with enumerable->queryable rewriting altogether, and to support recognizing and translating enumerable operators directly.
Contributor guide
Assessment
This issue has not been assessed yet.