This question is locked. New answers and comments are not allowed.
Hello,
I found a problem using an example of the Open Access ORM documentation. (http://documentation.telerik.com/openaccess-orm/developers-guide/code-generation/developer-guide-code-generation-implement-idataerrorinfo).
The implementation of the ValidateProperty method in this example has a problem. I tested it on a project by myself and found that if only one property of a business object is checked in this method and the validation of this field fails, all other properties of the object will have the same error message because '_error' field is shared by all of them. You have to initialize the error argument in the ValidateProperty method to empty before you check the properties.
I could be wrong, but that is the way I sort it out.
Thank you,
Lorenzo.
I found a problem using an example of the Open Access ORM documentation. (http://documentation.telerik.com/openaccess-orm/developers-guide/code-generation/developer-guide-code-generation-implement-idataerrorinfo).
The implementation of the ValidateProperty method in this example has a problem. I tested it on a project by myself and found that if only one property of a business object is checked in this method and the validation of this field fails, all other properties of the object will have the same error message because '_error' field is shared by all of them. You have to initialize the error argument in the ValidateProperty method to empty before you check the properties.
Partial
Public
Class
Category
Private
Sub
ValidateProperty(
ByVal
propertyName
As
String
,
ByRef
[error]
As
String
)
[error] =
""
'If you don't do this initialization, all the fields that follow the
'last that fails validation
'will share the same error message
Select
Case
propertyName
Case
"CategoryID"
If
CategoryID < 0
Then
[error] =
"The identification number of the category cannot be negative"
End
If
Case
"CategoryName"
If
String
.IsNullOrWhiteSpace(CategoryName)
Then
[error] =
"You need to provide a name for the category"
End
If
End
Select
End
Sub
End
Class
I could be wrong, but that is the way I sort it out.
Thank you,
Lorenzo.