Is it ok to construct my object entities with this type?
public class Patient
{
public Datetime? AdmissionDate { get; set; }
public double? AdmissionFee { get; set }
public int? RoomNumber { get; set }
}
WHat is the drawback if I implemented this in all my entities, because recently, I always encounter situation where I really need to set the value to null, specially in DateTime. My current solution was put DateTime.MinValue when fetching null datetimes record from the database, and when Im displaying the result to Ui, I just check it like this.
if (patient.AdmissionDate == Datetime.MinValue)
{
DisplayAdmissionDate(string.empty)
}
else
{
DisplayAdmissionDate(patient.AdmissionDate)
}
Yes, in gridview, I have to put it on the Databound event, so when i have million data to display, I thought checking each of the datetime's each loop was not the most elegant way so, to this problem, I find this ? type where I can put null values, and I'm planning to ?ed all my properties, so in the future, putting null values to this value types will not be a problem. Any advise guys? TIA