2017-08-09 30 views

回答

2

要獲取:

  • 第1頁,你需要跳過0,並採取50
  • 第2頁,你需要跳過50,並採取50
  • ...
  • 第N頁你需要跳過(N-1)* 50並取50

所以正確的語法是:

// pageIndex => the page index. page starting at 1. 
// pageSize => the page size. 
context.Products.Where(condition).Skip((pageIndex - 1) * pageSize).Take(pageSize); 

如果頁面從0開始,所以你會做什麼:

context.Products.Where(condition).Skip(pageIndex * pageSize).Take(pageSize); 
相關問題