Efficient pagination using OFFSET-FETCH on SQL Server.
| ID | Name | Category | Price | Stock | Rating | Reviews | SKU |
|---|---|---|---|---|---|---|---|
| 4621 | Ultra Electronics Product Max | Electronics | $744.26 | 428 | ★ 4.9 | 613 | SKU-004621 |
| 4622 | Ultra Books Product Classic | Books | $752.05 | 129 | ★ 1.1 | 3 | SKU-004622 |
| 4623 | Super Books Product Plus | Books | $599.91 | 370 | ★ 4.4 | 243 | SKU-004623 |
| 4624 | Standard Office Supplies Product 2024 | Office Supplies | $609.00 | 319 | ★ 3.0 | 430 | SKU-004624 |
| 4625 | Deluxe Food & Grocery Product Plus | Food & Grocery | $957.04 | 499 | ★ 2.9 | 30 | SKU-004625 |
| 4626 | Professional Home & Garden Product Pro | Home & Garden | $469.36 | 480 | ★ 3.6 | 487 | SKU-004626 |
| 4627 | Economy Home & Garden Product Plus | Home & Garden | $495.46 | 457 | ★ 4.5 | 793 | SKU-004627 |
| 4628 | Pro Books Product Classic | Books | $21.48 | 382 | ★ 4.9 | 997 | SKU-004628 |
| 4629 | Professional Toys & Games Product XL | Toys & Games | $39.29 | 138 | ★ 3.9 | 757 | SKU-004629 |
| 4631 | Ultra Health & Beauty Product Mini | Health & Beauty | $847.20 | 135 | ★ 4.7 | 640 | SKU-004631 |
| 4632 | Deluxe Sports & Outdoors Product Max | Sports & Outdoors | $353.37 | 355 | ★ 3.7 | 535 | SKU-004632 |
| 4633 | Professional Automotive Product Pro | Automotive | $968.61 | 459 | ★ 1.3 | 23 | SKU-004633 |
| 4634 | Standard Home & Garden Product Pro | Home & Garden | $521.08 | 329 | ★ 4.7 | 169 | SKU-004634 |
| 4635 | Premium Clothing Product XL | Clothing | $470.75 | 155 | ★ 2.3 | 640 | SKU-004635 |
| 4636 | Professional Electronics Product Special Edition | Electronics | $870.03 | 487 | ★ 1.9 | 709 | SKU-004636 |
| 4637 | Premium Books Product Classic | Books | $825.85 | 465 | ★ 3.2 | 986 | SKU-004637 |
| 4638 | Elite Office Supplies Product 2024 | Office Supplies | $481.55 | 56 | ★ 3.7 | 282 | SKU-004638 |
| 4639 | Pro Books Product Plus | Books | $645.84 | 492 | ★ 4.9 | 651 | SKU-004639 |
| 4640 | Elite Electronics Product Lite | Electronics | $175.72 | 227 | ★ 1.1 | 356 | SKU-004640 |
| 4641 | Standard Health & Beauty Product Plus | Health & Beauty | $966.27 | 470 | ★ 2.8 | 157 | SKU-004641 |
| 4642 | Professional Office Supplies Product Special Edition | Office Supplies | $165.23 | 332 | ★ 1.4 | 835 | SKU-004642 |
| 4643 | Deluxe Electronics Product Advanced | Electronics | $84.22 | 278 | ★ 2.6 | 782 | SKU-004643 |
| 4644 | Economy Health & Beauty Product XL | Health & Beauty | $968.32 | 300 | ★ 3.3 | 899 | SKU-004644 |
| 4646 | Ultra Clothing Product Mini | Clothing | $692.59 | 57 | ★ 1.4 | 251 | SKU-004646 |
| 4647 | Deluxe Toys & Games Product XL | Toys & Games | $16.29 | 320 | ★ 1.5 | 41 | SKU-004647 |
| 4648 | Professional Office Supplies Product Plus | Office Supplies | $953.05 | 155 | ★ 3.2 | 782 | SKU-004648 |
| 4649 | Super Food & Grocery Product Lite | Food & Grocery | $438.37 | 315 | ★ 1.9 | 276 | SKU-004649 |
| 4651 | Mega Toys & Games Product Mini | Toys & Games | $196.04 | 483 | ★ 2.6 | 698 | SKU-004651 |
| 4653 | Pro Health & Beauty Product Mini | Health & Beauty | $921.87 | 421 | ★ 2.1 | 969 | SKU-004653 |
| 4654 | Economy Clothing Product Lite | Clothing | $525.52 | 20 | ★ 2.6 | 788 | SKU-004654 |
| 4655 | Professional Clothing Product Lite | Clothing | $665.80 | 97 | ★ 3.2 | 527 | SKU-004655 |
| 4656 | Mega Automotive Product Max | Automotive | $442.58 | 366 | ★ 2.3 | 427 | SKU-004656 |
| 4657 | Standard Sports & Outdoors Product Special Edition | Sports & Outdoors | $241.27 | 332 | ★ 3.1 | 882 | SKU-004657 |
| 4658 | Pro Sports & Outdoors Product Plus | Sports & Outdoors | $935.39 | 285 | ★ 3.9 | 201 | SKU-004658 |
| 4659 | Mega Home & Garden Product Max | Home & Garden | $81.36 | 338 | ★ 4.0 | 543 | SKU-004659 |
| 4660 | Economy Electronics Product Max | Electronics | $988.40 | 488 | ★ 3.5 | 758 | SKU-004660 |
| 4661 | Mega Office Supplies Product XL | Office Supplies | $48.19 | 373 | ★ 1.3 | 915 | SKU-004661 |
| 4662 | Premium Home & Garden Product Classic | Home & Garden | $886.31 | 496 | ★ 3.2 | 320 | SKU-004662 |
| 4663 | Deluxe Electronics Product Pro | Electronics | $598.18 | 211 | ★ 4.9 | 553 | SKU-004663 |
| 4664 | Standard Automotive Product Pro | Automotive | $959.37 | 469 | ★ 3.5 | 500 | SKU-004664 |
| 4665 | Pro Electronics Product Special Edition | Electronics | $878.06 | 388 | ★ 4.7 | 269 | SKU-004665 |
| 4666 | Standard Books Product Special Edition | Books | $915.13 | 21 | ★ 2.0 | 876 | SKU-004666 |
| 4667 | Pro Toys & Games Product Mini | Toys & Games | $215.76 | 81 | ★ 2.1 | 114 | SKU-004667 |
| 4668 | Pro Sports & Outdoors Product Pro | Sports & Outdoors | $121.65 | 484 | ★ 2.6 | 36 | SKU-004668 |
| 4669 | Standard Home & Garden Product Mini | Home & Garden | $455.25 | 253 | ★ 2.9 | 9 | SKU-004669 |
| 4671 | Economy Books Product XL | Books | $122.65 | 476 | ★ 1.2 | 814 | SKU-004671 |
| 4672 | Deluxe Clothing Product XL | Clothing | $807.10 | 473 | ★ 4.1 | 303 | SKU-004672 |
| 4673 | Elite Office Supplies Product Pro | Office Supplies | $336.37 | 79 | ★ 2.4 | 552 | SKU-004673 |
| 4674 | Ultra Health & Beauty Product Special Edition | Health & Beauty | $622.29 | 234 | ★ 2.3 | 247 | SKU-004674 |
| 4675 | Super Clothing Product Pro | Clothing | $732.23 | 110 | ★ 3.1 | 564 | SKU-004675 |
// Efficient pagination with Skip and Take
public async Task<PaginatedResult<DemoProduct>> GetPaginatedProductsAsync(int page, int pageSize)
{
// Get total count (cached if possible)
var totalCount = await _context.DemoProducts.CountAsync(p => p.IsActive);
// Get page of results
var items = await _context.DemoProducts
.Where(p => p.IsActive)
.OrderBy(p => p.Id) // Important: Must have ORDER BY for consistent paging
.Skip((page - 1) * pageSize) // OFFSET in SQL
.Take(pageSize) // FETCH NEXT in SQL
.AsNoTracking() // No tracking needed for read-only
.ToListAsync();
return new PaginatedResult<DemoProduct>
{
Items = items,
TotalCount = totalCount,
Page = page,
PageSize = pageSize
};
}