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

Two PagedList improvements #278

Merged
merged 2 commits into from
Jul 12, 2024
Merged

Conversation

adschmu
Copy link
Contributor

@adschmu adschmu commented Jul 12, 2024

Two changes, one is a breaking one (but a reasonable one).

There is not really a point to creating a PagedList without a superset.

If somebody actually desires to have an empty one, he should provide an empty
list.

This is a breaking change. If somebody actually created a PagedList with "null"
for whatever reason, this will now throw an Exception.
This addresses two aspects:

  1. Instead of using AddRange(), just saving the existing List is cheaper.

  2. There is an important difference between an Expression and a method
     delegate (Func<Tin, Tout>). In almost every case, you will need to
     use Expressions with IQueryable and method delegates with IEnumerable.

     In the previous implementation, we threw away the Expression by using
     Compile(). With a real IQueryable, this would mean that processing is moved
     from the DB to client evaluation for anything beyond that point. Hence,
     we change this to use the proper OrderBy overload for Expressions now with
     IQueryable. When a method delegate is provided, we directly assume
     IEnumerable.

     Note that this is NO breaking change, since IQueryable implements
     IEnumerable. However, for a real IQueryable this will now actually work
     on the DB e.g. in an EF Core scenario.
@adschmu
Copy link
Contributor Author

adschmu commented Jul 12, 2024

Since I've started looking at it, I found the issues with Expression.Compile().

In contrast to most of the other stuff we discussed recently which is somewhat cosmetic, this is a functional issue.

This was referenced Jul 12, 2024
@a-gubskiy a-gubskiy merged commit e51f1b2 into dncuug:master Jul 12, 2024
2 checks passed
@adschmu adschmu deleted the pr/pagedlist-improv branch July 12, 2024 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants