Actually it's quite easy to just create your NullableDateTimeType ...
Code:
public class NullableDateTimeType : NullableTypesType
{
private static DateTime? NULLVALUE = null;
public NullableDateTimeType()
: base(new DateTimeSqlType())
{
}
public override object NullValue
{
get { return NULLVALUE; }
}
public override Type ReturnedClass
{
get { return typeof(DateTime?); }
}
public override object Get(IDataReader rs, int index)
{
return new DateTime?(Convert.ToDateTime(rs[index]));
}
public override void Set(IDbCommand cmd, object value, int index)
{
IDataParameter parameter = (IDataParameter)cmd.Parameters[index];
DateTime? nullableValue = (DateTime?)value;
if (nullableValue.HasValue)
{
parameter.Value = nullableValue.Value;
}
else
{
parameter.Value = DBNull.Value;
}
}
public override object FromStringValue(string s)
{
if ((s == null) || (s.Trim().Length == 0))
{
return new DateTime?();;
}
else
{
try
{
return new DateTime?(DateTime.Parse(s));
}
catch (System.Exception ex)
{
throw new FormatException("Error parsing '" + s + "' to NullableDateTime.", ex);
}
}
}
}
in your entity class you do something like that ..
Code:
public class Order {
private DateTime? _orderDate;
...
public DateTime? OrderDate
{
get { return _orderDate; }
set { this._orderDate = value; }
}
...
}
and in your mapping file
Code:
<class name="NorthwindDomain.Order, NorthwindDomain" table="Orders">
...
<property name="OrderDate" type="NHibernateExtensions.NullableDateTimeType, NHibernateExtensions"/>
...
in this way your model is pure .NET2.0