public class MyUpdateListener : IPreUpdateListener
{
public开发者_运维问答 bool OnPreUpdate(PreUpdateEvent @event)
{
// What do I return from this method - true or false?
}
}
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.
精彩评论