Path: redb/redb.Examples/Examples/E081_OrderByThenBy.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/E081_OrderByThenBy.cs ---- using System.Diagnostics; using redb.Core; using redb.Examples.Models; using redb.Examples.Output; namespace redb.Examples.Examples; /// /// Sort employees by multiple fields using ThenBy. /// Sort by department, then by salary descending. /// [ExampleMeta("E081", "OrderBy + ThenBy", "Query", ExampleTier.Free, 1, "OrderBy", "ThenBy", "Sort")] public class E081_OrderByThenBy : ExampleBase { public override async Task RunAsync(IRedbService redb) { var sw = Stopwatch.StartNew(); var query = redb.Query() .OrderBy(e => e.Department) .ThenByDescending(e => e.Salary) .Take(100); // Uncomment to see generated SQL: // var sql = await query.ToSqlStringAsync(); // Console.WriteLine(sql); var result = await query.ToListAsync(); sw.Stop(); var first = result.FirstOrDefault(); var info = first?.Props != null ? $"{first.Props.Department}: ${first.Props.Salary:N0}" : "-"; return Ok("E081", "OrderBy + ThenBy", ExampleTier.Free, sw.ElapsedMilliseconds, result.Count, [$"Sort: Department ASC, Salary DESC", $"First: {info}"]); } }