I need help with eager loading in with Linq in NHibernate 3 trunk version.
I have a many-to-many relationship like this:
public class Post
{
pub
Support for this went into the trunk sometime ago; the syntax is be something like
var query = session.Query<Post>().Where(bla bla).Fetch(p => p.Tags);
If Tags in turn had another relationship, you can do:
var query = session.Query<Post>().Where(bla bla).Fetch(p => p.Tags).ThenFetch(t => t.SomethingElse);
For me this thread solve problem.
Linq for NHibernate - filtering on <many-to-one> foreign key causes extra lookup
var linqsession = session.Linq<FeedItem>();
linqsession.QueryOptions.RegisterCustomAction(c => c.SetResultTransformer(new DistinctRootEntityResultTransformer()));
var feedItemQuery = from ad in linqsession.Expand("Ads")
where ad.Id == Id
select ad