Before Save Entity

Posts   
 
    
bjacobs
User
Posts: 73
Joined: 20-Aug-2008
# Posted on: 25-Jan-2010 23:52:46   

Adapter Version 2.6.08.1013 Windows Client references SD.LLBLGenPro.ORMSupportClasses.NET20 When I Generate My DataModel I am targeting the .Net Framework 3.5 Have .Net Framework 3.5 SP1 installed.

Is there an event I can attach to where I can perform an operation on an entity when Save is called on the entity but before the actual save is performed?

Example: I have a Medication Order, a Fluid Order, and a Lab Order. All three inherit from Order and all have an OrderString property. When save is called on any of these objects I would like to set the OrderString property just before it is actually saved. I would also like to do this in one place if possible such as in the base OrderEntity class. I am looking for an event such as an OnBeforeSave or something to that effect.

Thanks,

Billy Jacobs

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Jan-2010 03:58:09   

Hi Billy,

As a matter of fact you can override **OnBeforeEntitySave **in your OrderEntity:

protected override void OnBeforeEntitySave()
{
    // your logic
    ...

    // call the base
    base.OnBeforeEntitySave();
}
David Elizondo | LLBLGen Support Team