I would like to write a Linq query to apply group-by on DataTable, which outputs the result as a DataTable.
I tried this code, which returns a result as var type, but I want the result in DataTable
var query = from row in dt.AsEnumerable()
group row by row.Field<DateTime>("ExpDate").Year into grp
select new
{
Years = grp.Key,
RSF = grp.Sum(r => r.Field<decimal>("SpaceRSF"))
};
Please could you assist me in finding a proper answer.