Path: redb/redb.Examples/Examples/E158_Parentheses.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/E158_Parentheses.cs ---- using System.Diagnostics; using redb.Core; using redb.Examples.Models; using redb.Examples.Output; namespace redb.Examples.Examples; /// /// Demonstrates parentheses for operation priority in Where clause. /// Calculates monthly salary (annual / 12) and filters employees earning over $7,000/month. /// Pro feature: server-side arithmetic with correct operator precedence. /// [ExampleMeta("E158", "Where - Parentheses Priority", "Query", ExampleTier.Pro, 158, "Arithmetic", "Parentheses", "Priority", RelatedApis = ["IRedbQueryable.Where"])] public class E158_Parentheses : ExampleBase { public override async Task RunAsync(IRedbService redb) { var sw = Stopwatch.StartNew(); // Find employees with monthly salary > $7,000 // Parentheses ensure division happens first: (Salary / 12) > 7000 var query = redb.Query() .Where(e => (e.Salary / 12m) > 7000m) .Take(100); // Uncomment to see generated SQL: // var sql = await query.ToSqlStringAsync(); // Console.WriteLine(sql); var results = await query.ToListAsync(); var totalCount = await redb.Query() .Where(e => (e.Salary / 12m) > 7000m) .CountAsync(); sw.Stop(); var first = results.FirstOrDefault(); var monthly = first?.Props.Salary / 12m ?? 0; return Ok("E158", "Where - Parentheses Priority", ExampleTier.Pro, sw.ElapsedMilliseconds, totalCount, [$"Filter: (Salary / 12) > 7,000 (monthly)", $"Found: {totalCount} employees", $"First: {first?.Props.FirstName}, Monthly: ${monthly:N0}"]); } }