Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

NHibernate - Mapping a String Foreign Key

By: a guest on Feb 26th, 2012  |  syntax: None  |  size: 0.50 KB  |  views: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Teams (
  2.  TeamId INT PRIMARY KEY,
  3.  Name VARCHAR(30)
  4. )
  5.  
  6. Players (
  7.  PlayerId INT PRIMARY KEY,
  8.  Team VARCHAR(30)
  9. )
  10.        
  11. <bag name="Players">
  12.     <key column="Team" foreign-key="Name" />
  13.     <one-to-many class="DataTransfer.Player, DataTransfer" />
  14. </bag>
  15.        
  16. <bag name="Players">
  17.    <key column="Team" property-ref="Team" />
  18.    <one-to-many class="Player" property-ref="Team" />
  19. </bag>
  20.        
  21. <many-to-one name="Players" class="DataTransfer.Player, DataTransfer"
  22.              column="Name" property-ref="Team" />