Func<FooEntity, double> selector = null;
selector = x => x.M1_TotalLoss;
var entity = FooEntity
.Where(x => x.Year == year)
.GroupBy(gp => gp.Year)
.Select(ss => new FooDto
{
SumTotalLoss = ss.Sum(selector)
})
.FirstOrDefaultAsync();
我需要总和动态选择器。
错误=内部.NET Framework数据提供程序错误1025.
答案 0 :(得分:0)
ss.AsQueryable().Sum(selector)