3

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?

cbp
  • 25,252
  • 29
  • 125
  • 205

2 Answers2

5
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
  • 52,548
  • 16
  • 116
  • 154
0

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
  • 1,126
  • 8
  • 14