Lazy Loading in NHibernate

lazy-loadingnhibernate

If a Customer has many Orders attached to them. How would you lazy load the Orders List using NHibernate.

Is it something that needs to be set up mapping file? any help or an example would be great.

Best Answer

Chris' suggestion is how I'd do it, however if you want to do it at runtime you can set the Fetchmode on your criteria to be lazy like so:

criteria.SetFetchMode("Orders", FetchMode.Lazy)
Related Topic