Async & Sync Rules with Same Priority

Async & Sync Rules with Same Priority

Old forum URL:

mosgath posted on Tuesday, February 22, 2011

I ran into a strange situation yesterday.  I have a business object that is a BusinessBase child.  It is four levels deep in the object hierarchy.  It uses the business rulesets depending on the type of material.  In each of the rulesets, I have an async rule to validate the model number in a backend system and retrieve description, price, etc.  I also have a rule that validates if the model number is allowed on the type of order.  I had the following in the AfterAddBusinessRules method:

            BusinessRules.AddRule(new Model.BusinessRules.ModelNumberValidationRule(ModelNumberProperty) { Priority = 3 });
            BusinessRules.AddRule(new Model.BusinessRules.ModelTypeOrderTypeValidationRule(ModelNumberProperty) { Priority = 3 });

Note that the priorities are the same.  The ModelNumberValidation is the async rule.  What is odd is that we were not getting the updates to the Model object from this rule unless I updated the context.Target referenced object directly.  The Return types of Error, Warning, or Information would not come back at all.  If I used the AffectedProperties and AddOutValue, nothing would return.  When I added the CSLA projects to my debugging session, I found that when this rule completed and was firing the Completed Event handler, it was passing in the rule information for the ModelTypeOrderTypeValidationRule and processed incorrectly.  I changed the priority levels so that ModelNumberValidation had a priority of 4 and everything worked.  I haven't been able to find any documentation that shows that Async and Sync rules cannot be part of the same priority level or that they need to be added in a specific order.  Did I miss this somewhere or is it a bug with the csla framework?  We are referencing the 4.0.1 framework.

Model Hierarchy:


RockfordLhotka replied on Tuesday, February 22, 2011

This is a bug that was resolved in version 4.1.

4.0.1 was an early beta (or pre-beta) release, I don't recommend its continued use.

mosgath replied on Tuesday, February 22, 2011

Thanks Rocky.

Copyright (c) Marimer LLC