I am getting "The null value cannot be assigned to a member with type System.Int32 which is a non-nullable value type" When executing Sum() of my empty statement. ResultView works fine, but either
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);
either
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);
fails with same exception.