The code below brings through a row for each InvNo, along with the sum of “SCharge” :0
var Values = from data in DtSet.Tables["tblCosts"].AsEnumerable()
group data by new
{
InvNo = data.Field<double>("InvoiceNo"),
AccRef = data.Field<double>("SiteRefNum"),
}
into g
select new
{
Code = "1",
InvType = "I",
Account = g.Key.AccRef,
InvNo = g.Key.InvNo,
SCharge = g.Sum(d => d.Field<double>("SCharge"))
};
Is there are way of modifying this so that I get another set of rows below, this time doing a sum on the column “TCharge”, or would I need to do a new query?
So since you want to show all of the rows twice, but with a slightly different projection the second time, we can start by saving a query for the groupings, and then performing two projections on those groups and combining them together.