It will be more efficient to replace:
gdc => gdc.ToList().groupID
gdc => gdc.Key
Other than that, it looks like I would have done.
Alternately, if you are okay with extension methods over LINQ (I personally prefer them), it can be shortened further still with:
var t = data.GroupBy(data => data.groupID).ToDictionary(gdc => gdc.Key, gdc => gdc.ToList());
- Group into a dictionary of elements
- LINQ Group By into a Dictionary Object
- How to split an array into a group of n elements each?
- How to group then select elements into new class in LINQ (C# preferably)
- LINQ method to group collection into subgroups with specified number of elements
- Reading elements into a dictionary object using LINQ
- Using Linq to group a list of objects into a new grouped list of list of objects
- Map two lists into a dictionary in C#
- Transform a DataTable into Dictionary C#
- LINQ Select into Dictionary
- Group a collection and return a Dictionary
- How do I translate this GROUP BY / MIN SQL query into LINQ?
- Converting a resource set into dictionary using linq
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- Grouping lists into groups of X items per group
- Group by key and send values into list using LINQ
- How to convert a 2-d array into a dictionary object
- LINQ query with GROUP BY and Count(*) into Anonymous Type
- Split a list into sublist by checking a condition on elements
- Two arrays into one Dictionary
- Linq - group a list into pairs based on a property
- Linq - group by using the elements inside an array property
- How do I combine the keys and values of a Dictionary into one List using LINQ?
- Left join after a into group in Linq using entity framework (core)
- Coercing a LINQ result list of KeyValuePair into a Dictionary - Missing the Concept
- How to order a list by property and group the elements in HTML Razor?
- LINQ Source Code Available
- How do I order the elements in a group by linq query, and pick the first?
- LINQ: How to Append List of Elements Into Another List
- Is there a way of splitting a C# generic dictionary into multiple dictionaries?
More Query from same tag
- c# Linq cross join rows on same table
- LINQ InvalidOperationException when making a query
- How to get depth of node
- Group By, Take First with a vale from second
- I have a LINQ statement that is partially query and partially method. How can I do this using one or the other?
- LINQ Group by column name passed as parameter - LINQ TO SQL
- How to get a strongly typed linq query of a data table and database
- EF Linq to get latest version of row in table
- Coalescing in LINQ query
- Different ways of using SelectMany()
- Intersect LINQ query
- LINQ Select Many - Modify flattened collection
- comparing datetime less than or equal to not working
- MoreLinq's Scan and For Loop returns different results
- SQLite-net TableQuery<T>.Select() poor performance
- Linq and ListView and Contains
- C# Reactive Extensions (rx) FirstOrDefault enumerates entire collection
- How do I "select null as "Column" Using LINQ in C#
- In a LINQ statement using closures, is it possible to specify a where clause within a closure?
- Linq to Entities, Table per Type and Nullable Foreign Key Relationships
- How to join an entity object with select query in LINQ c#
- Querying nested viewmodels with linq
- overload resolution failed
- GroupBy, then order another list based on group in C#
- 500 Error when converting nullable DateTime to string in IQueryable
- Is there any difference in performance between these two LINQ to SQL queries?
- Paging dynamic query results
- How to read the IntelliSense to use LINQ effectively
- Dynamic Linq to SQL - Where Not Like
- Exact Match Array in Mongo Query