Using Nullable in BO


Author
Message
Kevin Lingofelter
Kevin Lingofelter
StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)StrataFrame Novice (123 reputation)
Group: Forum Members
Posts: 77, Visits: 804
Hello All!

I am setting up some fields in the mapper to Use Nullable Generic. This setting works ok if the field is a numeric type, but if the field is varchar, the code the mapper generates is causing the build to fail. Here is the code for the field:

''' <summary>
''' Test
''' </summary>
''' <remarks></remarks>
<Browsable(False), _
BusinessFieldDisplayInEditor(), _
Description(
"Test"), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
Public Property [Test]() As Nullable(Of System.String)
  Get
    Dim loValue As Object
    loValue = Me.CurrentRow.Item("Test")
   
If loValue Is DBNull.Value Then
       
Return CType(Nothing, Nullable(Of System.String))
   
Else
       
Return CType(loValue, Nullable(Of System.String))
   
End If
 
End Get
 
Set(ByVal value As Nullable(Of System.String))
   
If value.HasValue Then
     
Me.CurrentRow.Item("Test") = value.Value
   
Else
     
Me.CurrentRow.Item("Test") = DBNull.Value
   
End If
 
End Set
End Property

The hilighted code is giving the error:

Error 1 Type argument 'String' does not satisfy the 'Structure' constraint for type parameter 'T' ...

Anyone know why this is? Thanks!


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search