i have a datatable:
+----------+--------+
| Rep Name | Volume |
+----------+--------+
| Alex | 9 |
| Alex | 1 |
| Alex | 3 |
| Liza | 24 |
| Liza | 17 |
| Pam | 0 |
| Pam | 6 |
+----------+--------+
i am sending ONE email for every UNIQUE person in REP NAME
example:
Hi Alex, Today your volume was 9, and 1, and 3.
next email:
Hi Liza, Today your valume was 24, and 17.
i would like to know the easiest way to loop through the datatable on unique values of REPNAME
something like:
var DistinctList = datatable123.Select(x=> x.repname).Distinct();
and then i would loop through DistinctList ?
You should use
GroupByfor this task.Update: I’ve rewritten the code so you can now use it with your
DataTable.