title: In using WCF, What data structure do I use to return a SQL Server query result that is formatted using FOR XML?
body: <p>I'm using WCF to create a service that will query my SQL Server DB and return the response in a specific XML layout (shown here)</p>
  
  <pre><code>&lt;SUP_LOCS&gt;
      &lt;SUP_LOC&gt;
          &lt;SUP_LOC_ID_DESC&gt;Memphis TN&lt;/SUP_LOC_ID_DESC&gt;
          &lt;QTY_AVL&gt;6&lt;/QTY_AVL&gt;
          &lt;ITEM_UOM&gt;EA&lt;/ITEM_UOM&gt;
      &lt;/SUP_LOC&gt;
      &lt;SUP_LOC&gt;
          &lt;SUP_LOC_ID_DESC&gt;Los Angeles CA&lt;/SUP_LOC_ID_DESC&gt;
          &lt;QTY_AVL&gt;1&lt;/QTY_AVL&gt;
          &lt;ITEM_UOM&gt;EA&lt;/ITEM_UOM&gt;
      &lt;/SUP_LOC&gt;
  &lt;/SUP_LOCS&gt;
  </code></pre>
  
  <p>I am using FOR XML to make SQL Server produce the XML. This gives me the correct XML format I show above.</p>
  
  <pre><code>select location [Sup_LOC_ID_DESC] ...(shortened for brevity)... FOR XML raw('SUP_LOC'), root('SUP_LOCS'), elements
  </code></pre>
  
  <p>My question is what data structure should I use in my method? (shown here). In my example, I am using string but when I use the WCF test client, my response doesn't look like I thought it would (see image below)</p>
  
  <pre><code>public string GetInventory(string itemID)
  {
      inventoryQuery = string.Format(inventoryQuery, itemID);
      string queryResult = _sub.Database.SqlQuery&lt;string&gt;(inventoryQuery).FirstOrDefault();
      return queryResult;
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/bd6yh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bd6yh.png" alt="enter image description here"></a></p>