Ok so I have the following relationships:
Bulletin < BulletinEmailLog < BulletinEmailLogRecipient - Contact - Entity
Where the "<" stands for 1 to many and the "-" is one to one.
And here is the code:
BulletinEmailLog BulletinEmailLogs = null;
BulletinEmailRecipient EmailRecipients = null;
Contact Contact = null;
Entity Entity = null;
var pastBulletin = NHibernateSession.Current.QueryOver<Bulletin>()
.Where(x => x.Id == bulletinID)
.Fetch(x => x.BulletinEmailLogs).Eager
.JoinAlias(x => x.BulletinEmailLogs, () => BulletinEmailLogs, NHibernate.SqlCommand.JoinType.LeftOuterJoin)
.JoinAlias(() => BulletinEmailLogs.Recipients, () => EmailRecipients, NHibernate.SqlCommand.JoinType.LeftOuterJoin)
.JoinAlias(() => EmailRecipients.Contact, () => Contact, NHibernate.SqlCommand.JoinType.LeftOuterJoin)
.JoinAlias(() => Contact.Entity, () => Entity, NHibernate.SqlCommand.JoinType.LeftOuterJoin)
.Future<Bulletin>();
Here I try to use one database query to grab all of the necessary information. The problem , is that later I try to loop through the BulletinEmailLogs but I see a call to the database. I would like to be able to add eager loading statements within the preceding code in order to do later searches using memory. Is that possible?