我正在将一个简单的工作演示从 nhibernate 移植到 fluent。我现有的休眠映射是这样的:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="MoneyHibernate"
namespace="MoneyHibernate">
<class name="Invoice" table="Invoices">
<id name="Id">
<generator class="guid"/>
</id>
<property name="Number"/>
<property name="Customer"/>
<property name="TotalValue" type="MoneyHibernate.MoneyCompositeUserType,MoneyHibernate">
<column name="TotalValue_Amount" not-null="true" />
<column name="TotalValue_Currency" length="3" not-null="true" />
</property>
</class>
</hibernate-mapping>
我试图创建 equlivilant ClassMap
:
internal class InvoiceMap : ClassMap<Invoice>
{
public InvoiceMap()
{
Id(x => x.Id);
Map(x => x.Customer);
Map(x => x.Number);
Map(x => x.TotalValue)
.CustomType(typeof (MoneyCompositeUserType))
.Column("TotalValue_Amount")
.Column("TotalValue_Currency");
}
}
但我得到了错误:
---> NHibernate.MappingException:属性映射的列数错误:MoneyHibernate.Invoice.TotalValue 类型:MoneyHibernate.MoneyCompositeUserType
所以我认为两次声明列不是正确的方法吗?