OnEntityContentsChanged not overrideable

Posts   
 
    
HcD avatar
HcD
User
Posts: 214
Joined: 12-May-2005
# Posted on: 24-Aug-2012 16:55:10   

using LLBLGen 3.5, VS2010, SQL2008R2, Adapter

Hello,

I'm trying to create a routine for an "IsDirty" notification-mechanism in a WPF app.

I've been playing around with the IsDirty and ContainsDirtyContents but I really would need access to the OnEntityContentsChanged method. This method is not marked as virtual. almost all other OnXxxx methods in the framework are virtual. (see attached image).

Is there a reason for this method not to be virtual ?

Kind regards, Sven

Attachments
Filename File size Added on Approval
OnEntityContentsChanged.png 89,566 24-Aug-2012 16:55.39 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 25-Aug-2012 05:38:17   

HcD wrote:

Is there a reason for this method not to be virtual ?

Hi Syen, I don't know exactly why it isn't virtual. Could you expose your scenario in which you need it to be overrode?

BTW, you also could write a handler for EntityContentsChanged at CommonEntityBase.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 27-Aug-2012 10:52:57   

It's not virtual as it's an important method of the framework: the event must be raised to make the framework work. If we made it virtual, users would override it and might forget to call the base or do different things and avoid calling the base method, resulting in side effects which would be hard to track down.

For v4 we created a datascope, which monitors a conceptual scope with data. It keeps track of whether data in the scope is changed. We built this on top of the context. You could do that too: subclass the context, make sure you bind to the EntityContentsChanged event when an entity is added to the context, and this way use the context as an observer for the event. You might run into edge case problems though this way (we needed to make some changes internally to make it work 100%) but for simple cases you could do it this way.

Frans Bouma | Lead developer LLBLGen Pro