gpt4 book ai didi

c# - NHibernate:来自表 X 的关联引用未映射的类:X

转载 作者:太空狗 更新时间:2023-10-30 00:34:13 25 4
gpt4 key购买 nike

我有一个订单和一个客户对象的两个映射文件。

客户映射:

  <class name="OODB.Domain.Customer, OODB.Domain" entity-name="Customers">
<id name="ID" column="customer_id">
<generator class="guid" />
</id>
<property name="FirstName" column="first_name"/>
<property name="LastName" column="last_name"/>
<property name="EMail" column="email"/>
<property name="Telephone" column="telephone" />

<component name="Address" class="Address">
<property name="Street" column="street"></property>
<property name="PostalCode" column="postal_code"></property>
<property name="City" column="city"></property>
</component>
</class>
</hibernate-mapping>

订单映射:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="OODB.Domain" namespace="OODB.Domain">
<class name="OODB.Domain.CustomerOrder, OODB.Domain" entity-name="Orders">
<id name="ID" column="order_id">
<generator class="guid"></generator>
</id>
<property name="OrderNo" column="order_no" length="8" not-null="true"></property>
<property name="Status" column="status" not-null="true"></property>
<many-to-one name="Orderer" class="Customer" column="customer_id" insert="true" not-found="exception" fetch="join"/>
</class>
</hibernate-mapping>

客户类:

namespace OODB.Domain
{
public class Customer : ModelBase<Customer>
{
public virtual string FirstName
{
get;
set;
}

public virtual string LastName
{
get;
set;
}

public virtual string EMail
{
get;
set;
}

public virtual string Telephone
{
get;
set;
}

public virtual Address Address
{
get;
set;
}

...
}

客户订单类:

public class CustomerOrder : ModelBase<CustomerOrder>
{
public virtual string OrderNo
{
get;
set;
}

public virtual Customer Orderer
{
get;
set;
}

public virtual OrderStatus Status
{
get;
set;
}
...
}

一切都很好,如果我删除多对一的东西(映射作为嵌入式资源集成。我已经检查了两次。)。否则我会收到错误消息“来自表 Orders 的关联引用了一个未映射的类:OODB.Domain.Customer”。但是 Customer 对象已映射...我缺少什么?

最佳答案

我对你的例子的猜测:many-to-one 元素中的“class”规范必须与所有其他 class 规范具有相同的详细程度。特别是,您必须包括程序集。

<many-to-one name="Orderer" class="OODB.Domain.Customer, OODB.Domain" column="customer_id" insert="true" not-found="exception" fetch="join"/>

关于c# - NHibernate:来自表 X 的关联引用未映射的类:X,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8482372/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com