I have a database table with a dataset that contains multiple rows of data as follows
ItemId Code StatusId
-------------------- ---------------------------------------------
62224 NC0860000 8
62225 NC0860000 8
62226 NC0860000 8
62227 NC0860200 5
62228 NC0860000 5
62229 NC0860000 5
62230 NC0860000 5
What I would like to accomplish is an output result as
NC0860000 8 3 (code, status, count)
NC0860000 5 3
I don't fully understand how grouping works in EF. I can get the key and a count of a single group using a query as:
var results = (from ssi in ctx.StageSubmitItems
join s in ctx.StageSubmissions on ssi.SubmissionId equals s.SubmissionId
where s.ContributorCode == contributorId
group ssi.SubmitItemId by ssi.AgencyCode into g
select new {AgencyCode = g.Key, Count = g.Count() }).ToList();
But I can't figure out how to group by code and then by StatusId and then produce a count of the total number of rows by status.
I'd appreciate any suggestions on where to look on how to accomplish this or what I am doing incorrectly in the query.