使用 SubSonic 寻呼
我正在使用 SubSonic 3 构建 MVC 2 应用程序 - 我尝试了许多不同的分页方法,但找不到任何合适的方法。
我有一个基本查询,该查询将传递到一个将循环的视图,并且每次迭代都会调用强类型的部分视图。
var SOQuestion= (
from q in repo.All<SOQuestion>()
orderby p.DateUpdated descending
select p
).Skip(5).Take(10);
我希望能够在适当的地方添加过滤器,例如 tag = "mvc"
和/或 user = "me"
,同时合理地对结果进行分页。
什么解决方案既简单又整洁?
I am building a MVC 2 application with SubSonic 3 - I have tried many differant paging methods and can find nothing that feels right.
I have a basic query that would be passed to a view which would loop and each iteration would call a strongly typed partial view.
var SOQuestion= (
from q in repo.All<SOQuestion>()
orderby p.DateUpdated descending
select p
).Skip(5).Take(10);
I want to be able to add filters where appropriate eg tag = "mvc"
and/or user = "me"
and at the same time page the results sensibly.
What solution is simple and neat?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
where
声明,正如拉撒路所描述的。如果您需要动态执行此操作(即您不知道要提前过滤哪些字段),请查看 动态 Linq 库。
You would use a
where
statement, as Lazarus describes.If you need to do it dynamically (i.e. you don't know which fields you will be filtering on ahead of time), have a look at the Dynamic Linq library.
您可以按如下方式执行此操作:
You can do that as follows: