In my NHibernate mappings, I have two objects - Listing and User. One user can have many lists, and mappings (Fluent) are configured as such:
Listing:
References<User>(h => h.User).ForeignKey("fk_UserID").Not.LazyLoad().Fetch.Join().Cascade.SaveUpdate();
User:
HasMany<Listing>(u => u.Listings);
It works great. However, when I started playing with QueryOver, I tried:
DbSession.QueryOver<HaveListing>() .Where(h => h.IsModerated == false) .And(h => h.User.SpammedStatus == false)
That does not work. This, however, works:
DbSession.QueryOver<HaveListing>() .Where(h => h.IsModerated == false) .JoinQueryOver(h => h.User) .Where(u => u.SpammedStatus == false)
Obviously, using the latter is okay, but I wanted to make sure that something was missing - my relationships are defined in the mappings, so do I really need to specify a connection each time to do WHERE is the user? It would be useless to include these associations whenever it is not necessary.
source share