title: Linq check for null and replace null value in orderby
body: <p>I have a linq query where sometimes the string field, product name, may be empty, null.
  This is a new field in the table and if data hasn't been entered, then I get an error when running the query.  What I need to do is check for null and if null replace the null/empty value with the text value from a drop down list. I've tried several things but can't get it to work. </p>
  
  <pre><code>public IQueryable&lt;Product&gt; BindProduct([Control("ddProductName")] int? ProductNameId)
  {
     var prod = from c in _DbContext.Products
        where c.ProductNameId == ProductNameId
        orderby string.IsNullOrEmpty(c.ProductName) ? ddProductName.SelectedItem.Text : c.ProductName,
        c.ItemNumber
        select c;
        return prod;
  }
  </code></pre>
  
  <p><strong>CHANGED TO:</strong></p>
  
  <pre><code> public IQueryable&lt;Product&gt; BindProduct([Control("ddProductName")] int? ProductNameId)
      {
          var prodName = ddProductName.SelectedItem.Text;
          var prod = from c in _DbContext.Products
                     where c.ProductNameId == ProductNameId
                     let sortName = c.Name ?? prodName
                     orderby sortName, c.ItemNumber
                     select new { c, sortName };
          return prod;
  
      }
  </code></pre>
  
  <p><strong>UPDATE:</strong>
  I don't think I was clear.  What I need to do is check for null and if null replace the null/empty value with the text value from a drop down list.</p>