Just hit on an interesting issue. We had an object that was generating the old "Object is not valid and cannot be saved" exception. It turned out that the property causing this was of type List<string>. We were adding to the property using the Add method of the List but of course this does not make use of the setter in a property and therefore PropertyHasChanged never gets fired and the object remains invalid even though it should be valid. We had to create a new inherited List<T> class that provides Add & Remove methods that fire an event ListHasChanged. The BO then subscribes to this event and calls ValidationRules.CheckRules when it gets triggered. This seemed like a lot of work and I am wondering if there is a better or preferable approach to the problem?
Would appreciate any feedback.
Hi Andy
There are acually three List<T> properties and we have a custom rule saying that the object is not valid if none of the three properties contains any strings. A BLB object does not feel right because the list is so simple - it has no key info or any fields other then the one simple string. The IsValid override is an interesting thought, but I am not sure if it is better than our approach.
Thanks.
Copyright (c) Marimer LLC