Eager load while using Linq in NHibernate 3

前端 未结 2 1500
小鲜肉
小鲜肉 2021-01-02 14:02

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         


        
2条回答
  •  感动是毒
    2021-01-02 14:23

    Support for this went into the trunk sometime ago; the syntax is be something like

    var query = session.Query().Where(bla bla).Fetch(p => p.Tags);
    

    If Tags in turn had another relationship, you can do:

    var query = session.Query().Where(bla bla).Fetch(p => p.Tags).ThenFetch(t => t.SomethingElse);
    

提交回复
热议问题