Abstracting a Service for a Blazor Component
Learn about abstracting service for a Blazor component, ensuring compatibility with both Blazor Server and WebAssembly, and utilizing EditForm for streamlined form handling.
We'll cover the following...
We'll cover the following...
Abstracting a service for a Blazor component
Currently, the Blazor component directly calls the Northwind database context to fetch the customers. This works fine in Blazor Server since the component executes on the server. However, this component would not work when hosted in Blazor WebAssembly.
We will now create a local dependency service to enable better reuse of the components:
Step 1: In the Northwind.BlazorServer
project, in the Data
folder, add a new file named INorthwindService.cs
. The Visual Studio project item ...