I am using CSLA 4 and I created some object level validation rules but they do not seem to be invoked automatically by the CSLA base classes.
What is the recommended way for this to happen?
Is this taken care of automatically by the CSLA or do the inheriting classes need to explicitly call CheckRules before Save so we can show to the user all the broken rules if there are any?
You need to explicitly trigger object-level rules to run by calling CheckRules() or CheckObjectRules().
There is no data binding convention by which these rules can be automatically triggered, so it is left to you to determine when they should run.
You should be aware that calling
will NOT raise OnPropertyChanged to update the UI if you use AddOutValue to set fields in your BO.
So, I have added <bo>.CheckObjectRules() to BusinessBase for the next release that will notify UI of updated properties.
If you wish to call CheckObjectRules when a property has been changed you should either add that code to the property set method or override PropertyHasChanged (and NOT OnPropertyChanged) in you BO.
Copyright (c) Marimer LLC