Property Before Change

Posts   
 
    
Gazley
User
Posts: 18
Joined: 17-Apr-2006
# Posted on: 20-Nov-2006 12:41:54   

Can anyone advise me whether LLBLGen Pro will generate entities that raise an event that fires just before an Entity property is about to be changed and if so, whether it can be cancelled in the event to abandon the update?

I note that LLBL implements the IPropertyChanged interface but I guess I am referring to and "IPropertyChanging" type scenario?

If not, can I configure LLBL to generate this event for each property?

Thanks.

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 20-Nov-2006 14:43:50   

Hello,

If you want to check a value before it is inserted in a field, you can overrides the "OnValidateFieldValue" method on each entity you want to add verifications. You can put your code in a partial class or also in the user code section. If you want to add a check on each entity, you may have to create a custom template which will generate your code.

Also you can use OnPropertyChanged(propertyName) which come from .net 2.0 framework. But if you want to generate a specific function from your field the better way it's to create a custom template.

Gazley
User
Posts: 18
Joined: 17-Apr-2006
# Posted on: 20-Nov-2006 16:59:35   

Hi

OnValidateFieldValue might do the trick. If you return false from this method, does this stop the assignment to the field?

Thanks.

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 21-Nov-2006 02:18:15   

Yes that is correct. You return true if the value should be accepted or false if not. If false is returned, the value is simply rejected and the field isn't set to the new value.