在执行空语句的 Sum() 时,我收到“无法将空值分配给 System.Int32 类型的成员,这是一个不可为空的值类型”。ResultView 工作正常,但要么
var r = from v in DataContext.Visits
join bs in DataContext.BaseContents on v.BaseContentID equals bs.Id
where (bs.CreatedBy == userId) && (v.DateVisited.Year == workDate.Year) &&
(v.DateVisited.Month == workDate.Month) && (v.DateVisited.Day == workDate.Day) &&
(v.IsPreviewed == false) && (bs.ProfileProjectId != null)
select v;
int? number = r.Sum( v => v.Counter);
任何一个
var r = from v in DataContext.Visits
join bs in DataContext.BaseContents on v.BaseContentID equals bs.Id
where (bs.CreatedBy == userId) && (v.DateVisited.Year == workDate.Year) &&
(v.DateVisited.Month == workDate.Month) && (v.DateVisited.Day == workDate.Day) &&
(v.IsPreviewed == false) && (bs.ProfileProjectId != null)
select v.Counter;
int? number = r.Sum(v);
失败,同样的例外。