分页支持 - ADO.NET 实体框架和 LINQ
通过 ADO.NET EF 和 LINQ 提供什么样的分页支持?
“前 10 个”精选是什么样子的?
“下一个 10”选择?
What kind of paging support is offered through ADO.NET EF and LINQ?
What does a "first 10" Select look-like?
A "next 10" Select?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如其他人在这里所解释的, Take() 和 Skip() 就是您所需要的。
他们会切分结果集来为您提供您想要的页面。
您必须以某种方式维护 PageIndex 和 PageSize 信息,以便在运行查询时可以传递它们。
例如,如果您的数据访问是通过 Web 服务完成的,您将同时传递索引/大小作为您的过滤条件,并在您的客户端(应用程序或页面,如果是网站)中维护这些值。
没有开箱即用的“用于分页的状态迭代器”,如果这就是您正在寻找的...
此外,如果您正在实现“标准分页”构造,则需要在限制之前获取记录总数您的查询,您可以这样做,假设您的函数以某种方式获取 PageSize 和 PageIndex 作为参数:
As the others have explained here, Take() and Skip() are what you need.
They will chop the result set to get you the page you want.
You have to maintain the PageIndex and PageSize information somehow so that you can pass them in when running your query.
If your data access is done through a web service for instance, you would pass the index/size in at the same time as your filtering criteria, maintaining those values in your client (application, or page if it is a website).
There is no "stateful iterator for paging" out of the box, if that is what you are looking for...
Moreover, if you are implementing a "standard paging" construct, you will need to get the total count of records before limiting your query, which you can do like that, assuming your function get PageSize and PageIndex as parameters somehow:
更多此处
More Here
如果您的 Visual Studio 中有可用的 nuget,则可以添加
PagedList
包。看看 此链接位于 asp.net
If you have nuget available in your Visual Studio, you could add
PagedList
package.Have a look at this link at asp.net