score:2
Accepted answer
var refactoredresults = vehiclesales
.groupby(s => s.category)
.select(g => new stackedcolumnchart
{
category = g.key,
values = g.select(s => s.value).tolist()
})
.tolist();
Source: stackoverflow.com
Related Query
- C# Linq - Refactoring ForEach Loop with Sub List
- Replace foreach loop with linq
- Simplifying a foreach loop with LINQ (selecting two objects in each iteration)
- Use Linq to flatten a nested list instead of a foreach loop
- C# For Loop with LIST using LINQ
- nested foreach as LINQ with chained linked List
- How to remove selected data that found on another list and take last 6 id through LINQ without foreach loop
- Compare items in two lists and replace foreach loop with LINQ
- List loop operations with linq
- Remove Items from sub list matching another sub list with Linq
- Linq to format a list of items to replace foreach loop
- Is it faster to use LINQ to get a row from a List or a foreach loop
- Loop through List with Linq condition
- foreach loop with conditions on a List object's attribute
- Replacing foreach on a list with LINQ
- How can I convert Foreach loop with Linq expression OR AsEnumerable in C#.net?
- linq foreach item in list with more than one matching element
- how to turn nested foreach loop with C# linq
- C# LINQ Find List Inside Another List, Better way to code this than a foreach loop
- Convert foreach loop with repeater in linq
- How to Merge two sub list with linq
- Getting rid of outer foreach loop using linq or lambda and ensuring no duplicates are added to list
- How to filter list with linq for sub list?
- Creating sub lists with objects of the same attribute from a list using LINQ
- List Parameter's object name gets Prefixed with @ outside of ForEach Loop
- How to convert foreach loop with a switch statement into LINQ
- Linq query with Groupby Select and foreach loop
- Split List into Sublists with LINQ
- Create a list from two object lists with linq
- Select multiple records based on list of Id's with linq
More Query from same tag
- C# Using .Contains on a RadComboboxItem searching for a string
- Use a filter in an outer join in linq
- LINQ error- cannot covert IEnumerable<IEnumerable<object>> to IEnumerable<object>
- How do I order an underlying child collection of a parent class in LINQ lambda
- Search List content using Linq
- Determine table during runtime with Linq
- How to add a row number column in linq
- Unable to determine SQL type for... when creating tables with LinQ
- How to map data to class structure using linq?
- Handle null element in linq
- LINQ-to-SQL IN/Contains() for Nullable<T>
- Is there a way to use Any() in this LINQ query?
- converting linq result to dictionary<string, int>
- Dynamic LINQ: Compare date between today and four weeks ago
- How to use IQueryable types in DataGridViewColumnCollection in WinForm
- Use Linq to shortlist parent records by using Entity Framework relations
- Read Parent nodes only from XML using LINQToXML
- More efficient Linq to SQL
- Help with creating an object out of xml data with nested elements
- LINQ Outputting The Values Twice in DataGrid
- Use LINQ to concatenate multiple rows list with same value into single row
- CsvHelper - Split output files
- Use LINQ to include items within a range
- Get parent count that has a child with where condition
- LINQ List overwrites previous value instead of setting new one
- EF6 - Generating unneeded nested queries
- How to use dynamic linq to query through nested arrays?
- Calendar ID in linq
- Reverse group by linq
- Entity Framework Include syntax