I am using CSLA, latest version. I have created some basic business rules and I am trying to update the object with changes in UI and then set values to object and then call save. I would think on the save, rules would be checked and an exception would be thrown. I am having to call ValidationRules.CheckRules(); on _Update to get rules to run.
Current way I am having to do it:
obj = BLL.GLEventInfo.GetGLEvent(Me.GLEventList.SelectedEvent.GLEventID)
Csla.Data.DataMapper.Map(Me.GLEventList.SelectedEvent, obj, New String() {"IsEstimatedYesNo"})
Me.PopulateBOFromControls(obj)
obj.Save()
If obj.BrokenRulesCollection.Count > 0 Then
End If
It's largely up to you how you want to implement this.
A common pattern is to call ValidationRules.CheckRules() when the object is *created*, and so the process of setting properties can fix any broken rules if the proper values are supplied. This should avoid the need to call CheckRules() again when the object is saved.
It's also possible to associate rules with a "pseudo" property (e.g. CSLA doesn't care if the property name associated with a rule is actually a real property or not) to defer processing of those rules until save time. Then you can call ValidationRules.CheckRules("pseudopropertyname") in your Save method to fire only these special server side rules.
Copyright (c) Marimer LLC