Nhibernate: Don't fetch when accessing a child objects primary key
Posted
by thermal7
on Stack Overflow
See other posts from Stack Overflow
or by thermal7
Published on 2010-03-29T02:52:12Z
Indexed on
2010/03/29
2:53 UTC
Read the original article
Hit count: 583
nhibernate
|fetch
Hi,
Is there a way in NHibernate to get the foreign key of a child object, without fetching the child object?
EG.
I have User and UserRole. Can I access User.UserRole.UserRoleId without causing another hit on the database to retrieve UserRole?
I realize I can set fetch mode to eager and this will stop it from hitting the database again, but theoretically this shouldn't be needed, as the User table has UserRoldId in it.
Thanks in advance.
© Stack Overflow or respective owner