Hi,
I have a Linq Query method for finding minimum date which works fine. But when the CrtDt datetime field has null value it gives sqldatetime overflow error. Help Appreciated. Below is the code I have so far.
public int GetEarliestWaitListedUser(int eventId)
{
using (var context = new dbSignUpsDataContext())
{
Table<tParticipant> participantTable = context.GetTable<tParticipant>();
DateTime? minDate = Convert.ToDateTime(participantTable.Where(p => p.WaitLstInd == 'Y' && p.EventID == eventId).Select(p => p.CrtDt).Min());
var temp = participantTable.Where(p => p.CrtDt == minDate).FirstOrDefault();
if(temp != null)
{
int empId = temp.EmpID;
}
return temp.EmpID;
}
}
CrtDt is the datetime field from database.