-1
 public class Bar
    {
        [Key]
        public int BarID { get; set; }
        public int Quantity { get; set; }
        public decimal UnitTotal { get; set; }
        public decimal? DailyTotal { get; set; }
        public int PricelistID { get; set; }
        public virtual Pricelist Pricelist { get; set; }
    }

//in the BarController Create method

bar.DailyTotal = db.Bars.Sum(x => x.UnitTotal);
har07
  • 88,338
  • 12
  • 84
  • 137
user2985240
  • 95
  • 2
  • 8

1 Answers1

0

It would suggest that you have a null in the UnitTotal column in your DB. You could either eliminate the null or change the type to be decimal?

Stu
  • 2,426
  • 2
  • 26
  • 42