本文介绍了流利的NHibernate - 将2个表映射到一个类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ Employee $ $ $ $ b EmployeeCustID

表Customer
CustomerID
CustomerName

我想要的是将上面的结构映射到一个名为:
$ b

  Class Employee 
EmployeeID
EmployeeLogin
EmployeeName

如何用流利的nhibernate做这件事?

解决方案

我不知道是否可以使用流利,但在xml中使用连接元素:

简化:

 < class name =Employeetable =Customers> 
< id name =CustomerID... />

< property name =CustomerName/>

< join table =Employees>
< key column =EmployeeCustID/>
< property name =EmployeeLogin/>
< / join>

< / class>

请参阅


I have a table structure something like this

table Employees
 EmployeeID
 EmployeeLogin
 EmployeeCustID

table Customers
 CustomerID
 CustomerName

What i would like is to map the structure above to one single class named:

Class Employee
 EmployeeID
 EmployeeLogin
 EmployeeName

How do i do that with fluent nhibernate ?

解决方案

I don't know if it is possible with fluent, but in xml you use the join element:

simplified:

<class name="Employee" table="Customers" >
  <id name="CustomerID" .../>

  <property name="CustomerName"/>

  <join table="Employees">
    <key column="EmployeeCustID" />
    <property name="EmployeeLogin" />
  </join>

</class>

See this post by Ayende

这篇关于流利的NHibernate - 将2个表映射到一个类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 01:29