我有以下解决方案项目结构:NHibernate的在单独的组件连接子类
Application.Core.Entities
Application.Xtend.CustomerName.Entities
核心项目我有一个实体客户 defiend。在XTend项目中,我有一个实体定义了Customer的子类xCustomer(因为目前缺乏更好的名称)。
这里的想法是,我们在我们的应用程序中有一个核心域模型。然后客户可以创建一个包含我们核心模型扩展的新程序集。当扩展程序集存在时,智能类将返回核心类的子类。
我试图映射这种关系NHibernate。使用Fluent NHibernate我能够产生这种映射:
<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
default-lazy="false"
assembly="NHibernate.Core.Entites"
namespace="NHibernate.Entites"
default-access="field.camelcase-underscore">
<!-- Customer is located in assembly Application.Core.Entities -->
<class name="Customer" table="Customers" xmlns="urn:nhibernate-mapping-2.2">
<id name="Id" column="Id" type="Int64">
<generator class="native" />
</id>
<component name="Name" insert="true" update="true">
<property name="LastName" column="LastName" length="255" type="String" not-null="true">
<column name="LastName" />
</property>
<property name="FirstName" column="FirstName" length="255" type="String" not-null="true">
<column name="FirstName" />
</property>
</component>
<!-- xCustomer is located in assembly Application.XTend.CustomerName.Entities -->
<joined-subclass name="xCustomer" table="xCustomer">
<key column="CustomerId" />
<property name="CustomerType" column="CustomerType" length="255" type="String" not-null="true">
<column name="CustomerType" />
</property>
</joined-subclass>
</class>
</hibernate-mapping>
但NHib引发以下错误:
NHibernate.MappingException: persistent class Application.Entites.xCustomer, Application.Core.Entites not found ---> System.TypeLoadException: Could not load type 'Application.Entites.xCustomer' from assembly 'Application.Core.Entites, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'..
这是合理的xCustomer未在核心库中定义。
是否有可能跨越这样的不同组件?我接近问题了吗?