I have a db table with columns like DaysInTrade, PercentGain
i want a sum of PercentGain grouped by DaysInTrade
so:
DaysInTrade,PercentGain
1, 5
1,6
2,4
Would give me:
DaysInTrade, Sum
1, 11
2,4
I was not able to get intellisense working in the "select new" part unless I used something like Sum or Select. the DIT column below shows up blank no matter if I do ts.DaysInTrade, or gts.DaysInTrade
var partialQuery = (from ts in context.TradeSnapshots
group ts by ts.DaysInTrade
into gts
select
new
{
profit = gts.Sum(s => s.PercentGain),
DIT = gts.Select(ts=>ts.DaysInTrade)
});
dataGridViewTradeSnapshots.DataSource = partialQuery.ToList();