分页策略 [英] Pagination strategy

查看:109
本文介绍了分页策略的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要分页添加到我的意见。我看着PagedList(包的NuGet),它是非常好的。我与它的问题是,它需要在从数据库中所有记录拉。正如你所看到的,它不会是如果有几百万行的非常有效的。

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.

是否有任何不要求你在所有的数据库中的记录来拉的NuGet寻呼包?
我会写我自己的自定义分页?

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?

推荐答案

做一个快速的搜索 PagedList github上,我居然穿过这句话来自于作者,其特异性回答你的问题:

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

大家好,我是PagedList库的创造者。如果您正在使用PagedList有一个IQueryable(通过实体框架,LINQ2SQL,NHibernate.Linq等)库绝对不会为了得到另一个页面加载整个列表。

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.

如果由于某种原因,你不能使用IQueryable的是有StaticPagedList类,让您无需遍历整个集合生成自己的IPagedList例如:

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-手动分页

来自 http://forums.asp.net/t/1819810.aspx

这篇关于分页策略的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆