У меня есть класс вроде этого
public class MyClass
{
public int Id { get; set; }
public Nullable<DateTime> ApplicationDate { get; set; }
....
}
Теперь я пытаюсь заполнить объект MyClass
следующим образом
DataTable dt = DBHelper.GetDataTable(sql, conn);
DataRow dr = dt.Rows[0];
MyClass oMyClass = new MyClass();
oMyClass.Id = (int)dr["Id"];
oMyClass.ApplicationDate = dr["ApplDate"] == DBNull.Value ? null : Convert.ToDateTime(dr["AppDate"]);
//Above line gives an error
....
Присвоение значения даты приложения дает ошибку
Type of conditional expression cannot be determined because there is no implicit conversion between '<null>' and 'System.DateTime'
Что мне здесь не хватает?