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

Query: Consider optimizing out superflous Distinct() #8643

Closed
divega opened this issue May 30, 2017 · 0 comments
Closed

Query: Consider optimizing out superflous Distinct() #8643

divega opened this issue May 30, 2017 · 0 comments

Comments

@divega
Copy link
Contributor

divega commented May 30, 2017

Distinct() is superfluous if applied to a superset of the key properties of a single query source. A query like this:

var query = context.Products
    .OrderBy(p => p.UnitPrice ?? 0)
    .Skip(5)
    .Take(15)
    .Distinct()
    .Take(5);

Could even be reduced to:

var query = context.Products
    .OrderBy(p => p.UnitPrice ?? 0)
    .Skip(5)
    .Take(5);
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