Open
Description
Hello,
In c# I have the following code:
// customers
// Name: Brian, PriceUnit: 10, Quantity: 1
// Name: John, PriceUnit: 10, Quantity: 2
// Name: Brian, PriceUnit: 10, Quantity: 3
var list = customers
.Select(c => new { c.Name, Total = c.PriceUnit * c.Quantity })
.GroupBy(g => new { g.Name })
.Select(x => new { x.Name, Total = x.Sum(s => x.Total)})
.ToList();
// list
// Name: Brian, Total: 40
// Name: John, Total: 20
I tried to reproduce this using linq
in typescript but I couldn't. Can you help me?
Metadata
Metadata
Assignees
Labels
No labels