code_junkie

NHibernate Bag Mapping

Nov 14th, 2011
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. <bag name="rooms" table="tb_calEvent_rooms" lazy="false">
  2. <key column="calEventID"/>
  3. <many-to-many class="BasicRoom" column="roomID"/>
  4. </bag>
  5.  
  6. public class BasicRoom
  7. {
  8. private long _id;
  9. private long _buildingID;
  10. private string _roomName;
  11.  
  12. SELECT *
  13. FROM
  14. dbo.tb_calEvent_rooms
  15. INNER JOIN dbo.tb_calEvents ON (dbo.tb_calEvent_rooms.calEventID = dbo.tb_calEvents.id)
  16. INNER JOIN dbo.tb_rooms ON (dbo.tb_calEvent_rooms.roomID = dbo.tb_rooms.id)
  17. INNER JOIN dbo.tb_buildings ON (dbo.tb_rooms.buildingID = dbo.tb_buildings.id)
  18. WHERE
  19. dbo.tb_buildings.id = 54
  20.  
  21. SELECT *
  22. FROM
  23. dbo.tb_calEvents
  24. INNER JOIN dbo.tb_calEvent_rooms ON (dbo.tb_calEvents.id = dbo.tb_calEvent_rooms.calEventID),
  25. dbo.tb_buildings
  26. WHERE
  27. dbo.tb_buildings.id = 54
  28.  
  29. <bag name="rooms" table="tb_calEvent_rooms" lazy="false">
  30. <key column="calEventID"/>
  31. <many-to-many class="BasicRoom">
  32. <column name="roomID"/>
  33. <column name="buildingID"/>
  34. </many-to-many>
  35. </bag>
Add Comment
Please, Sign In to add comment