Upgrading from 3.8.1 to 4.2.2

Upgrading from 3.8.1 to 4.2.2

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

chethantr posted on Thursday, June 28, 2012

Hi all,

I have a project which is using CSLA 3.8.1 with .NET F/W 3.5 and now that has to be converted to 4.2.2 with .NET F/W 4.0. Now that i am facing some issues is changes in method names and properties. For instance, "ValidationRules" class has been changed to "BusinessRules". So similarly "Csla.Rules.CommonRules.IntegerMinValue" has been changed to what? is there any place where I can see comparision? Please respond as this issue has bcome showstopper for me. Your early response would be appriciated Huh?

Thanks in advance.

JonnyBee replied on Thursday, June 28, 2012


The best resource on how to use CSLA 4 is Rockys ebook series: http://download.lhotka.net/Default.aspx?t=UsingCsla4

Available for purchase here. http://store.lhotka.net/Store/tabid/1560/ProductID/22/List/1/Default.aspx

And of course also the change log for each release: http://www.lhotka.net/cslanet/ 

The 3.x rule engine is gone and there is an entire new rule engine where all rules are classes in 4.x.

chethantr replied on Friday, June 29, 2012

Thanks for quick response Mr.JonnyBee

I have a time constraint, I dont have enough time to read complete book. And change log is not so clear. Is there any other link where in I can get diff b/w various version, as I said I have very less time Sad

JonnyBee replied on Friday, June 29, 2012


Basic summery and few links in this release post:  http://forums.lhotka.net/forums/p/9260/43936.aspx 

chethantr replied on Thursday, July 19, 2012


sorry for posting the comments on diffeent threads. now its that  Csla.Validation had public void AddRule(RuleHandler handler, IPropertyInfo propertyInfo); in 3.V now AddRule has only 5 overloaded 1. methods AddRule(System.Type objectType, Csla.Rules.IAuthorizationRule rule, string ruleSet) 2. AddRule(System.Type objectType, Csla.Rules.IAuthorizationRule rule) 3. AddRule(Csla.Rules.IAuthorizationRule rule) 4. AddRule(Csla.Rules.IBusinessRule rule, string ruleSet) 5. AddRule(Csla.Rules.IBusinessRule rule)

now i am adding a rule BusinessRules.AddRule(CustomRules.ValidatingExtendedBindingListIsValid<IDeviceInfo>, _deviceListProperty); where ValidatingExtendedBindingListIsValid is a class and IDeviceInfo is an interface which implements CslaExtensions.IReadOnlyBase, IDeviceKey, IEquatable<IDeviceInfo>

public class ValidatingExtendedBindingListIsValid<T> : BusinessRule where T : class


               protected override void Execute(RuleContext context)


                var value = Utilities.CallByName(context.Target, context.OriginPropertyName, CallType.Get);

                //var rv = true;

                var validatingCollection = value as ValidatingExtendedBindingList<T>;

                if (validatingCollection != null)


                    var errorMessages = new List<string>(validatingCollection.ValidationErrors());

                    if (errorMessages.Count != 0)


                        var flattenedErrors = new StringBuilder();

                        foreach (var error in errorMessages)












now how do i add my rule?

JonnyBee replied on Thursday, July 19, 2012

create an instance of your rule and call BusinessRules.AddRule, ex:

BusinessRules.AddRule(new MyRule<type>(primaryProperty));

I do recommend that you buy the Using CSLA 4 : Creating Business Objects ebook. 

chethantr replied on Thursday, July 19, 2012

Yes, the class ValidatingExtendedBindingListIsValid was converted to implement BusinessRule , and as you see it does not have any constructor with no arguments. Also to add a point, i am bit new to OOPS conceptsCrying

chethantr replied on Friday, July 20, 2012


as recommanded by you, i got the ebook, but in ebook no where Csla.Validations.DecoratedRuleArgs is mentioned. Really feeling diffuculties in upgradation, why so many breaking changes?

JonnyBee replied on Friday, July 20, 2012

The ebook documents how to use CSLA 4.x - not 3.8x or migration to 4.x.

RuleArgs/DecoratedRuleArgs no longer exists in 4.x - you now use properties on your rule to pass/read values from the BO (possibly aided by the rule engine itself). 

The new rule engine provides the same progrmming model/unit testing experience no matter if he rule is sync or async and it is much easier to create generic - reusable rules. You should focus on understanding the new rule programming model - and how to wriite rules - rater the mapping fetures from the old rule engine. 

chethantr replied on Friday, July 20, 2012

any recommanded books for conversion? if not any link(except change log) in the site which clearly specify changes from version to version?

RockyRocks replied on Saturday, July 21, 2012

Doing an upgrade without allowing yourself time to learn the changes is a stressful route to have chosen. There are rarely shortcuts to learning new things.

What is forcing the upgrade? If you are running on full .NET then using multiple .NET frameworks is fine; you should be able to compile your app against .NET 4.0 even if using CSLA 3.8x

chethantr replied on Wednesday, September 12, 2012


Back with one more query, how to add the arguments to business rules?

JonnyBee replied on Wednesday, September 12, 2012

If you think of parameters that can be defined in AddBusnessRules then add as properties on the rule class and add as parameter to constructor.

See f.ex MaxLength rule that gets the maxlength as a parameter.

  public class MaxLength : CommonBusinessRule


    public int Max { get; private set; }


    public MaxLength(Csla.Core.IPropertyInfo primaryProperty, int max)

      : base(primaryProperty)


      Max = max;

      this.RuleUri.AddQueryParameter("max", max.ToString());

      InputProperties = new List<Core.IPropertyInfo> { primaryProperty };



Copyright (c) Marimer LLC