Add Code to be run after successfully inserted entity

Posts   
 
    
Behdad
User
Posts: 12
Joined: 08-Jun-2010
# Posted on: 09-Jul-2010 22:24:13   

Hi I want to add some custom code as partial class.I want my code be run after a new entity successfully inserted to database and some other code to be run after entity get updated in database.How it is possible?

Regards

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 10-Jul-2010 03:50:00   

If you use Adapter, you can override OnSaveEntity in a partial class of DataAccessAdapter. This partial class should be in the same DBSpecific project.

If you use SelfServicing you can override OnSaveComplete in the involved Entity's partial class.

I both cases you can know if it was an Insert or Update checking the .IsNew property (true=Insert, false=update).

David Elizondo | LLBLGen Support Team
Behdad
User
Posts: 12
Joined: 08-Jun-2010
# Posted on: 10-Jul-2010 10:22:34   

Thanks for your reply.It can solve my problem but I want to include my code in separate entity partial classes to make it more readable.Should I use validator classes or there is a better way to do it?eg: I want to when a user creates a user , I make a mirror in another db.

Regards

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39903
Joined: 17-Aug-2003
# Posted on: 11-Jul-2010 18:10:08   

I'd use a trigger for that, inside the database, defined for INSERT.

Frans Bouma | Lead developer LLBLGen Pro