I am building a MVC 2 application with SubSonic 3 - I have tried many differan开发者_StackOverflow中文版t 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?
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:
var SOQuestion= (
from q in repo.All<SOQuestion>()
where tag =="mvc" && user == "me"
orderby p.DateUpdated descending
select p
).Skip(5).Take(10);
精彩评论