The returned value in this case should be enum, Let's use the name OnPreEventResult
, and these would be the possible values:
OnPreEventResult.Continue
=> to continue currently returnfalse
OnPreEventResult.Break
=> at the moment, when thetrue
is returned the Action is aborted
So, as both examples above show, we can use the return value to manage the execution flow:
to Continue:
If we in theAuditEventListener
return false, we in fact return something likeOnPreEventResult.Continue
. We've made some custome logic, and we want NHibernate to continue... so the false is returnedto Break/Abort:
Ayende's example is showing us how to change the real DELETE into UPDATE. Update is called explicitly@event.Persister.Update(...
and the delete is not executed due to the returned value true, i.e.OnPreEventResult.Break
In the code, the returned values are stored in local variable called veto
, which is again more self descriptive.
See:
A snippet from the EntityInsertAction
, the Execute()
method:
...
bool veto = PreInsert();
if (!veto)
{
persister.Insert(id, state, instance, Session);
...