I don't have access to code here in front of me so I was just wondering if someone could help me out with Session.Evict().
Say I have a Person object with a child collection of Addresses. I populate the Person object from a session and lazy load the Addresses collection. I then call Session.Evict(personObject) to detach the Person object from the session. My question is, if I attempt to access the Addresses collection will it just return null, or will I get an exception because the NHibernate proxy can't find the associated session?
If you cause the lazy load to happen before you evict the entity, then the collection will be accessible even after the eviction. However if you evict the entity and then try to lazy load the child collection you will get an exception.
You will receive a NHibernate.LazyInitializationException.
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