title: Linq stored procedure to return XML
body: <p>I am using Entity Framework code-first approach. I want to call a stored procedure from the <code>DbContext</code> class and to get XML output.</p>
  
  <p>Stored procedure (SQL Server):</p>
  
  <pre><code>CREATE PROCEDURE xml_test    
  AS
  BEGIN
      DECLARE @xml1 xml
  
      SET @xml1 = (SELECT * from Product FOR XML RAW) 
  
      SELECT @xml1 AS my_xml
  END
  </code></pre>
  
  <p>LINQ Entity Framework:</p>
  
  <pre><code>using (DBContext db = new DBContext())
  {
      var ProductList = await db.Database.ExecuteSqlCommandAsync("exec xml_test");
  }
  </code></pre>
  
  <p>Here the <code>ProductList</code> list is returning -1.</p>
  
  <p>I want to get the xml output which is returned by the stored procedure.</p>
  
  <p>Note: I have also tried methods like: <strong>ExecuteSqlCommand, SqlQuery</strong> with no help.</p>