I am running into an nHibernate error while saving an object.
The classes involved are:
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;}
}
}
Mapping:
<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 >
While persisting the object to database via Save, I get the following error:
Exception: Unable to cast object of type 'Castle.Proxies.IHardwareSpecificationProxy' to type 'Hardwaremarketplace.Model.SystemTransactions.CPUSpecification'.
I am trying to figure out how to resolve this so any help will be appreciated. f