我有以下解決方案項目結構: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未在覈心庫中定義。
是否有可能跨越這樣的不同組件?我接近問題了嗎?