views:

42

answers:

2

I need to write some business logic rigt before flush against all changed entities. One of the solution I've tried is IPreUpdateEventListener. But this event listener already have object denormalized to key-value. I need something before denormalization and even before flush.

So the questions is how to get list of changed (diry) entities.

+1  A: 

You might look at the Flush event. But what are you trying to accomplish, exactly?

Diego Mijelshon
Thanks, flush event seems could work. It has IEventSource as argument, and eventSource.PersistenceContext.EntityEntries.Keys is all changed entities. All this stuff needed to update "views" of the entities. Views are just denormalized data of the main events, they also have references, this is why I cannot use IPreUpdateEventListener.
Mike Chaliy
+1  A: 

Well, best solution I've found is using PersistenceContext.

foreach (var entity in eventSource.PersistenceContext.EntityEntries.Keys)
{
    // entity is entity to update...
}

Not sure if this is right solution, however.

Mike Chaliy