Before / After Save

Posts   
 
    
lotek
User
Posts: 56
Joined: 14-Sep-2005
# Posted on: 12-Jul-2010 20:51:30   

What is the cleanest way to execute code before and after an entity is saved.

EG: I want to save a "Person".

Before Save: If age > 60 then set retired = true

Post Save: If retired = true then email someone

I want these pre/post save behaviors to happen each time the entity is saved where it is through the SaveEntity or SaveEntityCollection method. Ideally, this would be part of my existing business layer. I know there is an "AfterSave" event, but i dont see a "BeforeSave" event.

Thanks, Matt

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Jul-2010 07:01:35   

Personally I would put that kind of logic directly in the business class. If you like to do something with LLBLGen Framework features you case create your own Validator, and then override the ValidateEntityBeforeSave and ValidateEntityAfterSave. More info...

David Elizondo | LLBLGen Support Team