Linq Paging - How to incorporate total record count

Posted by Billy Logan on Stack Overflow See other posts from Stack Overflow or by Billy Logan
Published on 2010-03-31T13:14:46Z Indexed on 2010/03/31 13:33 UTC
Read the original article Hit count: 493

Filed under:
|

Hello everyone, I am trying to figure out the best way of getting the record count will incorporating paging. I need this value to figure out the total page count given a page size and a few other variables.
This is what i have so far which takes in the starting row and the page size using the skip and take statements.

promotionInfo = (from p in matches
orderby p.PROMOTION_NM descending
select p).Skip(startRow).Take(pageSize).ToList();

I know i could run another query, but figured there may be another way of achieving this count without having to run the query twice.

Thanks in advance, Billy

© Stack Overflow or respective owner

Related posts about LINQ

Related posts about linq-to-entities