Seth
Seth

Reputation: 8373

Invalid Linq query using Where

I have the following code:

    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);
    }

I want to get the rows of orderDetails where the foreign key OrderId is equal to the parameter orderId. However I keep getting the following error: Error 2 Cannot implicitly convert type 'int' to 'bool'. What am I missing?

Upvotes: 0

Views: 162

Answers (2)

Kenneth J
Kenneth J

Reputation: 4896

where orderDetails.OrderId == orderId

Upvotes: 0

Marlon
Marlon

Reputation: 20332

where orderDetails.OrderId = orderId

Needs to be

where orderDetails.OrderId == orderId

Upvotes: 8

Related Questions