C# LINQ to DATASET Grouping with a total -
i have datatable in data set. table has 3 columns , not grouped.
table1 field1 string field2 datetime field3 decimal
i need grouped on field1, field2, totaled on field3
tring accomplish in linq results not coming out correctly.
i want original data table in dataset (in foreach?) if not possible know easy remove/add table.
here have far not quite working;
var newsort = row in objecttable.asenumerable() group row new { fullname = row.field<string>("fullname"), attenddate = row.field<datetime>("attenddate"), } grp select new { fullname = grp.key.fullname, attenddate = grp.key.attenddate, sumdayshours = grp.sum(r => r.field<double>("dayshours")) }; foreach (var row in newsort) { dstemp.tables["groupeddata"].rows.add(fullname, row.attenddate, row.sumdayshours); }
Comments
Post a Comment