title: Filter a query using value of XElement within XML using LINQ C#
body: <p>Using LINQ C#, I am querying a database table. The table has a column which contains XML and I would like to filter the results based on an element's value inside the XML being equal to a predefined string. I am using the following query:</p>
  
  <pre><code>(from data in DataObjects.Items
  where data.DataItemTimeUtc &lt; DateTime.UtcNow &amp;&amp; 
  data.DataItemXml.XDocument
     .Descendants("Items")
     .Descendants("MetaData")
     .Descendants("Device")
     .First().Value == "abc123"
  orderby data.DataItemTimeUtc descending
  select data).ToArray();
  </code></pre>
  
  <p>but it is failing with an error:</p>
  
  <blockquote>
    <p><em>The expression of type 'System.Collections.Generic.IEnumerable`1[System.Xml.Linq.XElement]'
    is not a sequence</em></p>
  </blockquote>