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.
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)
Heres a good article:
http://blogs.chayachronicles.com/sonofnun/archive/2007/03/30/230.aspx
From the above article:
The most common is to simply mark the class with the 'lazy="true"' attribute or place 'default-lazy="true"' in the mapping declaration:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="@core.assembly@"
default-access="nosetter.camelcase-underscore" default-lazy="true">
Or
<class name="Cei.eMerge.Core.Domain.Contacts.Contact" table="Contact" lazy="true" >
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With