views:

27

answers:

0

I have a query which is something like this:

Session.CreateSQLQuery(
    @"SELECT f.*, b.*, z.* FROM Foo f
     LEFT OUTER JOIN Bar b ON b.Id = f.BarId
     LEFT OUTER JOIN Zar z ON z.Id = b.ZarId"
     )
    .AddEntity("f", typeof(Foo))
    .AddJoin("b", "f.BarId")
    .AddJoin("z", "b.ZarId")
    .List<Foo>();

The problem is that I am still getting hundreds of SELECT requests made to the Zar table, even though I have specified that Zar should be joined.

As far as I am aware the only relationship is Foo->Bar->Zar, i.e. the reference to Zar is not occurring anywhere else.

Is my understanding of AddJoin correct? What could be going wrong?