I am getting a NullReferenceException when I try and convert the following LINQ to EF query. What could be wrong here?
List<DailyProductionRecord> prodRecs = new List<DailyProductionRecord>();
var recs = from p in productionEntities.DailyProductionRecordSet
where ((p.Department.DeptId == dept.DeptId) && (p.RecordDate >= thisPeriodStart) && (p.RecordDate < nextPeriodStart))
select p;
prodRecs = recs.ToList();
EDIT: I've just discovered I was too quick off the mark, and my dept criterion was null.