Efficient pagination using OFFSET-FETCH on SQL Server.
| ID | Name | Category | Price | Stock | Rating | Reviews | SKU |
|---|---|---|---|---|---|---|---|
| 3755 | Economy Books Product Lite | Books | $212.92 | 467 | ★ 4.4 | 701 | SKU-003755 |
| 3756 | Mega Sports & Outdoors Product Mini | Sports & Outdoors | $525.66 | 471 | ★ 2.8 | 851 | SKU-003756 |
| 3757 | Deluxe Automotive Product Classic | Automotive | $980.32 | 219 | ★ 3.2 | 246 | SKU-003757 |
| 3759 | Super Office Supplies Product Classic | Office Supplies | $204.31 | 439 | ★ 1.8 | 963 | SKU-003759 |
| 3760 | Standard Electronics Product Pro | Electronics | $636.43 | 300 | ★ 4.4 | 924 | SKU-003760 |
| 3764 | Mega Electronics Product Classic | Electronics | $130.72 | 238 | ★ 4.9 | 477 | SKU-003764 |
| 3765 | Pro Electronics Product Plus | Electronics | $835.41 | 203 | ★ 3.8 | 481 | SKU-003765 |
| 3767 | Economy Automotive Product 2024 | Automotive | $899.64 | 222 | ★ 4.1 | 420 | SKU-003767 |
| 3769 | Professional Sports & Outdoors Product XL | Sports & Outdoors | $615.80 | 333 | ★ 2.8 | 409 | SKU-003769 |
| 3770 | Standard Toys & Games Product Mini | Toys & Games | $461.80 | 499 | ★ 2.8 | 326 | SKU-003770 |
| 3772 | Pro Electronics Product Pro | Electronics | $308.59 | 398 | ★ 3.9 | 508 | SKU-003772 |
| 3773 | Deluxe Automotive Product Plus | Automotive | $709.56 | 343 | ★ 2.4 | 890 | SKU-003773 |
| 3774 | Super Sports & Outdoors Product Max | Sports & Outdoors | $590.34 | 261 | ★ 4.0 | 40 | SKU-003774 |
| 3775 | Premium Clothing Product Max | Clothing | $548.85 | 236 | ★ 3.9 | 587 | SKU-003775 |
| 3777 | Super Health & Beauty Product Pro | Health & Beauty | $759.85 | 296 | ★ 1.5 | 675 | SKU-003777 |
| 3779 | Standard Sports & Outdoors Product Pro | Sports & Outdoors | $458.41 | 439 | ★ 1.2 | 179 | SKU-003779 |
| 3780 | Elite Automotive Product Lite | Automotive | $316.28 | 71 | ★ 3.2 | 727 | SKU-003780 |
| 3783 | Super Books Product Max | Books | $405.42 | 47 | ★ 2.7 | 312 | SKU-003783 |
| 3784 | Mega Office Supplies Product Special Edition | Office Supplies | $885.15 | 136 | ★ 2.9 | 572 | SKU-003784 |
| 3785 | Super Food & Grocery Product Lite | Food & Grocery | $512.64 | 234 | ★ 4.6 | 84 | SKU-003785 |
| 3786 | Mega Office Supplies Product Plus | Office Supplies | $500.01 | 53 | ★ 3.1 | 488 | SKU-003786 |
| 3787 | Ultra Office Supplies Product Lite | Office Supplies | $399.84 | 220 | ★ 2.0 | 879 | SKU-003787 |
| 3788 | Economy Office Supplies Product 2024 | Office Supplies | $281.86 | 462 | ★ 4.9 | 742 | SKU-003788 |
| 3789 | Premium Food & Grocery Product Mini | Food & Grocery | $605.81 | 10 | ★ 1.9 | 675 | SKU-003789 |
| 3790 | Premium Clothing Product Classic | Clothing | $906.33 | 113 | ★ 4.1 | 677 | SKU-003790 |
| 3791 | Ultra Office Supplies Product Advanced | Office Supplies | $285.07 | 405 | ★ 1.7 | 894 | SKU-003791 |
| 3792 | Ultra Toys & Games Product 2024 | Toys & Games | $391.34 | 457 | ★ 2.2 | 343 | SKU-003792 |
| 3793 | Professional Toys & Games Product Pro | Toys & Games | $188.86 | 399 | ★ 4.8 | 344 | SKU-003793 |
| 3794 | Premium Toys & Games Product Special Edition | Toys & Games | $948.36 | 328 | ★ 3.8 | 789 | SKU-003794 |
| 3795 | Deluxe Clothing Product XL | Clothing | $127.50 | 474 | ★ 1.9 | 982 | SKU-003795 |
| 3796 | Mega Books Product Special Edition | Books | $568.16 | 294 | ★ 2.8 | 605 | SKU-003796 |
| 3797 | Ultra Home & Garden Product Advanced | Home & Garden | $173.09 | 354 | ★ 5.0 | 633 | SKU-003797 |
| 3798 | Deluxe Office Supplies Product Advanced | Office Supplies | $270.02 | 303 | ★ 1.9 | 159 | SKU-003798 |
| 3799 | Premium Automotive Product Pro | Automotive | $412.88 | 246 | ★ 1.0 | 464 | SKU-003799 |
| 3800 | Professional Books Product 2024 | Books | $253.84 | 444 | ★ 2.5 | 290 | SKU-003800 |
| 3801 | Standard Automotive Product Special Edition | Automotive | $271.97 | 264 | ★ 2.2 | 978 | SKU-003801 |
| 3802 | Standard Office Supplies Product Pro | Office Supplies | $319.29 | 92 | ★ 1.8 | 184 | SKU-003802 |
| 3803 | Standard Food & Grocery Product XL | Food & Grocery | $18.73 | 414 | ★ 4.5 | 563 | SKU-003803 |
| 3804 | Standard Sports & Outdoors Product Classic | Sports & Outdoors | $477.55 | 199 | ★ 3.8 | 351 | SKU-003804 |
| 3805 | Professional Clothing Product Mini | Clothing | $992.70 | 266 | ★ 2.6 | 181 | SKU-003805 |
| 3806 | Ultra Clothing Product Max | Clothing | $809.90 | 71 | ★ 1.7 | 33 | SKU-003806 |
| 3807 | Super Books Product Mini | Books | $22.80 | 126 | ★ 2.1 | 558 | SKU-003807 |
| 3808 | Ultra Toys & Games Product Max | Toys & Games | $95.40 | 224 | ★ 3.9 | 771 | SKU-003808 |
| 3809 | Economy Food & Grocery Product Classic | Food & Grocery | $149.29 | 104 | ★ 3.2 | 895 | SKU-003809 |
| 3810 | Economy Clothing Product Lite | Clothing | $637.25 | 316 | ★ 4.3 | 231 | SKU-003810 |
| 3811 | Premium Toys & Games Product XL | Toys & Games | $850.84 | 194 | ★ 3.4 | 254 | SKU-003811 |
| 3812 | Pro Health & Beauty Product Classic | Health & Beauty | $378.03 | 223 | ★ 3.6 | 237 | SKU-003812 |
| 3813 | Pro Toys & Games Product Plus | Toys & Games | $736.45 | 154 | ★ 4.5 | 918 | SKU-003813 |
| 3814 | Standard Clothing Product Pro | Clothing | $197.02 | 368 | ★ 2.0 | 449 | SKU-003814 |
| 3815 | Standard Health & Beauty Product Classic | Health & Beauty | $742.74 | 384 | ★ 4.1 | 11 | SKU-003815 |
// 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
};
}