Path: redb/redb.Examples/Examples/E071_AnyAsync.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/E071_AnyAsync.cs ---- using System.Diagnostics; using redb.Core; using redb.Examples.Models; using redb.Examples.Output; namespace redb.Examples.Examples; /// /// Check if any employees exist using AnyAsync(). /// Returns true if at least one record exists. /// [ExampleMeta("E071", "AnyAsync - Check Existence", "Query", ExampleTier.Free, 71, "Any", "Exists", RelatedApis = ["IRedbQueryable.AnyAsync"])] public class E071_AnyAsync : ExampleBase { public override async Task RunAsync(IRedbService redb) { var sw = Stopwatch.StartNew(); // Check if any employees exist (no predicate) var query = redb.Query(); // Uncomment to see generated SQL: // var sql = await query.ToSqlStringAsync(); // Console.WriteLine(sql); var anyExist = await query.AnyAsync(); // Existence within a set filtered by a field two nested classes deep var anyOnTopFloor = await redb.Query() .Where(e => e.HomeAddress!.Building!.Floor == 30) .AnyAsync(); sw.Stop(); return Ok("E071", "AnyAsync - Check Existence", ExampleTier.Free, sw.ElapsedMilliseconds, anyExist ? 1 : 0, [$"Any employees exist: {anyExist}", $"Any living on floor 30: {anyOnTopFloor}"]); } }