recordsList.ListOfRecords = new StudentRecordsBAL()
.GetStudentsList()
.Select(q => new StudentRecords()
{
_RollNumber = q._RollNumber,
_Class = q._Class,
_Name = q._Name,
_Address = q._Address,
_City = q._City,
_State = q._State,
_Subjects = q._Subject,
_AttendedDays = new AttendanceBAL()
.GetAttendanceListOf(q._RollNumber)
.Where(date => date != null)
.Select(date =>
new DateTime(date._Date.Year, date._Date.Month, date._Date.Day))
.Distinct()
.ToList(),
_AttendedSubjects = GetAttendedSubjects(q._RollNumber)
}).ToList();
The method, GetAttendanceListOf(q._RollNumber)
in above code will return a list of records from the database or "null" if there are no records present for the passed "roll-no". A linq query will be terminated generating error
"Value cannot be null".
Is there a way to handle this error and make LINQ jump to next step?