I'm building a standard old thick client with NHibernate where the
majority of my entities (A type) are dehydrated at application start
and stay there for the app lifetime. These occassionally reference a
couple of heavyweight classes (B type) that encapsulate a lot of data
which are lazily loaded proxies so that they are only fetched from the
database on demand.

This works fine. The problem is I also desire the ability to unload
these B types later - from my point of view I want to go back to the
original state just after application startup where A is a real, non-
proxy class and B is an uninitialized proxy. I understand I will have
to track the references to B (and any of its ancilliary objects)
myself.

Seeing as there doesn't seem to be a way to de-initialize a proxy
(correct?), my original plan was to do something like:

A a = ...
// ensure there are no dangling references to B
var b_id = a.referenceToB.Id;
session.Evict(a.referenceToB);
a.referenceToB = session.Load<B>(b_id);

Unfortunately it seems the session still keeps a referenceToB
(presumably for purposes of equality comparison on a, to see if it
needs to write back to the database). So I actually have to either
session.Evict(a) or call session.Flush() after a.referenceToB = null;

I'm wondering if I there is a way to make the session stop tracking
referenceToB without evicting a or otherwise flushing/clearing the
session? Or lacking that, a way to basically achieve similar
functionality?

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to