title: asp.net/C#: Handle datetime if null using LINQ
body: <p>I have null values in database specifically for Good Expiry Date, which is the field is:<code>good_expiryDate</code>.</p>
  
  <p>What i want is to handle it in this way:
  If <code>good_expiryDate</code> is null i want to present it as "" or "-", if it has value it will show the value retrieved from database?</p>
  
  <p>the LINQ query i write is like this, but it return <code>MinValue</code> if <code>good_expiryDate</code> is <code>null</code>(this is what i tried to do).</p>
  
  <pre><code>var query = (from cd in db.CDIndexes
               join gds in db.Goods on cd.cdin_CDIndexID equals gds.good_CDIndexId 
               join itms in db.Items on gds.good_ItemsID equals itms.item_ItemsID
  
              where
              cd.cdin_CompanyId==c.Comp_CompanyId&amp;&amp;
              (
                  gds.good_RemainCBM &gt; 0 ||
                  gds.good_RemainWT &gt; 0 ||
                  gds.good_RemainPackages &gt; 0 ||
                  gds.good_RemainVolumeWT &gt; 0
              )
              &amp;&amp;
              itms.item_ItemsID==customerId
  
              select new DataItem
              {
                   depNumber=(int)cd.cdin_Serial,
                   ItemDesc=gds.good_Name,
                   gdExpiryDate =(DateTime) gds.good_expiryDate==null?DateTime.MinValue: (DateTime)gds.good_expiryDate,
                   InvoicBalanceUnits = (decimal) gds.good_RemainPackages,
                   WTBal=(decimal)gds.good_RemainWT,
                   VolWT=(decimal)gds.good_RemainVolumeWT
              }
         );
  return query.ToList();
  </code></pre>
  
  <blockquote>
    <p>Update: good_expiryDate is type of Datetime, nullable in database</p>
  </blockquote>