title: .NET and MySql paramters, AddWithValue NULL variables, how to avoid to check for nulls
body: <p>Let's say I have a MySql stored procedure that inserts a record with some nullable CHAR fields.</p>
  
  <p>In VB.NET if I don't check for Nothing (or Null in other languages), I get an exception from the db driver, so I write:</p>
  
  <pre><code>command.CommandType = CommandType.StoredProcedure;
  command.Parameters.AddWithValue("_name", if(name Is Nothing, "", name)).Direction = ParameterDirection.Input;
  </code></pre>
  
  <p>And this is the first thing I don't like; I'd like to pass Nothing and the driver knows it has to put NULL in the Db. But then, in the stored procedure, I have to check back the field if it is empty:</p>
  
  <pre><code>INSERT INTO mytable
  (
      name,
  -- other 200 char fields
  )
  VALUES
  (
      NULLIF(_name, ''),
  -- other 200 char fields
  )
  </code></pre>
  
  <p>Ugly uh? I have to check for nothingness/emptiness twice. 
  Is there a better, more direct, way? </p>
  
  <p>Even worse, for non reference types (i.e: Integers) the check for nothingness makes no sense, since a primitive type can't be nothing (yes, I could set an Integer to a non meaningful value, say -1 for a positive id, but...). </p>