Search⌘ K
AI Features

Querying a Database and Using Display Templates

Explore how to implement price-based filtering of products by querying the Northwind database in an ASP.NET Core MVC application. Learn to create action methods with query parameters, use view models and ViewData, and build display templates to render filtered results efficiently.

Let’s create a new action method with a query string parameter passed to it and use that to query the Northwind database for products that cost more than a specified price.

Implementing price-based filtering

We defined a view model containing properties for every value that needed to be rendered. In this example, there will be two values: a list of products and the price the visitor entered. To avoid ...