I've come across a bug in BO Mapper when adding a FieldChanging event to a field that allows nulls.
The following code was generated by the mapper. The "If value..." comparison always results to false,
since the value was set equal to the e.FieldValue in the prior line, resulting in the item always
being set to DBNull.
Set(ByVal value As System.Int32)
Dim e As New TestBOFieldChangingEventArgs(TestBOFieldNames.ta_tst_id, value)
Me.OnFieldPropertyChanging(Me, e)
value = CType(e.FieldValue, System.Int32)
If value <> CType(e.FieldValue, System.Int32) Then <---- Always False
Me.CurrentRow.Item("ta_tst_id") = value
Else
Me.CurrentRow.Item("ta_tst_id") = DBNull.Value
End IfEnd Set
Since I've configured the item to be Return Alternate on Null / Set Null on Alternate to 0
I believe the if statement should be "If value <> 0 Then" as it does when adding a FieldChanged event.
The following code was generated by the mapper for a field where Alternate on null was set to 0 with
both FieldChanged and FieldChanging events. The FieldChanged event code uses "If value <> 0" while the
FieldChanging event code is using "If value <> Ctyp..."
Set(ByVal value As System.Int32)
Dim e As New TestBOFieldChangingEventArgs(TestBOFieldNames.ta_tst_id, value)
Dim llRaiseEvent As Boolean = False
Dim loRow As DataRow = Me.CurrentRow
Me.OnFieldPropertyChanging(Me, e)
value = CType(e.FieldValue, System.Int32)
If value <> 0 Then
If Not loRow.Item("ta_tst_id").Equals(value) Then llRaiseEvent = True
Else
If Not loRow.Item("ta_tst_id").Equals(DBNull.Value) Then llRaiseEvent = True
End If
If value <> CType(e.FieldValue, System.Int32) Then
loRow.Item("ta_tst_id") = value
Else
loRow.Item("ta_tst_id") = DBNull.Value
End If
If llRaiseEvent Then Me.OnFieldPropertyChanged(Me, New TestBOFieldChangedEventArgs(TestBOFieldNames.ta_tst_id))
End Set