tags:

views:

21

answers:

2

I know how to find dirty properties using NHibernate, but it doesn't seem to work for collections (i.e. to find out if items have been added or removed from a collection). Anyone know how?

A: 

I am sorry I won't give you a precious example. I do not have Visual Studio opened right now to test it. You should study NHibernate.Type.CollectionType.IsDirty method.

Petr Kozelek
A: 
var ipc = theEntity.TheCollection as IPersistentCollection;
var isDirty = ipc.IsDirty;

However, keep this in mind (from the XML doc):

Note that this is only reliable during the flush cycle, after the collection elements are dirty checked against the snapshot.

Diego Mijelshon