I have setup a field string value in the BO Mapper custom field properties as follows:Return Alternate on Null/Set Null on Alternate (reference type)
NULL Replacement Value: ""
The problem is when I clear the field value on the form's control and save, the BO is writing an empty string back to the database instead of NULL.
However, when I modify your BO code by changing [If value IsNot "" Then] to
[If value.Length > 0 Then] (see modified code below), the logic works and the BO writes the NULL value back to the database.
What is going on here?
''' <summary>''' JobAddress''' </summary>''' <remarks></remarks><Browsable(
False), _BusinessFieldDisplayInEditor(), _
Description(
"JobAddress"), _DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Property [JobAddress]() As System.StringGetDim loValue As ObjectloValue =
Me.CurrentRow.Item("JobAddress")If loValue Is DBNull.Value ThenReturn ""ElseReturn CType(loValue, System.String)End IfEnd GetSet(ByVal value As System.String)' If value IsNot "" ThenIf value.Length > 0 ThenMe.CurrentRow.Item("JobAddress") = valueElseMe.CurrentRow.Item("JobAddress") = DBNull.ValueEnd IfEnd SetEnd Property