score:7
Accepted answer
from p in names
group p by p.Name into g
order by g.Key
select new { Name = g.Key, Amount = g.Sum(o => o.Amount) }
score:8
var personMoney = names.GroupBy(x=>x.Name)
.Select(x=>new {Name = x.Key, AllMoney = x.Sum(y=>y.Money)})
.OrderByDescending(x=>x.AllMoney).ToList();
Source: stackoverflow.com
Related Articles
- LINQ Source Code Available
- creating Linq to sqlite dbml from DbLinq source code
- How to Select top (5) contributors group by Business type code in c# linq query
- source code for LINQ 101 samples
- c# Linq or code to extract groups from a single list of source data
- Group by in LINQ
- C# Linq Group By on multiple columns
- Convert string[] to int[] in one line of code using LINQ
- LINQ Group By into a Dictionary Object
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Using Linq to group a list of objects into a new grouped list of list of objects
- LINQ - Left Join, Group By, and Count
- How to get first record in each group using Linq
- Linq with group by having count
- Linq code to select one item
- How do I get the MAX row with a GROUP BY in LINQ query?
- LINQ Group By and select collection
- Linq order by, group by and order by each group?
- Linq Query Group By and Selecting First Items
- LINQ Group By Multiple fields -Syntax help
- LINQ to SQL using GROUP BY and COUNT(DISTINCT)
- How are people unit testing code that uses Linq to SQL
- Group Multiple Tables in LINQ
- LINQ group by expression syntax
- LINQ aggregate and group by periods of time
- linq distinct or group by multiple properties
- Group by Weeks in LINQ to Entities
- Linq - Top value from each group
- Nested Group by LINQ
- Counting Using Group By Linq
- Object not set to an instance of an object when using Any()
- Slickest way to put objects into separate lists based on a property value
- Can I use the "Count" property on a Linq result?
- What would be the LINQ solution for this query in c#?
- Linq to SQL Multiple Table Select as Keyvalue Pair
- C# Linq/XML - file not found
- Count minus Count in GroupBy in Linq
- Converting IQueryable<object> results to comma delimited string
- Linq: Get Item which is in a list which also is in a list
- Linq query where any item from List<int> belongs to parameter string[]
- Linq doing a group in a lambda subselect
- How to use null in join condition in linq
- update xml using xdocument
- LINQ - Buidling a search query
- How to get a Lookup as Union of 2 old Lookups?
- How to use a stored procedure in ADO.NET Entity Framework
- LINQ Group By and aggregate fields
- group by and count with linq vb.net
- How to get a custom object out of a List<> with LINQ?
- Composing a where clause in LINQ query at runtime