I use this code to define my stored procedure
CREATE PROCEDURE [dbo].[SP]
(@Country NVARCHAR(20))
AS
BEGIN
SET NOCOUNT ON;
SELECT c.*,O.* from Customers
as c inner join orders O on c.CustomerID=o.CustomerID
where c.Country=@Country
END
and this is my C # code:
IList<Entities.Customer> Customers;
using (var context = new NorthwindContext())
{
SqlParameter categoryParam = new SqlParameter("@Country", "London");
Customers = context.Database.SqlQuery<Entities.Customer>("SP @Country", categoryParam).ToList();
}
The problem is here:
I want to report data from a table Orders, and my stored procedure generates this for me. How can I get the data Ordersin my c # code? Remember that I want to execute this stored procedure only once.
source
share