Hi,
I have a table InventoryObject with two foreign-keys to Device and Room.
Now I want to select all InventoryObjects with their Room and Device.
My T-SQL query would be: select * from InventoryObject i left join device d on i.deviceid=d.deviceid left join room r on i.roomid=r.roomid;
But NHibernate generates a Select statement for the Inventories and than one statement per Room and Device.
How can i force NHibernate to generate only one statement?
I use Nhibernate 3.2 and Linq to query the DB.
My command to get all objects is: Session.Query<T>().ToList()
My InventoryObject Mapping-File:Code:
<class name="InventoryObject" table="InventoryObject" lazy="true" >
<id name="InventoryID" column="InventoryID" type="long">
<generator class="identity" />
</id>
<many-to-one insert="true" column="DeviceID" update="true" lazy="false" name="Device" not-null="true" class="Device">
</many-to-one>
<many-to-one insert="true" column="RoomID" update="true" lazy="false" name="Room" not-null="true" class="Room" >
</many-to-one>
<bag name="Archives" inverse="true" cascade="none" lazy="true" fetch="join">
<key column="InventoryID" />
<one-to-many class="Archive" />
</bag>
<bag name="Tickets" inverse="true" cascade="none" lazy="true">
<key column="InventoryID" />
<one-to-many class="Ticket" />
</bag>
</class>