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 DateTime SomeStartingDate
{
    get
    {
        if (dr["SomeDate"] == DBNull.Value)
            return DateTime.MinValue;
        else
            return (DateTime)dr["SomeDate"];
    }
    set
    {
        if (value == DateTime.MinValue)
            dr["SomeDate"] = DBNull.Value;
        else
            dr["SomeDate"] = value;
    }
}

public DateTime SomeEndingDate
{
    get
    {
        if (dr["SomeDate"] == DBNull.Value)
            return DateTime.MaxValue;
        else
            return (DateTime)dr["SomeDate"];
    }
    set
    {
        if (value == DateTime.MaxValue)
            dr["SomeDate"] = DBNull.Value;
        else
            dr["SomeDate"] = value;
    }
}

That way, only your SQL is in danger and all your code can just assume away...

--
"you watch my lips...like a pair of wrists that have never been slit."
Sam Phillips

Marc C. Brooks
http://musingmarc.blogspot.com

===================================
This list is hosted by DevelopMentor�  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to