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));

I want to sum Column "Fee" which is nvarchar type and group it by MonthID

Mike
  • 751
  • 2
  • 10
  • 25

1 Answers1

0

Just look to this example

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)));

The keys are identifiers of months and values - sums of fee for appropriate month.