문제

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

올바른 솔루션이 없습니다

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top