Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. // Method 1
  2.  
  3. public PartialViewResult feeds(int page)
  4. {
  5. // if page=1 then 10 records if page=2 then 20 records etc.
  6. const int recordsPerPage = 10;
  7. var skipRecords = page * recordsPerPage;
  8. var iefeedss = sqlConnection.Query<thread>("Select * From (SELECT ROW_NUMBER() OVER (order by ...) AS Row,* FROM threads where
  9. .. statement) As threads where Row >= 1 AND Row <=@lower", new {lower = skipRecords }).ToList();
  10.  
  11. }
  12. // Method 2
  13.  
  14. public PartialViewResult feeds(int page)
  15. {
  16. // if page=1 then 10 records if page=2 then 20 records etc.
  17. const int recordsPerPage = 10;
  18. var skipRecords = page * recordsPerPage;
  19. var iefeedss = sqlConnection.Query<thread>("Select top @lower * From my table", new {lower=skipRecords }).ToList();
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement