Hi otis,
Well, yes, I know that DataTable doesn't support nullables.
However, I would prefere similar syntax:
public System.DateTime? Created
{
get
{
if(IsNull(_parent.CreatedColumn))
{
return null;
}
else
{
return (System.DateTime)this[_parent.CreatedColumn];
}
}
set
{
if (value == null)
value = DBNull.Value;
this[_parent.CreatedColumn] = value;
}
}
over
public System.DateTime Created
{
get
{
if(IsCreatedNull())
{
return (System.DateTime)TypeDefaultValue.GetDefaultValue(typeof(System.DateTime));
}
else
{
return (System.DateTime)this[_parent.CreatedColumn];
}
}
set
{
this[_parent.CreatedColumn] = value;
}
}
/// <summary>Returns true if the TypedList field Created is NULL, false otherwise.</summary>
public bool IsCreatedNull()
{
return IsNull(_parent.CreatedColumn);
}
/// <summary>Sets the TypedList field Created to NULL. Not recommended; a typed list should be used as a readonly object.</summary>
public void SetCreatedNull()
{
this[_parent.CreatedColumn] = System.Convert.DBNull;
}
It isn't a big deal though.