Hello,
I am issuing the following Criteria query:

var industries = this.Session.CreateCriteria<Industry>()
                                .CreateAlias("Manufacturers", "manu",
JoinType.InnerJoin)
                                .CreateAlias("manu.Distributors",
"dist", JoinType.InnerJoin)
                                .AddOrder(new Order("Name", true))
                                .AddOrder(new Order("manu.Name",
true))
                                .AddOrder(new Order("dist.Name",
true))
                                .SetResultTransformer(new
DistinctRootEntityResultTransformer())
                                .List<Industry>();

Industry has many manufacturers, and each manufacturer has many
distributors.  The query in NHProf seems to be issuing properly, but
when I issue nested loops to load the results into a treeview I get a
SELECT N+1 situation:

foreach (var industry in industries)
{
    foreach (var manufacturer in industry.Manufacturers)
    {
        foreach (var distributor in manufacturer.Distributors)
        {
        }
    }
}

And ideas?  I'm making an assumption that CreateAlias does the same
thing as SetFetchMode.

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to