This code works for me very well:
if (someStr == null)
da.InsertCommand.Parameters.Add("@SOMESTR", SqlDbType.NVarChar).Value = DBNull.Value;
else
da.InsertCommand.Parameters.Add("@SOMESTR", SqlDbType.NVarChar).Value = someStr;
But my intuition tells me that there may be a one-liner version of it. Something like:
da.InsertCommand.Parameters.Add("@SOMESTR", SqlDbType.NVarChar).Value = someStr==null ? DBNull.Value : someStr ;
But the one-liner I just posted above fails of course because DBNull.Value doesn't cast to String.
Is there a way to accomplish the one liner I so desire?