C
C#14mo 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
Denis14mo ago
What is your goal? On which property do you wish to group the items? And what values do you want to aggregate?
Accord
Accord14mo 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.