Search code examples
c#csla

Is it possible to have AuthorizationRule on CSLA CriteriaBase


Is it possible to have AuthorizationActions.WriteProperty rules on a CriteriaBase in CSLA ?

I have a screen with a bunch of filters and I want to enable only those that the user has access (ex: some user can't search in other regions).


Solution

  • No, CriteriaBase doesn't support any rules. There's no requirement to subclass it though for criteria type classes; you can use BusinessBase<T> as your criteria subclass, which will support authorization and validation rules.

    I believe the current recommendation is to move way from using CriteriaBase at all, especially since newer versions can pass multiple simple types or types which implement IMobileObject directly, so you'd really only need a class to represent your criteria if there needs to support business rules, such as your authorization rule, or perhaps a validation rule that requires a minimum number of criteria properties to be set.