DataAnnotation and BrokenRules collection...

DataAnnotation and BrokenRules collection...

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


ballistic posted on Wednesday, December 09, 2009

How does the DataAnnotation fit in with the BrokenRules collection?

If I have an object where I decorate some of my properties with DataAnnotation validation and then also have my own business rules which feed into the BrokenRules collection would I have two separate lists that have the with information about the property that failed the validation? Or is there something that combines them into one list?

Thank you,

 - Andres

RockfordLhotka replied on Wednesday, December 09, 2009

The validation attributes work (inside CSLA) exactly the same as a rule method. The attribute is invoked like a rule method, and its result is added to the broken rules collection like a rule method. In short, they are just another way to implement rule methods.

RockfordLhotka replied on Wednesday, December 09, 2009

Keep in mind, though, that you need to call base.AddBusinessRules() in your override in order to auto-register the attributes as rules.

 

Copyright (c) Marimer LLC