Path: redb/redb.Examples/Examples/E010_WhereSimple.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/E010_WhereSimple.cs
----
using System.Diagnostics;
using redb.Core;
using redb.Examples.Models;
using redb.Examples.Output;
namespace redb.Examples.Examples;
///
/// Example: Simple Where filter by salary.
///
[ExampleMeta("E010", "Where - Filter by Salary", "Query",
ExampleTier.Free, 1, "Where", "Query", "Filter",
RelatedApis = ["IRedbQueryable.Where", "IRedbService.Query"])]
public class E010_WhereSimple : ExampleBase
{
public override async Task RunAsync(IRedbService redb)
{
var sw = Stopwatch.StartNew();
var query = redb.Query()
.Where(e => e.Salary > 75000m)
.Take(100);
// Uncomment to see generated SQL:
// var sql = await query.ToSqlStringAsync();
// Console.WriteLine(sql);
var result = await query.ToListAsync();
sw.Stop();
return Ok("E010", "Where - Filter by Salary", ExampleTier.Free, sw.ElapsedMilliseconds, result.Count,
[$"Filter: Salary > 75000"]);
}
}