title: How to work with null, dbnull and datetime in short if condition
body: <p>I retrieve some datetime data from SQL-Server. In my Web.Api Controller, I advise the database data to my object.</p>
  
  <p>This works:</p>
  
  <pre><code> if (reader["images_lastupload"] == DBNull.Value)
   {
        mydata.ImagesLastUpload = null;
   }
   else
   {
        mydata.ImagesLastUpload = Convert.ToDateTime(reader["images_lastupload"].ToString());
   }
  </code></pre>
  
  <p>The db field "Images_lastupload" can be NULL. So I want to check this.</p>
  
  <p>mydata.ImagesLastUpload is a nullable datetime. Everything works fine.</p>
  
  <p>But the short Version does not work:</p>
  
  <pre><code> mydata.ImagesLastUpload = (reader["images_lastupload"] == DBNull.Value) ? null : Convert.ToDateTime(reader["images_lastupload"].ToString());
  </code></pre>
  
  <p>How can I make the short Version work? My German error is:</p>
  
  <p><em>Der Typ des bedingten Ausdrucks kann nicht bestimmt werden, weil keine implizite Konvertierung zwischen '' und 'System.DateTime' erfolgt.</em></p>