我在保存对象时遇到了 nHibernate 错误。
涉及的类是:
interface IHardwareSpecification
{
//fields and methods
}
public class CPUSpecification : IHardwareSpecification
{
//fields and methods
}
public class SystemTransaction
{
//Bunch of other fields
private IHardwareSpecification _specs;
public virtual IHardwareSpecification Specification
{
get { return _specs; }
set { _specs = value;}
}
}
映射:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" ...>
<class name="SystemTransaction" table="SystemTransactions" lazy="false">
<component access="field.camelcase-underscore" name="Specification"
class="HardwareMarketplace.Model.CPUSpecification">
<property access="field.camelcase-underscore" column="Specification_Rate"
name="Rate"/>
...
</component>
</class>
</hibernate-mapping >
通过 Save 将对象持久化到数据库时,出现以下错误:
例外:无法将“Castle.Proxies.IHardwareSpecificationProxy”类型的对象转换为“Hardwaremarketplace.Model.SystemTransactions.CPUSpecification”类型。
我正在尝试弄清楚如何解决此问题,因此将不胜感激。F