I get data from a table but the 'DateOfBirth' field is shown as null.
So if 'DateOfBirth' is null how can I skip it?
EXCEPTION : Cannot cast DBNull.Value to type 'System.DateTime'. Please use a nullable type
var dd = dx.Tables[0].AsEnumerable().Select(x => new StaffModel
{
userno = x.Field<string>("USERNO"),
dateofbirth = x.Field<DateTime>("DATEOFBIRTH"), // This comes as a DB NULL.
passportno = x.Field<String>("PASSPORTNO"),
passportexp = x.Field<DateTime>("EXPDATE")
});