我有一段存储过程:
...
SELECT B.BinID, AverageCost, SUM(Qty) AS Qty
FROM #CurrentReturn R INNER JOIN Bins B ON R.BinCode = B.BinCode AND B.StoreroomID = @StoreroomID
...
@StorerroomID
是SP参数之一。
现在我正在尝试将其转换为LINQ to Entities,
var AverageCostList = from r in CurrentReturn
join b in BinQuery on new {r.BinCode, b.StoreroomID} equals new {b.BinCode, storeroomID}
它不起作用,如L.H.S.上的类型。 equals
的{}不能包含b。
那么有没有办法将这样的内连接SQL转换为LINQ?
答案 0 :(得分:1)
我会将B.StoreroomID = @StoreroomID
比较放入where where子句
from r in CurrentReturn
join b in BinQuery
on r.BinCode equals b.BinCode
where b.StoreroomID == storeroomID