我在尝试获取“预订”的SUM,并收到错误“由于物化值为null,所以转换为值类型'Int32'失败。无论是结果类型的泛型参数还是查询必须使用可空类型。“使用LINQ SUM时出现异常
var bookings = entities.Bookings.Where(x => x.ID == id &&
x.StartDate <= bookingEnd &&
x.EndDate >= bookingStart)
.Sum(x => x.BookingQuantity);
我该如何解决这个问题?如果它没有预订,我需要得到0。
同样的问题在这里:http://stackoverflow.com/questions/2076827/linq-error-generic-pa- ter----query-must-use-a-nullable-type – VikciaR 2011-04-15 10:18:46