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. enter image description here 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:

enter image description here

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

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -