i have an IEnumerable which was created by a query of a table. It contains all the dues records for a particular member.
duesOwed
i need to filter it as follows. I want to group the data by DuesYeaMonth. Thats just a string column in the format 20130701
Year/Month/Day. I only want the rows where the Dues Category code (DuesCatCd) starts with "D" and after they are grouped only those groups where DuesAmount <> 0 and ordered by DuesYearMonth in descending order. So basically i am trying to find the newest dues record still owing and will work my way back to the first.
here is what i have so far. I figure it has to be done in two statements.
var groups = duesOwed.Where(d => d.DuesCatCd.StartsWith("D")).GroupBy(d => d.DuesYearMonth);
now the part i am not sure about
var MostRecordDuesRecord = groups.Where(d => d.DuesAmount != 0).OrderByDescending(d => d.DuesYearMonth);
What is groups though. Visual Studio doesnt seem to think it is a IEnumerable of DuesOwed records because DuesAmount is in red and it doesnt like the parameter to OrderByAscending.