Building a Blazor data component
In this section, we will build a component that will list, create, and edit employees in the Northwind database.
We will build it over several steps:
- Make a Blazor component that renders the name of an employee, set as a parameter.
- Make it work as a routable page as well as a component.
- Build and call an ASP.NET Core Minimal APIs web service.
- Call the web service in the component.
Making the component
We will add the new component to the existing Blazor project:
- In the
Northwind.Blazor
project, in theComponents\Pages
folder, add a new file namedEmployees.razor
. - Add statements to output a heading for the
Employees
component and define a code block, defining a property to store the name of a country, as shown highlighted in the following markup:@rendermode InteractiveServer <h1>Employees @(string.IsNullOrWhiteSpace(Country) ? "Worldwide" : "in " +...