i have the following sql command
var Query = new SqlCommand(@"SELECT [file] FROM [ApplicationSettings] WHERE [id] = @id And username=@username", con);
Query.Parameters.AddWithValue("@id", fileName);
Query.Parameters.AddWithValue("@username", userName ?? //then what?! );
the userName is a string (NVARCHAR in the sql), sometimes it has a value and sometimes its set to null, so i have 2 cases
username='someUserName'
username=Null
how can i achieve this in the current syntax without if statements or any additional checking
command.Parameters.Add("@Parameter", SqlDbType.VarChar).Value = parameterValue ?? DBNull.Value;