score:5
Accepted answer
you could remove the middle select and just order the groups by the sums and then select the product.
var list = list.groupby(t => t.parentproduct)
.orderby(group => group.sum(t => t.numberoforders))
.select(group => group.key);
Source: stackoverflow.com
Related Query
- Using Linq to GroupBy and Sum datatable
- LINQ Sum Nested collection with GroupBy and OrderByDescending
- Using LINQ on ObservableCollection with GroupBy and Sum aggregate
- EF core Linq groupby and having sum count - could not be translated and will be evaluated locally
- Linq groupby and sum
- c# linq GroupBy and Sum up only the lowerest in each group
- GROUPBY and SUM on List items using LINQ
- How to group multiple lists using LINQ - Sum and GroupBy
- LINQ to Nhibernate (3.0) : GroupBy and Sum in subquery gives NoTImplemented
- Linq Join with GroupBy and Sum
- LINQ GroupBy Source = A Destination = B or Source = B and Destination = A
- LINQ sum and groupby and return empty records?
- Can LINQ GROUPBY and SUM with Dapper achieve this?
- C# Linq nested GroupBy and Sum
- LinQ groupby multiply columns and sum c#
- Linq GroupBy and Sum for MVVM from stored procedure
- LINQ with groupby and count
- Using GroupBy, Count and Sum in LINQ Lambda Expressions
- C# Groupby Linq and foreach
- Linq and conditional sum
- Using LINQ to group by multiple properties and sum
- Multiple group by and Sum LINQ
- Translate SQL to lambda LINQ with GroupBy and Average
- LINQ - GroupBy a key and then put each grouped item into separate 'buckets'
- Linq Query with SUM and ORDER BY
- Operator Overloading and Linq Sum in C#
- LINQ Query with GROUP and SUM
- Difference between Sum and Aggregate in LINQ
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Linq GroupBy and Aggregate
More Query from same tag
- I need help understanding LINQ. Where is my understanding going wrong?
- Swap Attribute in each item in a list c#
- Return value of stored procedure is correct but column values are all NULL
- Linq query in foreach
- How to get a value out of a Span<T> with Linq expression trees?
- How to reference a specific object from a list in a config file using .NET MVC with C#
- Convert list of strings to list of simple objects
- LINQ Query error: Unable to create a constant value of type. Only primitive types or enumeration types are supported in this context
- What is the correct syntax for using an expression in a Linq query?
- IEnumerable<string> => unique string[]
- Null value in linq where clause
- Conditional Record Delete in a Loop
- LINQ Filter rows based on LEFT JOIN
- Getting error when fetching data from Sql server compact using linq
- Linq query - "Where" on List<T> Where reflected property Contains text/value
- Join 3 tables in .net core entity framework
- Find and display surrounded text and highlight search term MVC 5
- How can I create a LINQ-to-SQL statement when I have table name as string?
- condition in include in linq to entities
- Linq Queryable Expression Tree: SqlException: Incorrect syntax near '&'
- How to manually build Expression which will return always true?
- How can I add additional Dictionary object
- Multiply filtering in MongoDB
- Given the following linq queries, which one is 'more performant'?
- Linq to Dynamics - compare two properties in where clause
- How to join parameterized stored procedure with tables in LINQ c#
- without for loop how can is show var type these value in TextBox
- LINQ loop through a collection and append an increment to matching values
- Compare two lists from user
- How do I build a query to select master and last detail (max(Id)) with LiNQ