Per type rule example

Per type rule example

Old forum URL:

correodemarques posted on Saturday, May 11, 2013


I have a business object for which I need to make some validations that involve several properties of the object and more data that I will need to read from the database. I'm using this object in an MVC application and I though that will be better to run this validation once, after all the related properties are set. In other objects with regular rules I usually suppress the rule checks, set all the properties and then call CheckRules before saving.

Should I use a Per-Type rule? I was looking the ebook "Creating business objects" and couldn't find any example or to much detail about per-type rules.

I would like somebody to point me in the right direction.

Thanks in advance.

JonnyBee replied on Saturday, May 11, 2013


Chapter 4 is all about Business Rules and CSLA 4 only has Per-Type rules. Are you referring to object level rules?

Object level rules is just as any other business rule - only that PrimaryProperty is null (not set).

Look at the ICheckRules interface:

namespace Csla.Core
  public interface ICheckRules
    void SuppressRuleChecking();
    void ResumeRuleChecking();
    void CheckRules();
    BrokenRulesCollection GetBrokenRules();

Depending on WHEN you want the rule to execute you could

When you call CheckRules the object level rules is executed first - then the property level rules.

correodemarques replied on Saturday, May 11, 2013

Ohh, I see. Yes, I was talking about object level rules and I was missing the fact that they are like a regular rule with the primary property null.

Thanks Jonny.

Copyright (c) Marimer LLC