LINQ Query to find the first different instances of rows from DT

I have a DataTable with these 2 columns of intereset:

Category Sum
cat1 10
cat1 15
cat2 20
cat2 25
cat3 30
cat3 35

I want to find with LINQ each first row that has a different category than “cat1” and extract the category name and sum.
So to have as output “cat2”-20 and “cat3”-30. This output can be of any kind, dictionary,DT,etc.

Can you help ?

looks like we do it with a group by

Assign activity
LHS: dtResult| datatype: DataTable

(From d in dtData.AsEnumerable
Group d by k=d("Category").toString.Trim into grp=Group
Where Not k.Equals("cat1")
Select r = grp.First()).CopyToDataTable

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.