-2
- 頁1:開始索引0,限制50
- 第2頁:開始索引49,限制50
- 頁N:開始索引x,極限ÿ
這是對?
context.Products.Where(condition).Skip(x).Take(y);
這是對?
context.Products.Where(condition).Skip(x).Take(y);
要獲取:
所以正確的語法是:
// 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);