Bad
int mainDepID = db.Departments.SingleOrDefault(y => y.ID == depID).MainDepartmentID;
Good
int mainDepID = 0;
Web.Model.Department currentDepartment = db.Departments.SingleOrDefault(y => y.ID == depID);
if (currentDepartment != null)
{
mainDepID = currentDepartment.MainDepartmentID;
}
No comments:
Post a Comment