var TatalFeeCollectionDetail = new List<lcclsTotalFeeCollectionDetail>();
TatalFeeCollectionDetail = (from t in .......
group t by new { t.MonthName,t.FeeParticularName }
into grp
select new lcclsTotalFeeCollectionDetail
{
Month = grp.Key.MonthName,
Particular = grp.First().FeeParticularLedgerName,
Amount = grp.Sum(t => t.Amount),
}).ToList();
dgvTotalFeeCollectionDetail.DataSource = TatalFeeCollectionDetail;
My result is this .............
Month particular Amount
April b 1
April c 2
April d 1
April e 2
April f 1
I want to convert it like this can any1 help me...........I search for it but can,t understood what to do....
Month b c d e f Total Amount
April 1 2 1 2 1 7
Thanxxxxxxx in advance
You can't. That would mean creating an anonymous type with a variable number of properties, and it's not possible in C# which is strongly typed.
What you can certainly do is storing the 'particular' values in a Dictionary and get a result like
Month particular Total
April {{b, 1}, {c, 2}, {d, 1}, {e, 2}, {f, 1}} 7