Pagination strategy [closed]

ε祈祈猫儿з 提交于 2019-12-25 04:00:22

问题


I want to add paging to my Views. I looked into the PagedList (Nuget package) and it's really nice. The problem I have with it, is that it needs to pull in all the records from the database. As you can see, it would not be very efficient if there are millions of rows.

Are there any Nuget Paging packages that don't require you to pull in all the database records? Will I have to write my own custom paging?


回答1:


Doing a quick search for the PagedList github, I actually came across this quote from the author which specifically answers your question:

Hi, I'm the creator of the PagedList library. If you are using PagedList with an IQueryable (via Entity Framework, Linq2Sql, NHibernate.Linq, etc) the library will definitely not load the whole list in order to get another page.

If, for some reason, you cannot use IQueryable there is a StaticPagedList class that will allow you to generate your own IPagedList instance without iterating over the entire collection:

https://github.com/troygoode/pagedlist#example-2-manual-paging

Taken from: http://forums.asp.net/t/1819810.aspx




回答2:


In my experiences, I've always created my own custom paging. It has always worked out better (in terms of flexibility) to just create my own. There is a plug in out there that may help you if you don't want to go that route. I have not used it, but I have looked at the example and it may be something that can work for you.

Ajax Paging With Bootstrap In MVC 4

I would recommend downloading the example project they provide, should be pretty straight forward.



来源:https://stackoverflow.com/questions/19870565/pagination-strategy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!