【发布时间】:2008-11-03 20:47:04
【问题描述】:
我有以下解决方案项目结构:
Application.Core.Entities
Application.Xtend.CustomerName.Entities
在核心项目中,我有一个实体客户。在 XTend 项目中,我定义了一个名为 xCustomer 的 Customer 的子类实体(因为目前没有更好的名称......)。
这里的想法是我们的应用程序中有一个核心域模型。然后,客户可以创建一个新组件,其中包含对我们核心模型的扩展。当扩展程序集存在时,智能IRepository 类将返回核心类的子类。
我试图在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: 持久类 Application.Entites.xCustomer, 未找到 Application.Core.Entites ---> System.TypeLoadException:无法加载类型 'Application.Entites.xCustomer' 来自 程序集'Application.Core.Entites, 版本=1.0.0.0,文化=中性, PublicKeyToken=null'..
这很有意义 xCustomer 没有在核心库中定义。
是否可以像这样跨越不同的程序集?我处理问题的方法有误吗?
【问题讨论】:
标签: nhibernate orm fluent-nhibernate