score:3
Accepted answer
This should get you the idea:
new [] {
"010000100001", "010000100001", "010000100001", "010000100002",
"010000100002", "010000100002", "010000200003", "010000200003",
"020000300004", "020000300005" }
.GroupBy(s => new {
Subject = s.Substring(0,2),
Chapter = s.Substring(2,6),
Book = s.Substring(8) });
Edit See a demo live on https://ideone.com/A6RQU
Source: stackoverflow.com
Related Query
- How can I use group in a LINQ expressions to group substrings of a field?
- How can I switch that code to use LINQ
- How can I use external expressions in Linq with EF4 (and LINQKit)?
- How can I use order by and group by in Linq Extraction Method?
- How can I use custom expressions in DevArt LINQ to Entities and also use query comprehension syntax?
- How can I use Linq to get correctly group these results?
- How can I use order by and group by in Linq Extraction Method and With multiple data?
- How can I use ":" in LINQ group by conditions
- How can I use my class properties in my Linq query with group by statement?
- How can I use Linq in a T4 template?
- How can I reuse expressions within LINQ statements?
- How to use Linq to group every N number of rows
- How can I use linq to sort by multiple fields?
- How can I use LINQ to find a DataGridView row?
- How to use distinct with group by in Linq to SQL
- How can I use Linq with a MySql database on Mono?
- How can I use linq to initialize an array of repeated elements?
- How can I use LINQ to project this parent and children object model into a flat, single object?
- How can I use Left join in linq that we use in sql?
- How to pass LinQ Expressions from F# to C# code
- How can I average a DateTime field with a LINQ query?
- How can I use linq to return integers in one array that do not match up with an integer property of another array?
- How can I create a dynamic LINQ query in C# with possible multiple group by clauses?
- How to use Contains() function if field value is null in linq
- How can I use linq to check if an flags/bitwise enumeration contains a type?
- how do i use group by only on date from datetime in LINQ query
- How can I use LINQ to calculate the longest streak?
- How can I group by the difference between rows in a column with linq and c#?
- How can I combine this code into one or two LINQ queries?
- How can I use LINQ to "prune" a dictionary?
More Query from same tag
- How can I see the SQL text that is sent by LINQ to my database?
- Left Joins in LINQ with multiple Critieria?
- Linq custom query with object properties
- Querying Mongo when a document have one to many relationship in a single well structed query using mongo C# driver
- Checking two IEnumerables for equality
- Select data from two tables with Linq/Lambda
- C# LINQ to SQL Invalid Object Name
- Why am I required to reference System.Numerics with this simple LINQ expression?
- Anonymous type in medium trust, works with Reflection not with Expressions
- LINQ to Entities does not recognize method - async operation
- c# Linq - Is this a good design for deleting records?
- Linq to sql - generates wrong sql?
- Update and replace datatable rows value throughout all columns
- Get List<int> from List<Customer> using linq
- LINQ algorithm to create generic table from XML
- entity framework linq include and grouping
- LINQ query expressions and extension methods
- Working with Anonymous Types with Linq in VB, C#
- EF Select records distinct by one field from Entity
- Is there any real difference between "and" and "wheres" in linq
- Delete subjects which isn't selected anymore
- LINQ: get nested arrays based on a groupby?
- Using String.Join for multiple items in a List
- Generating dictionary from elements of XML through LINQ
- How to return LINQ object from method?
- Inner join with linqJS
- Entity Framework 4 Unit of Work / Repository WITHOUT .Query() Lambda
- How can I read a CSV from Webserver using c# with LINQ? (ClickOnce deployment)
- LINQ query string[] group by multiple anonymous columns
- Dynamic LINQ Language Function