简体   繁体   English

与nhibernate分页

[英]pagination with nhibernate

I'm searching best usage pattern in nhibernate pagination primary for asp mvc apps. 我在asp mvc应用程序中搜索nhibernate分页主要的最佳使用模式。 Also, worth to mention is that queries should not use futures bacause there are not supported on all databases. 此外,值得一提的是,查询不应使用期货,因为所有数据库都不支持。

Thanks in advance 提前致谢

Use linq ( session.Query ) with Skip and Take . 使用linq( session.Query )和Skip and Take This should work with most providers and it's probably the simplest way to implement it. 这应该适用于大多数提供商,它可能是实现它的最简单方法。

For example, to take 3rd page of length 10, you'd call: 例如,要获取长度为10的第3页,您可以调用:

 var pageEntities = session.Query<YourEntityType>().Skip( 20 ).Take( 10 );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM