from r in table.AsEnumerable()
group r by r.Field<int>("ProductId") into g
select new {
ProductId = g.Key,
CountThisWeek = g.Sum(r => r.Field<int>("CountThisWeek")),
CountLastWeek = g.Sum(r => r.Field<int>("CountLastWeek"))
}
You can use CopyToDataTable()
method to create new DataTable
from these anonymous objects.