diff --git a/Modules.Language/Utils.vb b/Modules.Language/Utils.vb index d619ef7f..77a6e077 100644 --- a/Modules.Language/Utils.vb +++ b/Modules.Language/Utils.vb @@ -54,6 +54,7 @@ Public Class Utils ''' The type of the value ''' The value ''' The default Value + ''' The original value or the default value Public Shared Function NotNull(Of T)(ByVal value As T, ByVal defaultValue As T) As T If IsNothing(value) OrElse String.IsNullOrEmpty(value.ToString) OrElse IsDBNull(value) Then Return defaultValue @@ -62,6 +63,21 @@ Public Class Utils End If End Function + ''' + ''' Checks a Row value for three different `null` values, + ''' Nothing, Empty String, DBNull + ''' + ''' Returns the original value if the value is not null, or `defaultValue` + ''' + ''' The type of the value + ''' The DataRow that contains the value + ''' The column name + ''' The default value + ''' The original value or the default value + Public Shared Function NotNull(Of T)(ByVal Row As DataRow, Column As String, DefaultValue As T) As T + Return NotNull(Row.Item(Column), DefaultValue) + End Function + ''' ''' Creates a "slug" from text that can be used as part of a valid URL. ''' Invalid characters are converted to hyphens. Punctuation that Is