Path: redb/redb.Examples/Examples/E082_SkipTake.cs
Snapshot: redb, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb
Page: https://redbase.app/src/dev-2026-12-06/redb/redb.Examples/Examples/E082_SkipTake.cs
----
using System.Diagnostics;
using redb.Core;
using redb.Examples.Models;
using redb.Examples.Output;
namespace redb.Examples.Examples;
///
/// Paginate employees using Skip and Take.
/// Get page 2 with 10 items per page.
///
[ExampleMeta("E082", "Skip/Take - Pagination", "Query",
ExampleTier.Free, 1, "Skip", "Take", "Pagination")]
public class E082_SkipTake : ExampleBase
{
public override async Task RunAsync(IRedbService redb)
{
var sw = Stopwatch.StartNew();
const int pageSize = 10;
const int page = 2; // 0-based would skip 10
var query = redb.Query()
.OrderBy(e => e.LastName)
.Skip((page - 1) * pageSize)
.Take(pageSize);
// Uncomment to see generated SQL:
// var sql = await query.ToSqlStringAsync();
// Console.WriteLine(sql);
var result = await query.ToListAsync();
sw.Stop();
return Ok("E082", "Skip/Take - Pagination", ExampleTier.Free, sw.ElapsedMilliseconds, result.Count,
[$"Page {page}, size {pageSize}", $"Skip {(page - 1) * pageSize}, Take {pageSize}"]);
}
}