views:

104

answers:

1
public class MyUpdateListener : IPreUpdateListener
{
    public bool OnPreUpdate(PreUpdateEvent @event)
    {
           // What do I return from this method - true or false?
    }
}
+3  A: 

I've wondered about this too and was unable to find a definitive answer. So I pulled down the 2.1.1.GA source code and found the answer: returning true from OnPreInsert, OnPreUpdate, or OnPreDelete will veto (i.e. cancel) the respective insert, update, or delete operation. The remainder of the "Pre" listeners return void.

The most common use of IPreInsertListener and IPreUpdateListener is to add record level auditing and for those tasks you should return false.

Jamie Ide