我在 C# 中使用 NHibernate,在编译时它给了我这个错误:
{"Could not find a getter for property 'idOrder' in class 'FrancosPoS.DBMapping.ordPsf'"}
我找到了这个问题,但我不知道如何为我使用它: Nhibernate - 找不到属性的吸气剂
这是我的映射类:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping assembly="FrancosPoS" namespace="FrancosPoS.DBMapping" xmlns="urn:nhibernate-mapping-2.2">
<class name="ordPsf" table="ord_psf" lazy="true" >
<id name="idOrdPastaF">
<generator class="identity" />
<!--<column name="idOrdPastaF" sql-type="int(11)" not-null="true" />-->
</id>
<many-to-one insert="false" update="false" lazy="false" name="idOrder">
<column name="idOrder" sql-type="int(11)" not-null="true" />
</many-to-one>
<property name="idOrder">
<column name="idOrder" sql-type="int(11)" not-null="true" />
</property>
<many-to-one insert="false" update="false" lazy="false" name="idPastaF">
<column name="idPastaF" sql-type="int(11)" not-null="true" />
</many-to-one>
<property name="idPastaF">
<column name="idPastaF" sql-type="int(11)" not-null="true" />
</property>
.
.
.
<property name="obs">
<column name="obs" sql-type="varchar(50)" not-null="false" />
</property>
<property name="price">
<column name="price" sql-type="decimal(8,4)" not-null="true" />
</property>
</class>
</hibernate-mapping>
这是我的cs课:
namespace FrancosPoS.DBMapping {
public partial class ordPsf {
public ordPsf() { }
public virtual int idOrdPastaF { get; set; }
public virtual order order { get; set; }
public virtual pastaFeast pastaFeast { get; set; }
public virtual salad salad { get; set; }
public virtual onTheSide onTheSide { get; set; }
public virtual string obs { get; set; }
public virtual string price { get; set; }
}
}
我的猜测是我做错了映射。由于显而易见的原因,我不想有一个 idOrder 获取/设置,因为我需要使用该对象。(此外,我猜在修复这个之后,其他 id 也会出现同样的错误)