CSLA 4 BusinessRules Bug?

CSLA 4 BusinessRules Bug?

Old forum URL: forums.lhotka.net/forums/t/9102.aspx

Geoff_Manning posted on Thursday, June 17, 2010

Ok, I feel like I'm losing my mind. Someone please help me out. I'm doing something as simple as

protected override void AddBusinessRules() {


    BusinessRules.AddRule(new Csla.Rules.CommonRules.MinLength(SomeProperty, 2));


and that will NOT set the IsValid to false when it has less than 2 characters in it, HOWEVER, adding the dataannotation  [StringLength(20, MinimumLength=2)] works as expected, meaning that in the callback for the NewBusinessObject() the DataPortalResult.Object has IsValid set to false, whereas using the AddBusinessRules() route it comes back with IsValid set to true. Please don't tell me just to use the dataannotation, because this is just trhough troubleshooting that I found that at the most basic level it's not working in AddBusinessRules(), but I ultimately need to add other business rules that there are no dataannotations for.

Geoff_Manning replied on Thursday, June 17, 2010

Ok, I WAS losing my mind, or at least not using it.  I had the AddBusinessRules() method wrapped in an #if !SILVERLIGHT, so it wasn't running on the silverlight side

Copyright (c) Marimer LLC