We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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?
linq
The text was updated successfully, but these errors were encountered:
Hi, you can do it like this:
// code const custData = [ { Name: 'Brian', PriceUnit: 10, Quantity: 1 }, { Name: 'John', PriceUnit: 10, Quantity: 2 }, { Name: 'Brian', PriceUnit: 10, Quantity: 3 } ]; var custList = from(custData) .select(c => ({ Name: c.Name, Total: c.PriceUnit * c.Quantity })) .groupBy(c => c.Name) .select(g => ({ Name: g.key(), Total: g.sum(c => c.Total) })) .toArray(); console.log(JSON.stringify(custList));
//output // [{"Name":"Brian","Total":40},{"Name":"John","Total":20}]
Sorry, something went wrong.
No branches or pull requests
Hello,
In c# I have the following code:
I tried to reproduce this using
linq
in typescript but I couldn't. Can you help me?The text was updated successfully, but these errors were encountered: