Path: redb/redb.Examples/ExamplesEf/E150_ArrayAggregation_ef.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/ExamplesEf/E150_ArrayAggregation_ef.cs ---- using System.Diagnostics; using Microsoft.EntityFrameworkCore; using redb.Examples.Ef; using redb.Examples.Examples; using redb.Examples.Output; namespace redb.Examples.ExamplesEf; /// /// EF Core twin of : SUM and AVG over every element of SkillLevels and the /// employee count. The elements and the employees are two tables, so EF asks twice; redb asks once. /// [ExampleMeta("E150_ef", "EF: Array Aggregation - All Elements", "Analytics", ExampleTier.Free, 1, "EF", "Array", "Aggregation")] public class E150_ArrayAggregation_ef : EfExampleBase { public override async Task RunEfAsync(IDbContextFactory contexts) { var sw = Stopwatch.StartNew(); await using var db = await contexts.CreateDbContextAsync(); var allElements = await db.EmployeeProps_SkillLevels .GroupBy(_ => 1) .Select(g => new { TotalSkillPoints = g.Sum(s => s._value), AvgSkillLevel = g.Average(s => s._value) }) .FirstAsync(); var count = await db.EmployeeProps.CountAsync(); sw.Stop(); return Ok("E150_ef", "EF: Array Aggregation - All Elements", ExampleTier.Free, sw.ElapsedMilliseconds, count, [$"All SkillLevels[]: Sum={allElements.TotalSkillPoints}, Avg={allElements.AvgSkillLevel:F2}", $"Employees: {count}"]); } }