EDN Admin
Well-known member
Hello.
I start recently to use Entoty Framework v4 in one of my projects.
Everything is ok, but now i have a problem with the validation.
I am using with great success now the Data Annotations Attributes mechanism. The application is in Win Forms. But now I created a custom validator class that is called only when the user clicks a button for example. My problem relies on the fact that the
IDataErrorInfo implementation never triggers to display to the user that the object is invalid unless he changes there that property that becomes like this invalid thorugh my custom attribute.
I searched for 2 days now a way to programatically call the PropertyChanged events, or ReportPropertyChanged on the object but i cannot do this as i am trying to do this from outside the object, more precisely from the validator class. I tried reflection
and it seemed to be a startup as i could get the event from the object. But as soon as i try to read its value, meaning to convert the Value of the PropertyChanged Event to a Multicast delegate and invoke it it returns null.
I tried with 20 different approaches from different programming sites.
I REALLY AM OUT OF IDEAS.
I think i am missing something. Maybe the EF has a way to do this, or maybe its another way to do. I dont understand why it is not easy to call the validation on all the properties when i want, not only on the changed ones.
Whats even more strange about this is that the object that i am displaying is a parent record which shows as details, and it has a child list which is displayed as grid. The bubbles from the grid are instantly displayed even if nobody else changes the values.
So the question is why on the main object it does not trigger the IDataErrorInfo to update the bubbles on the form, while on the child grid it does. Also if i breakpoint after calling to my method that validates mine validators it gets all the required error
messages, so the validator works as it should. It is just that it cannot display back to the user the Info Bubbles on the screen. I have errorprovider on the form, and it works ok with normal validation, like when user adds a new object, or when user invalidates
by selection something there.
Sorry for the very long explanation of my problem, and please help me if you can.
Thank you in advance.
View the full article
I start recently to use Entoty Framework v4 in one of my projects.
Everything is ok, but now i have a problem with the validation.
I am using with great success now the Data Annotations Attributes mechanism. The application is in Win Forms. But now I created a custom validator class that is called only when the user clicks a button for example. My problem relies on the fact that the
IDataErrorInfo implementation never triggers to display to the user that the object is invalid unless he changes there that property that becomes like this invalid thorugh my custom attribute.
I searched for 2 days now a way to programatically call the PropertyChanged events, or ReportPropertyChanged on the object but i cannot do this as i am trying to do this from outside the object, more precisely from the validator class. I tried reflection
and it seemed to be a startup as i could get the event from the object. But as soon as i try to read its value, meaning to convert the Value of the PropertyChanged Event to a Multicast delegate and invoke it it returns null.
I tried with 20 different approaches from different programming sites.
I REALLY AM OUT OF IDEAS.
I think i am missing something. Maybe the EF has a way to do this, or maybe its another way to do. I dont understand why it is not easy to call the validation on all the properties when i want, not only on the changed ones.
Whats even more strange about this is that the object that i am displaying is a parent record which shows as details, and it has a child list which is displayed as grid. The bubbles from the grid are instantly displayed even if nobody else changes the values.
So the question is why on the main object it does not trigger the IDataErrorInfo to update the bubbles on the form, while on the child grid it does. Also if i breakpoint after calling to my method that validates mine validators it gets all the required error
messages, so the validator works as it should. It is just that it cannot display back to the user the Info Bubbles on the screen. I have errorprovider on the form, and it works ok with normal validation, like when user adds a new object, or when user invalidates
by selection something there.
Sorry for the very long explanation of my problem, and please help me if you can.
Thank you in advance.
View the full article