In the HomeController class, import the Microsoft.EntityFrameworkCore namespace. We need this to add the Include extension method so that we can include related entities.
Add a new action method, as shown in the following code:
public IActionResult ProductsThatCostMoreThan(decimal? price) { if (!price.HasValue) { return NotFound("You must pass a product price in the query string, for example, /Home/ProductsThatCostMoreThan?price=50"); } var model = db.Products.Include(p => p.Category).Include( p => p.Supplier).Where(p => p.UnitPrice > price).ToArray(); if (model.Count() == 0) { return NotFound($"No products cost more than {price:C}."); } ViewData["MaxPrice"] = price.Value.ToString("C"); ...