I have some classes that model my tables. Many of the tables have a sql server DateTime, which is a c# DateTime in my classes. The code looks something like "FIGURE 1" below. As I do this often I want to put in a static method that I can call my each of my classes. My problem is that I dont know how to represent the parameter (a specific sqldatreader column/row) in the static method, "FIGURE 2" below.
FIGURE 2
public static DateTime SqlDateTimeSet(????)
{
DateTime dt;
if (?????) // // true = null in test
dt = DateTime.MinValue;
else
dt = ????;
return dt;
}
FIGURE 1
User usr = new User();
int ordinal = <nullable DateTime column>;
if (dr.IsDBNull(ordinal))
usr.DisableDate = DateTime.MinValue;
else
usr.DisableDate = dr.GetDateTime(ordinal);