I'm using nHibernate 2.0 with C#. I have the following mappings:
Piece:
Code:
<class name="DAL.BusinessObjects.Piece, DAL" table="dbo.Piece" lazy="true">
<id name="Id" column="PieceGuid">
<generator class="assigned" />
</id>
<bag name="Piece2Games" lazy="true" cascade="all-delete-orphan" inverse="true" >
<key column="PieceGuid"></key>
<one-to-many class="Piece2Game"></one-to-many>
</bag>
</class>
Piece2Game:
Code:
class name="DAL.BusinessObjects.Piece2Game, DAL" table="dbo.Piece2Game" lazy="true">
<id name="Id" column="Piece2GameID">
<generator class="native" />
</id>
<many-to-one name="PieceMember" column="PieceGuid" class="Piece" />
</class>
When I load a Piece2Game object, nHibernate generates a proxy for Piece. If I only want to read PieceGuid of the Piece object (the FK value), it triggers a lazy load of the Piece object. Since PieceGuid is the FK, I already have the value and don't need to lazy load the entire object. Is there any way to prevent this?