I am trying to use the criteria Api over multiple tables with eager loading.
My stripped-down Entities look like this:
class Limit
{
Risk {get; set;}
}
class Risk
{
List<Company> Companies { get;set;}
}
class Company
{
List<Address> OldAdresses {get;set;}
}
class Address
{
string Street { get;set;}
}
My Criteria call looks like this:
var CriterionGruppe = Expression.Eq("Account.Id", someGuid);
var temp = _transaktion.Session.CreateCriteria(typeof(Limit))
.SetFetchMode("Risk", FetchMode.Eager)
.SetFetchMode("Risk.Companies", FetchMode.Eager)
.Add(CriterionGruppe)
.SetResultTransformer(new DistinctRootEntityResultTransformer())
.List<Limit>();
The addresses are still loaded with many Selects. How can I include the old adresses of a Company in my criteria call.
I already read a blog entry in ayende's blog and several other question here at stackoverflow. But still had no luck.
I hope someone could point me in the right direction.
Thanks in advance peter
When must we use eager loading in NHibernate? What is it's usage?