ValidationRules
Old forum URL: forums.lhotka.net/forums/t/7410.aspx
greengumby posted on Thursday, August 06, 2009
Could be a very simple problem but I added a
ValidationRules.AddRule(Csla.Validation.CommonRules.StringRequired, StkeyProperty);
and found that the only way I could get this rule to be run was as follows
set {
SetProperty(StkeyProperty, value);
ValidationRules.CheckRules(StkeyProperty);
}
Shouldn't SetProperty run the rules by default?
Thanks
JeremyJonnyBee replied on Thursday, August 06, 2009
Hi,
ValidationRules are checked only if the new value is different from old value.
And if you are not using BypassPropertyChecks properly you may also never return to the norpam property handling in SetProperty. BypassPropertyChecks should always have a using, ie
using (BypassPropertyChecks()) {
// set properties og Fetch or default values
}
// when leaving the using BO return to normal property handling
Maybe you could post your class code for inspection?
/jonnybee
greengumby replied on Thursday, August 06, 2009
Ahh yes I missed a CheckRules() on Create to set the broken rules up immediately so my new value of null was not different to the old value of null.
Thanks jonnybeeCopyright (c) Marimer LLC