5
我用这个代码来定义我的存储过程使用存储过程(代码第一)
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 [email protected]
END
,这是我的C#代码:
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();
}
问题是在这里:
我想从Orders
表中发送数据,我的存储过程会生成这个给我。我怎样才能得到我的C#代码中的Orders
数据?记住我只想执行一次这个存储过程。
tnkx为你很好和完整answer.but现在,我怎样才能从我的存储过程中选择linq的动态类型。 – 2012-01-11 06:11:26
即时通讯不是100%肯定,但类似var customers = context.Database.SqlQuery(“SP @Country”,categoryParam).ToList();将可能是正确的 –
2012-01-11 07:14:31
tnkx我会尝试你的解决方案 – 2012-01-11 07:16:27