NHibernate 2.* mapping files: how to define nullable DateTime type (DateTime?)?

前端 未结 1 348
执念已碎
执念已碎 2021-01-08 00:54

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 n

相关标签:
1条回答
  • 2021-01-08 01:32
    <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" />
    
    0 讨论(0)
提交回复
热议问题