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