0

In .hbm mapping file, i have the following setting:

<set name="Fields" table="Fields" lazy="false" cascade="all" inverse="false">

/.../

The lazy loading for this collection is globally disabled

Is it a way to "locally" enable lazy loading only for single Linq query?

The HBM mapping file must remains intact.

1 Answers1

1

Well, I don't think it is achievable by LINQ, but you can use NHibernate's ICriteria to achieve what you want. An example could be like below.

ISession.CreateCriteria<Entity>()
        .SetFetchMode("Fields", FetchMode.Lazy)
        .List<Entity>();

More information about ICriteria can be found: https://nhibernate.info/doc/nhibernate-reference/querycriteria.html

YYTan
  • 471
  • 1
  • 5
  • 21