动态生成lamda表达式怎么写select

2025-04-30 18:52:45
推荐回答(2个)
回答1:

new {x.Id,x.Name}这个是编译器的魔术,没有办法“动态”。

你可以select到一个字典或者数组中,如存在List里。

回答2:

大体如下: ObjectContext.T_Income .GroupBy ( k => new { IncomeOfPeople =k.IncomeOfPeople } ) .Select ( g => new { partName = g.Key.IncomeOfPeople, totalMoney = g.Sum (k => k.MoneyNum) } )