I know one of the breaking changes with NHibernate 2.* is that the NHibernate.Nullables are no longer supported. Therefore, what do you use in your mapping file to map the nullable DateTime? type? For i.e.:
Understandably doesn't work:
<property name="CreateDate" column="CreateDate" type="DateTime?" not-null="false" />
And no longer supported:
<property name="ModifiedDate" column="ModifiedDate" type="Nullables.NHibernate.NullableDateTimeType, Nullables.NHibernate" not-null="false"/>
I know it must be so obvious, but I'm not finding it!
Answer is as simple as: NHibernate will reflect over the class in question and discover that the property's reflected type is DateTime? all on its own.
Thanks @Justice!
<property name="CreatedDate" />
- NHibernate will reflect over the class in question and discover that the property's reflected type is
DateTime?
all on its own. - NHibernate will assume the column name is by default the same as the property name, unless you tell it otherwise.
- NHibernate will assume that any property is nullable (
not-null="false"
) unless you tell it otherwise.
If you really want, it should be something like ...
<property name="CreatedDate" type="System.Nullable`1[[System.DateTime, mscorlib]], mscorlib" />
来源:https://stackoverflow.com/questions/593236/nhibernate-2-mapping-files-how-to-define-nullable-datetime-type-datetime