Hello,
I'm trying to add some history info about insert,update,delete events.
With log4net, or another way (separate session) it is works. But I'm trying
to do it in same transaction with the process.
For that case,
I've created a event listener class;
public class AuditEventListener :
IPostUpdateEventListener,IPostInsertEventListener,IPostDeleteEventListener
And i've created a History entity class.
In the events i've wrote,
public void OnPostInsert(PostInsertEvent @event)
{
//no history for History type, and prevents recurrence
if (@event.Entity.GetType().Equals(typeof(History)))
return;
History history = new History();
.....
.....
@event.Session.Save(history);
}
But it seems, I'm breaking the queue action of nHibernate :(
It is about NHibernate.Engine.ActionQueue class'es ExecuteActions method.
private void ExecuteActions(IList list)
{
foreach (IExecutable executable in list)
Execute(executable);
list.Clear();
session.Batcher.ExecuteBatch();
}
it throws an InvalidOperationException (Collection was modified; enumeration
operation may not execute.).
It is totally understandable issue. (i'd add another action to queue while
nhibernate processing the queue)
Do you have any suggestion to do this thing in another way???
If not, i can change the code of
NHibernate.Engine.ActionQueue.ExecuteActions methods to prevent this error.
(I'm not sure, if i change, it will throws another exception in another
method.)
(Changing the nhibernate source is the last way i think.)
Thanks.
--
Fethi Gürcan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---