Wednesday, 21 August 2013

How to use Group By, Sum, and Contains in a single LINQ query?

How to use Group By, Sum, and Contains in a single LINQ query?

I'm trying to build a LINQ query but I'm not very experienced with it.
So far I have this:
int someShiftAreWanted =
(from allRows in aSelectedDataRowList
group allRows by new { Availability = allRows.Avail.Contains("WANTED") }
into allRowGroup
//where allRowGroup.Sum >= 1
select 1).Sum();
My goal is to set my variable someShiftAreWanted to the number of rows
that contain the string "WANTED" in the column Avail.

No comments:

Post a Comment