Consider the following scenario:
Class A has a one-to-many relationship to Class B. Class B has a many-to-one relationship to Class C.
class A {
IList<B> BList {get;set;}
}
class B {
C CMember{get;set;}
}
class C {
//null
}
If I load class B from the database using something like
IList<B> result = query.List<B>();
everything works as expected,
However if I do something like:
DetachedCriteria query = DetachedCriteria.For(typeof(A));
query.CreateAlias("B", "B", JoinType.InnerJoin);
IList<A> result = query.List<A>();
then, NHibernate will also select from table C and load all Cs.
Mappings below: A mapping...
<bag name="BList " table="B" lazy="true" inverse="false">
<key column="id" />
<one-to-many class="B" />
</bag>
B mapping...
<many-to-one class="C" name="CMember" column="idC" lazy="proxy" outer-join="true" />
Any Ideas? Thanks.