DataTable Streamlining

@pzgqq414
welcome to the forum
we can do it with the help of group by:

  • assign activity
    left side: dtResult | DataType: DataTable
    right side: YourDataTableVar.Clone

  • assign activity
    left side: dtResult | DataType: DataTable
    Right side:

(From d in YourDataTableVar.AsEnumerable
Group d by k1=d(0).toString.Trim, k2=d(1).toString.Trim into grp=Group
let sm = grp.Sum(Function (x) CInt(x(2)toString.Trim))
let ra = new Object(){k1, k2, sm}
Select r= dtResult.Rows.Add(ra)).CopyToDataTable