DataAccessAdapterBase Events

Posts   
 
    
vhtas
User
Posts: 20
Joined: 04-Aug-2008
# Posted on: 04-Aug-2008 19:46:42   

New to LLBLGen here. I've searched but couldn't find the answer to this one.

I'm trying to override the events in DataAccessAdapterBase. I need to differentiate between UPDATE/DELETE/INSERT events. I see OnSaveEntityComplete and OnDeleteEntityComplete but no OnUpdateEntityComplete.

There's an OnUpdateEntitiesDirectlyComplete event but it doesn't provide the entity being updated.

Thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Aug-2008 03:03:12   

Hi there.

You can use OnSaveEntityComplete. inside that, if

entityToSave.IsNew == true

then an INSERT is going to be performed, UPDATE otherwise.

David Elizondo | LLBLGen Support Team
vhtas
User
Posts: 20
Joined: 04-Aug-2008
# Posted on: 05-Aug-2008 19:40:08   

Thanks!

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 06-Aug-2008 00:08:51   

It seems to me like you could use an Auditor in conjunction with Dependency Injection with better results.

vhtas
User
Posts: 20
Joined: 04-Aug-2008
# Posted on: 06-Aug-2008 16:15:50   

Seth wrote:

It seems to me like you could use an Auditor in conjunction with Dependency Injection with better results.

I just checked out Auditor and it looks like it would certainly meet our needs. Which approach is recommended if you need to perform an action on a changed entity event? In our case we need to send a notification to a queue of the event.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 06-Aug-2008 17:21:58   

Which approach is recommended if you need to perform an action on a changed entity event? In our case we need to send a notification to a queue of the event.

Please be more specific, what exactly do you mean by an entity's change event? which change exactly are you after?

vhtas
User
Posts: 20
Joined: 04-Aug-2008
# Posted on: 06-Aug-2008 18:00:52   

I'm referring to INSERT/UPDATE/DELETE events.

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 06-Aug-2008 18:45:01   

I would use the auditor because of several reasons

  • It uses dependency injection (better separation of concerns)
  • You can add a default auditor to a entity base object to take care of ALL auditing (I remember this being so)
  • You get to tell your friends you've used IoC (inversion of control). Just think of the 'oohs' and 'aahs'
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 07-Aug-2008 05:33:44   

Indeed, Auditing would be a nice possibility here.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 07-Aug-2008 10:52:30   

You get to tell your friends you've used IoC (inversion of control). Just think of the 'oohs' and 'aahs'

smile

Frans Bouma | Lead developer LLBLGen Pro