我有以下代码:
public ActionResult Details(int orderId)
{
var query = from orderDetails in storeDb.OrderDetails
where orderDetails.OrderId = orderId
select new { orderDetails.Product, orderDetails.Quantity, orderDetails.UnitPrice };
return View(query);
}
我想得到orderDetails的行,其中外键OrderId等于参数orderId。但是我不断收到以下错误:Error 2 Cannot implicitly convert type 'int' to 'bool'
。我错过了什么?
答案 0 :(得分:8)
where orderDetails.OrderId = orderId
需要
where orderDetails.OrderId == orderId
答案 1 :(得分:0)
where orderDetails.OrderId == orderId