I got the following entity: User, Enrollment and Invoice.

One user have many invoices and many enrollments. Both are lazy mapped.

User
{
    IList<Invoice> Invoices { get; set;}
    IList<Enrollment> Enrollments { get; set;}

}

so I am loading up a list of users via linq. Something like
var query = from user in UserRepository select user;

var result = query
.FetchMany(x=>x.Enrollments)
.FetchMany(x=>x.Invoives)
.ToList();

I notice the following behavior by watching with the NHProfiler.

If I do var result = query.ToList() or
var result = query
.FetchMany(x=>x.Enrollments)
.FetchMany(x=>x.Invoives)
.ToList();
then lazy loading and eager loading work as expected.

if I do
var result = query
.FetchMany(x=>x.Enrollments)
.ToList();
then this cause a select N+ by also loading up the Invoices....


If this is a bug I'll thought of a test case later and filled a jira over
the weekend.

Reply via email to