score:2
Accepted answer
for the count you just need this query:
int total = pieces
.where(x => x.count > 0)
.groupby(x => new { x.count, x.date, x.description })
.sum(g => g.key.count);
so you can access all key properties of the grouping.
this returns 85 for your initial sample and 108 if you add the new piece.
Source: stackoverflow.com
Related Query
- Grouping using multiple columns, then summing a specific column using method syntax
- C#: LINQ query grouping by multiple columns in data table using Field method
- Using Linq Grouping how to I order by specific Group then remaining Groups descending
- C# SQL/Linq/Entity Framework calculating column totals for multiple columns from large data source
- LINQ Join on multiple columns with different record using extension method syntax
- How do i get specific columns from a thenInclude using Include with Multiple Levels of Properties
- Vb.net LINQ Syntax Group By Multiple Columns using Method Syntax
- How to retrieve multiple column values with same foreign key id using Linq method Syntax in C#?
- Grouping rows in a DataTable by column, then summing the contents of other columns in that group
- datatable sum column and concatenate rows using LINQ and group by on multiple columns
- linq to sql join on multiple columns using lambda
- How to order by multiple columns using VB.Net lambda expressions
- how to group by multiple columns using linq
- Selecting specific columns using linq: What gets transferred?
- c # using linq to group by multiple columns in a datatable
- Using LINQ to get DataGridView row index where first column has specific value
- How to reuse a linq expression for 'Where' when using multiple source tables
- LINQ: How to do JOIN using the linq extension method style on multiple fields?
- Grouping and multiple orderings using Linq to Entities
- LINQ: How to Select specific columns using IQueryable()
- Read all rows of a specific column using LINQ
- Group & Aggregate multiple columns using LINQ
- Is it possible to ignore a list item using the Skip method of the LINQ then apply skip on the list without losing that item?
- LINQ grouping multiple fields only if one of the fields is a specific value
- Problems trying to use GroupBy with multiple properties using the LINQ Method Syntax
- LINQ to SQL join 3 tables and select multiple columns and also using Sum
- Changes(update) not commited to multiple columns using LINQ to SQL
- Update Database using Entity Framework having primary key on multiple Columns
- Problem with simple join by multiple columns in two tables using linq
- Join a table using on multiple columns using a OR syntax
More Query from same tag
- Create a tree structure in linq with a single list source with parent - child as strings of an object
- Get a distinct list of ids from IEnumerable<T>
- Binding an Enum to LINQ and SelectListItem
- ObjectQuery lambda expression for select inside select
- Sort a list based on another list followed by a property on itself with LINQ
- LINQ "OR" in expression
- IEqualityComparer with Linq to XML and Distinct() is not executed in code?
- Finding maximum of Nth elements of a list of lists in C#
- Accessing Elements from multi-level (nested) XML documents in c#
- Transaction and TransactionScope isolation
- How to find highest level descendants with a given name
- Linq statement: Inner function call conflicts with enclosing method name
- How to compare dates in LINQ?
- Use LINQ to collaps multiply collections into one collection
- Create List in Linq query
- Converting linq to non linq
- How does this translate to SQL to LINQ?
- Linq, EF4, Filter data after Linq query
- Dataset to List with Linq
- How to use filter result with list integer in IQueryable
- Group a list into groups of 3 and select max of each group
- Is there any difference in execution for async lambda?
- LINQ - Speeding up query that has a join to a huge table
- Linq : Select multiple values and assign to select with specific option/value
- How can I create a DateTime value in a Linq Query?
- C# ?? operator and ora-12704: character set mismatch
- Append items to an object
- LINQ C#: Get the Distinct TAG NAMES (Not Values) that's common across all child XML elements
- Reusable Linq expression (to be passed to multiple .Where clauses in different parts of project)
- How do I make a LINQ expression to call a method?