C
C#2y ago
Dyad

❔ Aggregate Group By Functions on Items

``` var items = new [] { new Item { Year = 2021, Quarter = "Q1", Collection = "Modern", Price = 10 }, new Item { Year = 2021, Quarter = "Q2", Collection = "Antique", Price = 20 }, new Item { Year = 2021, Quarter = "Q3", Collection = "Modern", Price = 30 }, new Item { Year = 2021, Quarter = "Q4", Collection = "Modern", Price = 40 }, new Item { Year = 2022, Quarter = "Q1", Collection = "Antique", Price = 50 }, new Item { Year = 2022, Quarter = "Q2", Collection = "Modern", Price = 60 }, ... } var groupBys = new []{ x => x.Year, x => x.Quarter, x => x.Collection } //How to do this part? //Or is there a better way? var result = groupBys.Aggregate(items, (accumulator, groupBy) => accumulator.GroupBy(groupBy))
2 Replies
Denis
Denis2y ago
What is your goal? On which property do you wish to group the items? And what values do you want to aggregate?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server