Home  /  Questions  /  Question



50   50
Aug 07, 2015


Spark 4.5 and Nullable(Of T)

When defining a class to hold a datatable should Nullable(Of T) be used or avoided?
Partial Public Class UserClaim
        Inherits Entity(Of UserClaim)

        Public Sub New()
            MyBase.New(False)
        End Sub
        Public Sub New(ByVal defaults As Boolean)
            MyBase.New(defaults)
        End Sub

        Public Property Id As Nullable(Of Long) = Nothing
        Public Property User_Id As Nullable(Of Long) = Nothing
        Public Property Claim_Type As String = String.Empty
        Public Property Claim_Value As String = String.Empty
        Public Property Created_On As Nullable(Of DateTime) = Nothing
        Public Property Created_By As Nullable(Of Long) = Nothing
        Public Property Updated_By As Nullable(Of Long) = Nothing
        Public Property Updated_On As Nullable(Of DateTime) = Nothing
    End Class

 



508   99.9
Aug 10, 2015
Hello Elliot:

When a column is nullable in the database you make the class property also nullable. 
The only exception is String because they are nullable by default.  

Hope this helps.
Jack