Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted

1 solution

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


or with NHibernate attributes:
[CompositeId(0)]
[KeyProperty(1, Name = "OrderID")]
[KeyProperty(2, Name = "CustomerID")]
[KeyProperty(3, Name = "EmployeeID")]
public virtual string OrderID 
{ ...
 
Share this answer
 
v2
Comments
thuyphuongid 17-Jun-10 6:42am    
all of way: I cannot declare.
In the two way: Must add preference?
thuyphuongid 17-Jun-10 6:44am    
Reason for my vote of 2
It like other answer in the web.
kornakar 17-Jun-10 7:03am    
"It like other answer in the web".

Well that's because it's the correct answer. What else do you want me to add? The whole source code for your program?
thuyphuongid 17-Jun-10 20:56pm    
Oh no, I declare follow your instruction but i have errors, and i think it has one or more preference dll in .net framework.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900