Path: redb/redb.Examples/Examples/E073_AllAsync.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/E073_AllAsync.cs ---- using System.Diagnostics; using redb.Core; using redb.Examples.Models; using redb.Examples.Output; namespace redb.Examples.Examples; /// /// Check if ALL employees match a condition using AllAsync(predicate). /// Returns true only if every record satisfies the predicate. /// [ExampleMeta("E073", "AllAsync - Check All Match", "Query", ExampleTier.Free, 73, "All", "Predicate", "Validation", RelatedApis = ["IRedbQueryable.AllAsync"])] public class E073_AllAsync : ExampleBase { public override async Task RunAsync(IRedbService redb) { var sw = Stopwatch.StartNew(); // Check if all employees have non-negative salary var allNonNegativeSalary = await redb.Query() .AllAsync(e => e.Salary >= 0); // Check if all high earners (>100k) are over 25 years old var allHighEarnersOver25 = await redb.Query() .Where(e => e.Salary > 100000m) .AllAsync(e => e.Age > 25); // Negative check: are ALL employees millionaires? (expect false) var allMillionaires = await redb.Query() .AllAsync(e => e.Salary > 1_000_000m); // Filter and check both on nested classes: everyone in Berlin lives on floor 1 or higher var allBerlinFloorsValid = await redb.Query() .Where(e => e.HomeAddress!.City == "Berlin") .AllAsync(e => e.HomeAddress!.Building!.Floor >= 1); sw.Stop(); // Count passed validations var checks = new[] { allNonNegativeSalary, allHighEarnersOver25, allBerlinFloorsValid }; var passedCount = checks.Count(c => c); return Ok("E073", "AllAsync - Check All Match", ExampleTier.Free, sw.ElapsedMilliseconds, passedCount, [$"All Salary >= 0: {allNonNegativeSalary}", $"All high earners (>100k) over 25: {allHighEarnersOver25}", $"All millionaires (>1M): {allMillionaires} (expected false)", $"All in Berlin on floor 1 or higher: {allBerlinFloorsValid}"]); } }