title: XML LINQ Select to Object - Using TryParse
body: <p>I'm using the following code to load a list of objects from XML using LINQ:</p>
  
  <pre><code>List&lt;Order&gt; TheList = 
      (from order in XMLResponse.Descendants("Order")
      select new Order
      {
          OrderDate = DateTime.Parse(order.Element("OrderDate").Value)
      }).ToList&lt;Order&gt;();
  </code></pre>
  
  <p>I would like to use DateTime.TryParse so that I can use DBNull values on the values that do not parse correctly so I can continue processing if there is an error.  I've tried this:</p>
  
  <pre><code> OrderDate = DateTime.TryParse(order.Element("OrderDate").value, out OrderDate)
  </code></pre>
  
  <p>But that code yields an invalid argument exception.</p>
  
  <p>I know I could use an intermediary class (with all string values) to load the values, but that seems like excessive code for what I'm trying to accomplish.  Is there a way to use TryParse in my code above?  Thanks</p>