0
var TotalFee = (from item in _dbEntities.MonthlyFees
                               where item.Year == DateTime.Now.Year &&
                               item.FeeStatus == true
                               select item).GroupBy(x =>x.MonthID);//.AsEnumerable().Sum(x => int.Parse(x));

我想对 nvarchar 类型的“费用”列求和,并按 MonthID 对其进行分组

4

1 回答 1

0

看看这个例子

var feesDictionary = _dbEntities.MonthlyFees
            .Where(x => x.Year.Equals(DateTime.Now.Year) && x.FeeStatus)
            .GroupBy(x => x.MonthID)
            .ToDictionary(x => x.Key, x => x.Sum(y => Convert.ToDouble(y.Fee)));

键是月份和值的标识符 - 适当月份的费用总和。

于 2015-02-21T17:33:06.053 回答