Dofactory.com
Dofactory.com
 Back to list
Views:   5.5K
Replies:  1
Archived

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

 
Elliott Ward, Aug 07, 2015
Reply 1
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
Jack Poorte, Aug 10, 2015
Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Cookies       Do Not Sell       Licensing      
Made with    in Austin, Texas.  - vsn 44.0.0
© Data & Object Factory, LLC.