Rookian
Rookian

Reputation: 20549

Is it possible to configure NHibernate at runtime setting the loading-technique (eager/lazy) for a collection

Ya is this possible :) ?

Upvotes: 1

Views: 443

Answers (2)

ewernli
ewernli

Reputation: 38625

You can change the fetch mode per query dynamically.

IList cats = sess.CreateCriteria(typeof(Cat))
    .Add( Expression.Like("Name", "Fritz%") )
    .SetFetchMode("Mate", FetchMode.Eager)
    .SetFetchMode("Kittens", FetchMode.Eager)
    .List();

See section 12.5 of the documentation.

Upvotes: 1

dariol
dariol

Reputation: 1979

For queries - yes :)

Upvotes: 1

Related Questions