linq - How to perform Sum of a column dynamically in C#? -
i using system.linq.dynamic group columns using linq dynamically , need perform
how can sum column i.e.(sum(deposits)). user select table , columns @ runtime. ex: above table has territory, state, bankname, year, quarterfrommaint
assume user has selected these columns grouping (territory, state, bankname) , wants sum column ex:deposits. how can this? because asenumerable , asqueryable has sum. need perform groupby , sum
click here further clarification , code is:
here t1 table , qfields list contains grouping columns.
how can use linq sum column after groupby?
do mean this? if not, please disregard...
var query = rows .groupby(row => new { row.territory, row.state, row.bankname }) .select(group => new { group.key.territory, group.key.state, group.key.bankname, deposits = group.sum(row => row.deposits) });
Comments
Post a Comment