Efficient pagination using OFFSET-FETCH on SQL Server.
| ID | Name | Category | Price | Stock | Rating | Reviews | SKU |
|---|---|---|---|---|---|---|---|
| 3651 | Mega Clothing Product Classic | Clothing | $728.15 | 296 | ★ 3.8 | 44 | SKU-003651 |
| 3652 | Elite Food & Grocery Product XL | Food & Grocery | $770.19 | 58 | ★ 4.6 | 289 | SKU-003652 |
| 3653 | Standard Sports & Outdoors Product Plus | Sports & Outdoors | $757.34 | 9 | ★ 2.2 | 154 | SKU-003653 |
| 3654 | Ultra Books Product Lite | Books | $609.19 | 310 | ★ 3.9 | 681 | SKU-003654 |
| 3655 | Ultra Sports & Outdoors Product Lite | Sports & Outdoors | $936.16 | 226 | ★ 2.4 | 988 | SKU-003655 |
| 3656 | Elite Automotive Product Classic | Automotive | $294.02 | 136 | ★ 4.1 | 152 | SKU-003656 |
| 3657 | Pro Food & Grocery Product Classic | Food & Grocery | $152.59 | 175 | ★ 2.1 | 491 | SKU-003657 |
| 3658 | Elite Electronics Product Lite | Electronics | $990.84 | 327 | ★ 3.8 | 985 | SKU-003658 |
| 3659 | Standard Clothing Product 2024 | Clothing | $487.98 | 456 | ★ 4.1 | 25 | SKU-003659 |
| 3660 | Mega Health & Beauty Product XL | Health & Beauty | $565.79 | 492 | ★ 3.3 | 252 | SKU-003660 |
| 3661 | Elite Food & Grocery Product 2024 | Food & Grocery | $727.93 | 325 | ★ 1.7 | 501 | SKU-003661 |
| 3662 | Super Home & Garden Product Mini | Home & Garden | $734.87 | 273 | ★ 4.8 | 872 | SKU-003662 |
| 3663 | Ultra Automotive Product Mini | Automotive | $408.77 | 300 | ★ 2.7 | 190 | SKU-003663 |
| 3664 | Deluxe Books Product 2024 | Books | $98.29 | 143 | ★ 3.8 | 460 | SKU-003664 |
| 3665 | Elite Health & Beauty Product XL | Health & Beauty | $524.93 | 196 | ★ 1.4 | 256 | SKU-003665 |
| 3666 | Economy Health & Beauty Product 2024 | Health & Beauty | $349.88 | 353 | ★ 2.0 | 563 | SKU-003666 |
| 3667 | Elite Toys & Games Product Pro | Toys & Games | $858.05 | 0 | ★ 2.2 | 907 | SKU-003667 |
| 3668 | Pro Toys & Games Product Lite | Toys & Games | $653.52 | 483 | ★ 2.4 | 210 | SKU-003668 |
| 3669 | Mega Books Product Lite | Books | $465.80 | 172 | ★ 2.7 | 945 | SKU-003669 |
| 3670 | Professional Sports & Outdoors Product Special Edition | Sports & Outdoors | $679.22 | 72 | ★ 4.5 | 253 | SKU-003670 |
| 3671 | Standard Clothing Product Plus | Clothing | $905.69 | 285 | ★ 4.9 | 324 | SKU-003671 |
| 3672 | Elite Office Supplies Product Pro | Office Supplies | $981.66 | 106 | ★ 3.6 | 472 | SKU-003672 |
| 3673 | Elite Toys & Games Product Lite | Toys & Games | $321.03 | 437 | ★ 4.0 | 224 | SKU-003673 |
| 3674 | Super Health & Beauty Product XL | Health & Beauty | $192.54 | 43 | ★ 1.4 | 983 | SKU-003674 |
| 3675 | Premium Sports & Outdoors Product Special Edition | Sports & Outdoors | $547.61 | 34 | ★ 3.9 | 3 | SKU-003675 |
| 3676 | Standard Office Supplies Product Advanced | Office Supplies | $581.59 | 214 | ★ 2.7 | 669 | SKU-003676 |
| 3677 | Standard Sports & Outdoors Product XL | Sports & Outdoors | $532.20 | 299 | ★ 3.7 | 266 | SKU-003677 |
| 3678 | Super Sports & Outdoors Product 2024 | Sports & Outdoors | $104.21 | 452 | ★ 4.7 | 523 | SKU-003678 |
| 3679 | Mega Electronics Product Special Edition | Electronics | $280.13 | 255 | ★ 2.2 | 844 | SKU-003679 |
| 3680 | Professional Home & Garden Product 2024 | Home & Garden | $906.15 | 284 | ★ 4.9 | 2 | SKU-003680 |
| 3681 | Economy Toys & Games Product XL | Toys & Games | $41.20 | 449 | ★ 1.5 | 750 | SKU-003681 |
| 3682 | Economy Home & Garden Product Max | Home & Garden | $950.60 | 373 | ★ 2.9 | 918 | SKU-003682 |
| 3683 | Premium Home & Garden Product Pro | Home & Garden | $55.72 | 31 | ★ 2.5 | 792 | SKU-003683 |
| 3684 | Super Books Product Lite | Books | $285.13 | 123 | ★ 5.0 | 617 | SKU-003684 |
| 3685 | Premium Sports & Outdoors Product Pro | Sports & Outdoors | $337.90 | 447 | ★ 3.5 | 488 | SKU-003685 |
| 3686 | Elite Clothing Product Lite | Clothing | $651.35 | 55 | ★ 1.9 | 589 | SKU-003686 |
| 3687 | Elite Office Supplies Product Special Edition | Office Supplies | $447.50 | 31 | ★ 4.7 | 661 | SKU-003687 |
| 3688 | Mega Sports & Outdoors Product Mini | Sports & Outdoors | $753.19 | 175 | ★ 4.5 | 762 | SKU-003688 |
| 3689 | Pro Electronics Product Mini | Electronics | $937.09 | 476 | ★ 1.1 | 933 | SKU-003689 |
| 3690 | Standard Clothing Product Pro | Clothing | $893.42 | 79 | ★ 2.0 | 52 | SKU-003690 |
| 3691 | Elite Sports & Outdoors Product Pro | Sports & Outdoors | $948.42 | 7 | ★ 4.9 | 928 | SKU-003691 |
| 3693 | Ultra Books Product Max | Books | $923.36 | 330 | ★ 4.5 | 506 | SKU-003693 |
| 3694 | Premium Books Product Plus | Books | $620.34 | 358 | ★ 2.2 | 348 | SKU-003694 |
| 3695 | Standard Health & Beauty Product Special Edition | Health & Beauty | $356.06 | 411 | ★ 2.8 | 513 | SKU-003695 |
| 3696 | Standard Electronics Product 2024 | Electronics | $327.81 | 399 | ★ 3.6 | 165 | SKU-003696 |
| 3697 | Elite Sports & Outdoors Product Pro | Sports & Outdoors | $933.23 | 100 | ★ 1.8 | 481 | SKU-003697 |
| 3698 | Pro Toys & Games Product Plus | Toys & Games | $709.92 | 103 | ★ 3.8 | 219 | SKU-003698 |
| 3699 | Ultra Toys & Games Product Max | Toys & Games | $796.40 | 334 | ★ 1.5 | 607 | SKU-003699 |
| 3700 | Elite Electronics Product Advanced | Electronics | $166.99 | 137 | ★ 3.8 | 111 | SKU-003700 |
| 3701 | Premium Office Supplies Product Pro | Office Supplies | $980.48 | 15 | ★ 2.7 | 593 | SKU-003701 |
// 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
};
}