Path: redb/redb.Examples/Examples/E123_ListItemArrayAny.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/E123_ListItemArrayAny.cs ---- using System.Diagnostics; using redb.Core; using redb.Examples.Models; using redb.Examples.Output; namespace redb.Examples.Examples; /// /// Query filtering by ListItem array using Any(). /// Shows how to filter objects where any element in ListItem array matches condition. /// Requires E114-E119 to run first. /// [ExampleMeta("E123", "ListItem Array - Any", "List", ExampleTier.Free, 123, "ListItem", "Array", "Any", "Query", RelatedApis = ["IRedbQueryable.Where", "List.Any"])] public class E123_ListItemArrayAny : ExampleBase { public override async Task RunAsync(IRedbService redb) { var sw = Stopwatch.StartNew(); // Query persons where any Role has Value == "Active" var query = redb.Query() .Where(p => p.Roles!.Any(r => r.Value == "Active")) .Take(100); // Uncomment to see generated SQL: // var sql = await query.ToSqlStringAsync(); // Console.WriteLine(sql); var results = await query.ToListAsync(); sw.Stop(); if (results.Count == 0) { return Ok("E123", "ListItem Array - Any", ExampleTier.Free, sw.ElapsedMilliseconds, 0, ["Filter: Roles.Any(r => r.Value == 'Active')", "No matching persons found. Run E119 first."]); } var firstName = results.FirstOrDefault()?.Props?.Name ?? "N/A"; var rolesCount = results.FirstOrDefault()?.Props?.Roles?.Count ?? 0; return Ok("E123", "ListItem Array - Any", ExampleTier.Free, sw.ElapsedMilliseconds, results.Count, [$"Filter: Roles.Any(r => r.Value == 'Active')", $"Found: {results.Count}, First: {firstName} ({rolesCount} roles)"]); } }