Is there anything wrong at the below code? In my VIEW, i got CREATED_DATETIME(have value) in sql result. Somehow I get object reference not set to an instance of an object. I have other page using the same structure function to called VIEW as well and working fine.
using (MyDBEntities entities = new MyDBEntities())
{
if (startDate.HasValue && endDate.HasValue)
{
result = entities.VIEW_VOID_HISTORY.Where(a => a.CREATED_DATETIME >= startDate.Value && a.CREATED_DATETIME <= endDate.Value).OrderByDescending(a => a.CREATED_DATETIME).ToList();
}
}