本文介绍了在类映射文件xml中声明多ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据库中有一个表,其中有三列make primary_key.
示例:
表订单(主键包括:OrderID,CustomerID,EmployeeID)

帮助我在nhibernate中创建到此表的映射文件.由于无法使用三个ID进行映射,因此只能创建一个ID的映射文件.

I have a table in my database that it has three column make primary_key.
Example:
Table Orders(primary key include: OrderID, CustomerID, EmployeeID)

Help me create mapping file in nhibernate to this table. Because i can not mapping with three ID, i can only create mapping file with one ID.

推荐答案

<composite-id>
  <key-property name="OrderID" />
  <key-property name="CustomerID" />
  <key-property name="EmployeeID" />
</composite-id>



或具有NHibernate属性:



or with NHibernate attributes:

[CompositeId(0)]
[KeyProperty(1, Name = "OrderID")]
[KeyProperty(2, Name = "CustomerID")]
[KeyProperty(3, Name = "EmployeeID")]
public virtual string OrderID 
{ ...


这篇关于在类映射文件xml中声明多ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 11:01