Dear Frans,
I did manage to get the IFieldPersistenceInfo array out of the inherited Adapter. What I need now is the following:
- I need to find all fields that are not nullable
- Sort field out that are auto-filled (Identity, timestamps, Fields with defaults)
- Check for User-changes: TestOriginalFieldValueForNull works only on fetched entities and not on new ones, for new Entites I use IsChanged
As you can see from the code I did manage some of these issues what remains is:
- SourceColumnDbType returns an integer. How can I interpret this integer? do you use some enum to identify types?
- I don't know if the PersistenceInfo kann tell me if a column has a default value, is this possible?
Dim _fieldInfos As IFieldPersistenceInfo()
Dim _fieldInfo As IFieldPersistenceInfo
Dim _error As EntityValidationError
Dim i As Integer
_fieldInfos = New PersistenceInfoAdapter().GetPersistanceInfo(Me.Auftragsposition.LLBLGenProEntityName)
For i = _fieldInfos.GetLowerBound(0) To _fieldInfos.GetUpperBound(0)
If Not _fieldInfos(i).SourceColumnIsNullable AndAlso _fieldInfos(i).IsIdentity = False AndAlso _fieldInfos(i).SourceColumnDbType <> SourceColumnDbTypeEnumShouldoneExist AndAlso _
(Me.Auftragsposition.TestOriginalFieldValueForNull(Me.Auftragsposition.Fields(_fieldInfos(i).SourceColumnName).FieldIndex) _
Or Me.Auftragsposition.Fields(_fieldInfos(i).SourceColumnName).IsChanged = False) Then
_error = New EntityValidationError
_error.Message = "Feld darf nicht leer sein"
_error.MessageCode = "Validate_Auftragsposition_03"
_error.Source = _fieldInfos(i).SourceColumnName
MyBase.ErrorCol.Add(MyBase.ErrorCol.Count, _error)
End If
Next
Again, thank you very much for your support.