I have a difficult question. I am looking for the most concise, hardest way to achieve the following:
query = (from book in library.books.OrderBy(x=>x.title) group book by new { title = book.title[0].ToString(), yadiyada="" });
As a result, all the books in the library are grouped by the first letter. Yadiyada is that my group object is not a simple string, but an object.
I am wondering if there is a clean LINQ way of doing this so that the grouping is 'A', 'B', 'C', ... 'Z', but all the rest fall into one group called “123! @ #”.
In other words, I want only one group for all non-alpha characters (A-> Z + Rest).
I can do this in many ways if I get verbose (currently I'm just doing a union of two Linq statements), but that is not the purpose of this question. I am wondering if anyone can come up with a really neat way to do this ...
source share