Question

I have a custom attribute that accesses the database with nhiberate. The attribute actually inherits from Castle's AbstractValidationAttribute and is used to validate properties against regular expressions. Problem is, these regular expressions are cms managed and stored in the database, and when you change the values in the database, they are not reflected in the attribute. Basically, the attribute only initializes and there fore loads from the database once. Is there any way around this?

Thanks, Robin

No correct solution

OTHER TIPS

In my book it feels a bit odd to have an attribute perform database operations. That said, the attribute object is instantiated each time you call GetCustomAttributes for instance, so if the attribute picks up the data as part of its construction, it should fetch it whenever attributes are inspected using that method.

Attributes generally don't do anything. They are markers. Other code should use them to perform some operation based on the data used in the attribute.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top