Skip to content
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

Repeated statement in the ORDER BY clause instead of referring to the alias in the SELECT #23058

Closed
kresimirlesic opened this issue Oct 20, 2020 · 1 comment

Comments

@kresimirlesic
Copy link

EF core repeats the SQL statement in the order by section instead of referring to the alias.

This can cause duplicate branches (possibly complex) in the execution plan which can easily be avoided using aliases.

Example:

db.Users.Select(x => new { OrderProperty = (complex subquery).Count() }).OrderBy(x => x.OrderProperty)

would be translated to something along:

select (complex sql) from Users
order by (complex sql)

@kresimirlesic kresimirlesic changed the title Repeated statement in the ORDER BY instead of referring to the alias in the SELECT Repeated statement in the ORDER BY clause instead of referring to the alias in the SELECT Oct 20, 2020
@maumar
Copy link
Contributor

maumar commented Oct 21, 2020

dupe of #18775

@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants