Search code examples
linqnhibernatefetcheager

Linq for NHibernate and fetch mode of eager loading


Is there a way to set the fetchmode to eager for more than one object using linq for nhibernate. There seems to be an expand method which only allows me to set one object. However I need to set it for more than one object. Is this possible? Thanks


Solution

  • just use it more then once.

    IList<Entity> GetDataFromDatabase()
    {
        var query = session.Linq<Entity>();
        query.Expand("Property1");
        query.Expand("Property2");
        return query.ToList();
    }