NHibernate在hbm文件中推断出属性上的错误类型

时间:2015-08-02 14:42:11

标签: c# xml nhibernate hbm

我有一个现有的HBM XML文件,我需要添加两个新属性。当我添加这些时,NHibernate似乎推断出不正确的类型并报告PropertyAccessException。明确设置属性也没有帮助。代码如下:

域:

public class Centre : VersionedDomainObject
{
    public virtual DateTime? DateDeleted { get; set; }
    public virtual bool Deleted { get; set; }

    public virtual string CentreName { get; set; }
    public virtual string CentreNumber { get; set; }

    public virtual Iesi.Collections.Generic.ISet<CentreAddress> Addresses { get; set; }
    public virtual Iesi.Collections.Generic.ISet<CentreSource> CentreSources { get; set; }



    public virtual string Telephone { get; set; }
    public virtual string Fax { get; set; }
    public virtual string Url { get; set; }
    public virtual string Email { get; set; }
    public virtual bool CentreVisibleOptIn { get; set; }
    public virtual decimal? Latitude { get; set; }
    public virtual decimal? Longitude { get; set; }
...

}

HBM XML文件:

   

       

<id name="Id" access="property" column="ID">
  <generator class="identity" />
</id>

<version name="_version" column="VERSION" unsaved-value="-1"  access="field"/>

<property name="LastAmended" not-null="true"/>
<property name="DateCreated" not-null="true"/>

<property name="DateDeleted" />
<property name="Deleted" />

<property name="CentreName" />
<property name="CentreNumber" />

<property name="Telephone"  />
<property name="Fax" />
<property name="Url" />
<property name="Email" />

<property name="CentreVisibleOptIn" not-null="true" />
<property name="AcceptsPrivateCandidates"/>

<property name="Contact" />

<property name="AwardingOrganisationId" not-null="true"/>

<many-to-one name="GeographicRegion" class="CommonData.Domain.Common.Location.GeographicRegion, CommonData.Domain.Common" column="GeographicRegionId" />

<many-to-one name="CategoryType" column="CategoryTypeId" class="CommonData.Domain.Centre.CategoryType, CommonData.Domain.Common.Operational" />

<property name="Latitude" />
<property name="Longitude" />

<set name="Addresses" cascade="all-delete-orphan" lazy="true" inverse="true">
  <key column="CentreId" not-null="true" />
  <one-to-many class="CommonData.Domain.Centre.CentreAddress, CommonData.Domain.Centre"/>
</set>

<set name="CentreSources" cascade="all-delete-orphan" lazy="true" inverse="true">
  <key column="CentreId" not-null="true" />
  <one-to-many class="CommonData.Domain.Centre.CentreSource, CommonData.Domain.Centre"/>
</set>

数据库:

纬度和经度是数据库中新添加的列,类型为decimal(9,6)。

0 个答案:

没有答案