LinQ to group by with two columns and count

prepare an empty datatable with 3 cols: Day, Time, Count - w.g. with Build DataTable - dtResult

Assign Activity:
dtResult =

(From d in yourOriginDataTable.AsEnumerable
Group d by k1=d("Col1Name").toString.Trim, k2=d("Col2Name").toString.Trim into grp=Group
Let ra = new Object(){k1,k2, grp.Count}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable

In case that the Timing needs a more detail analysis have a look here for some debugging / analysis techniques:

1 Like