One thing you might want to consider, in the face of not being able to
change things in your database is to still implement the Null Object
Pattern for dates in you codebase and let the mapping to/from NULL
happen only once...
Something like what was in the code at that link I posted:
public Date
7 11:59 AM
To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM
Subject: Re: [ADVANCED-DOTNET] Null dates in 2005
> I've always done something like below to handle dates that can be null
> in the DB. Was curious if they (MS) every got around to coming up
with
> a date data-type that can accept null values. Is the
> I've always done something like below to handle dates that can be null
> in the DB. Was curious if they (MS) every got around to coming up with
> a date data-type that can accept null values. Is there a better way?
Don't use NULL dates... it makes all the SQL prone to errors (since
comparing a
You can use this for nullable datetime types:
DateTime? d = null;
if (d.HasValue) {
//Do something here
Console.WriteLine(d.Value.ToString());
}
//...is the same as...
Nullable dd = null;
if (
I've always done something like below to handle dates that can be null
in the DB. Was curious if they (MS) every got around to coming up with
a date data-type that can accept null values. Is there a better way?
Public Property PaymentProcessedDateTime() As DateTime
Get
I