title: Best practice of SingleOrDefault()
body: <p>I want to make my code better. Can I safely rewrite the first example to the second?</p>
  
  <pre><code>IQueryable&lt;PDF&gt; pdfList = (from pdfobj in pdfDataContext.PDFs
                             where pdfobj.Id == pdfId
                             select pdfobj);
  if (pdfList.Count() &gt; 0)
  {
    PDF pdfOldWay = pdfList.FirstOrDefault();
    pdfOldWay. // do something. (pdfOldWay can't be null here...)
  }
  </code></pre>
  
  <p>--</p>
  
  <pre><code>PDF pdfNewWay = (from pdfobj in pdfDataContext.PDFs 
                   where pdfobj.Id == pdfId 
                   select pdfobj).SingleOrDefault();
  if (pdfNewWay != null)
  {
    // do something
  }
  </code></pre>
  
  <p>--</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Sorry for not being clear. My issue is to get the PDF object out directly without having to use a list first. I don't want to make a check for count is greater than 0 and because it just doesn't look good.</p>