title: Exception handling within a LINQ Expression
body: <p>I have a simple LINQ-expression like:</p>
  <pre class="lang-cs prettyprint-override"><code>newDocs = (from doc in allDocs
             where GetDocument(doc.Key) != null
             select doc).ToList();
  </code></pre>
  <p>The problem is, GetDocument() could throw an exception. How can I ignore all doc-elements where GetDocument(doc.Key) == null or throws an exception?</p>
  <p>The same code in old school looks like:</p>
  <pre class="lang-cs prettyprint-override"><code>foreach (var doc in allDocs)
  {
      try
      {
          if (GetDocument(doc.Key) != null) newDocs.Add(doc);
      }
      catch (Exception)
      {
          //Do nothing...
      }
  }
  </code></pre>