Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View NHibernate session objects

I keep getting an error when i delete an object from a collection that it will be resaved because it exists in other collections. In the current session only the collection I am working on exists. There aren't any others. So I think NHibernate is telling me that even though the object will be deleted, it still exists in the session.

How can i view the objects that are in the current session or in which collection did NHibernate find that the object that I am trying to delete belongs?

like image 773
Mité Avatar asked Mar 15 '12 22:03

Mité


1 Answers

I found it:

var sessionContext = session.GetSessionImplementation().PersistenceContext;
foreach (var entity in sessionContext.EntitiesByKey.Values)
{

}

the context contains all the objects that are in the session.

like image 160
Mité Avatar answered Oct 15 '22 09:10

Mité