有没有人使用context.DataContext.ExecuteStoreQuery?我正在使用SqlEntityConnection从这样定义的存储过程中提取数据
CREATE PROCEDURE [dbo].[CustOrderHist] @CustomerID nchar(5)
AS
SELECT ProductName, Total=SUM(Quantity)
FROM Products P, [Order Details] OD, Orders O, Customers C
WHERE C.CustomerID = @CustomerID
AND C.CustomerID = O.CustomerID AND O.OrderID = OD.OrderID AND OD.ProductID = P.ProductID
GROUP BY ProductName
使用此F#代码
let RunCustomerStoredProcedure () =
let context = schema.GetDataContext()
let query = context.DataContext.ExecuteStoreQuery("CustOrderHist",new SqlParameter("CustomerID","AFKLI"))
query |> Seq.iter(fun (pn,t) -> Console.WriteLine(String.Format("{0} {1}",pn,t)))
但我得到了这个例外:
Procedure or function 'CustOrderHist' expects parameter '@CustomerID', which was not supplied.
答案 0 :(得分:0)
你试过这个吗?
let RunCustomerStoredProcedure () =
let context = schema.GetDataContext()
let query =
context.DataContext.ExecuteStoreQuery(
"CustOrderHist",
new SqlParameter("@CustomerID","AFKLI"))
query |> Seq.iter(fun (pn,t) -> Console.WriteLine(String.Format("{0} {1}",pn,t)))
请注意@
中的其他"@CustomerID"
。