-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translate Select() with index using ROW_NUMBER #24218
Comments
We currently do not support index based overloads for lambda. There are several cons to having support for it.
context.Set<Customer>().Select(c => new { Customer = c, c.Address }).Where(c => c.Customer.Id == "ALFKI");
// which actually gets converted to following while translating
context.Set<Customer>().Where(c => c.Id == "ALFKI").Select(c => new { Customer = c, c.Address }); Above is useful since
Overall, while there seem to be translation existing the usability of it and value it provides is very minimal, not to mention the high cost it incurs because it is not natural translation for index in SQL. Hence we decided not to support it. We have a tracking item in backlog to provide support for window functions in queries #12747 It will allow you to generate the query the way you want without the cost we translating the indexer in that form implicitly, giving more control over execution and avoiding issues about lambda movements. |
Reopening to reconsider this. For perf reasons, we are now considering doing away with the pending selector logic which moves Select() forward (as part of #32957), which would make at least some of the problems above go away. Thanks for @virzak for re-raising this in #12747 (comment). |
Integrated with EF entities mapping from database based on row number
There is a simply way to translate
IQueryable.Select((source, index) => ... )
into SQL usingrow_number() over ()
And optional actions based on query: SQL case operator or client side transformation.
Just an example
The text was updated successfully, but these errors were encountered: