I'm having exactly the same problem, after reading the manual?
My questions:
1) How do I know the entity is invalid (see code below)?
2) Rather than throw exceptions can I append error messages and mark the entity invalid?
3) Assuming "Yes" to 2), how do I access the error message?
I'm creating 3-tier remoting app. To minimze chat I want the option to validate entities on client and/or the business layer thru entity.ValidateEntity.
I have a validator object:
Public Class MemberValidator
Inherits ValidatorBase
Public Overrides Sub ValidateEntity(ByVal involvedEntity As IEntityCore)
Dim toValidate As MemberEntity = CType(involvedEntity, MemberEntity)
If toValidate.Fname Is Nothing Then
Throw New ORMEntityValidationException("Frist name can't be null", toValidate)
End If
...
MyBase.ValidateEntity(involvedEntity)
End Sub
End Class
Now suppose the client creates a Member entity and, as below, enters an invalid value, how can I confirm the validity of the entity before communicating with the server? I am heading in this direction:
Dim oMem As New MemberDetails
oMem.Member.Fname = Nothing
Dim memVal As New MemberValidator
Member.Validator = memVal
Member.ValidateEntity()
' Now what? How do I know MemberDetails is invalid...?
BTW, MemberDetails is in a thin wrapper class that holds an an instace of my LLBLB member entity. Don't think this affects matters here?
Am using LLBLG v2.0, VB.Net 2005.
Really appreciate your help here. This is a big brick wall at the moment.