I am a C# programmer but dabbling in VB.Net because everybody else in my team uses it. In the interests of professional development I would like to shrink the following If... Else... statement.
If cmd.Parameters("@whenUpdated").Equals(DBNull.Value) Then
item.WhenUpdated = Nothing
Else
item.WhenUpdated = cmd.Parameters("@whenUpdated").Value
End If
I appreciate examples are already available however I can not get it working for this specific case.
Cheers, Ian.
Use If as a function rather than a statement:
item.WhenUpdated = If(cmd.Parameters("@whenUpdated").Equals(DBNull.Value), cmd.Parameters("@whenUpdated").Value, Nothing)