Skip to content

how to use select with chained groupby #89

Open
@lucas-pollus

Description

@lucas-pollus

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions