Performing Operations during Poco events (Insert, Update, etc) - schotime/NPoco GitHub Wiki

To do things when an entity is inserted, updated, deleted etc. you can write your own class inheriting from Database. You can then override methods like OnInsert, OnUpdate.

Example:

public class CustomDatabase : Database
    {
        protected override bool OnUpdating(UpdateContext updateContext)
        {
            var entity = updateContext.Poco as CommonEntity;
            if (entity != null)
            {
                entity.DateModified = DateTime.UtcNow;
            }
            return base.OnUpdating(updateContext);
        }
    }