title: SQL Database with XML fields, select according to XElement using LINQ
body: <p>I have a table in an SQL database, where the table configuration corresponds to</p>
  
  <pre><code>ID
  Name string
  data xml
  </code></pre>
  
  <p>where the datafield might (but not necessarily) contain a descendant element</p>
  
  <pre><code>&lt;config&gt;Some value...&lt;/config&gt;
  </code></pre>
  
  <p>Using LINQ I want to select all the rows that has a data xml element which contains the config element with a value of... say 17.</p>
  
  <p>My approach has been something like:</p>
  
  <pre><code>var query = from x in db
              from y in x.data.descendants("config")
              where y.Value == "17"
              select x;
  </code></pre>
  
  <p>But this throws an exception about the Value not being valid.</p>
  
  <p>How should I formulate this query?</p>
  
  <p>Regards, Casper</p>