tags:

views:

16

answers:

1

I have a need to inspect the set of attached entities that would be persisted if I called Flush() on a given session. (I'm writing code that accesses a Session as part of a generic pipeline before saving and it can be used in any number of contexts.)

I find myself wishing that there were a method like

mySession.GetPersistentEntities()

so I could inspect them and perform some preprocessing.

Anyone know of a way to do this?

Thanks,

Jeff

+1  A: 

No, NHibernate's ISession does not expose anything like that. You can either:

  • Track these instances yourself (not recommended)
  • Use standard NHibernate mechanisms:
    • Event listeners (e.g. IFlushEventListener, ISaveOrUpdateEventListener)
    • Interceptors (IInterceptor.OnFlushDirty(), OnSave())
Mauricio Scheffer