I have a table with a primary key and row key column. The data looks like below. The data has already been loaded into a table that is a collection.
Primary Key Row Key
01000100001 000001 - Subject ID=1, Book ID=1, Chapter ID=1 and Page ID=1
01000100001 000002 - Subject ID=1, Book ID=1, Chapter ID=1 and Page ID=2
01000100001 000003 - Subject ID=1, Book ID=1, Chapter ID=1 and Page ID=3
01000100002 000004 - Subject ID=1, Book ID=1, Chapter ID=2 and Page ID=4
01000100002 000005 - Subject ID=1, Book ID=1, Chapter ID=2 and Page ID=5
01000100002 000006 - Subject ID=1, Book ID=1, Chapter ID=2 and Page ID=6
01000200003 000007 - Subject ID=1, Book ID=2, Chapter ID=3 and Page ID=7
01000200003 000008 - Subject ID=1, Book ID=2, Chapter ID=3 and Page ID=8
02000300004 000009 - Subject ID=2, Book ID=3, Chapter ID=4 and Page ID=9
02000300005 000010 - Subject ID=2, Book ID=3, Chapter ID=5 and Page ID=10
The collection class is called Pages and contains a column called PrimaryKey which is made up of the following:
2 column Subject ID
4 column Book ID
4 column Chapter ID
I need to create a report that looks something like the following and I am wondering
if and how I could create a query for this with LINQ.
Subject Books Chapters Pages
01 2 3 8
02 1 2 2
Any suggestions on how I could do this would be much appreciated.
You can use the group by and sum features the linq query would look something like this:
Sorry that I don’t have visual studio available right now, but this should give you a pretty good start.