Blazor Data Access Strategies
In this article, we will explore data access strategies in Blazor web application,
- Client -> Blazor Server -> Database
In this approach Client and Blazor server communication will happen through SignalR and further it will communicate with Database directly using EF core or some other method.
Use this approach only when in the future you don’t want to convert your app into web assembly because EF core will not run on the client-side.
2) Client -> Blazor Server -> Restful Service -> Database
We included Restful service in between Blazor server and Database as restful service will be running on .net core server so have access to database communication capabilities. So with this architecture we can easily switch between two hosting models with the minimal changes.
REST => Representational State Transfer
REST is a pattern for creating API
REST API allows applications to interact with each other and allows the transfer of data.
Example of temperature app was client send and request to rest server with the city name and the server will respond with temperature for that particular city.
REST Constraints:
1) Client-Server: Requirement at least client and server in the application
2) Stateless: Communication between client and server is stateless means we can not store anything on server related to client and server ensures that each request from the client treated independently.
3) Cacheable: Some data provided by the server does not change often this constraint says let the client know how long this data good for so the client does not need to come back again to the server for that data over and over again.
4) Uniform Interface: This constraint defines the interface between client and server
https://localhost:44398/api/employees
https — Protocol
localhost:44398 –Domain name
api — Optional
employees — EndPoints
So, each resource identified by URI(Uniform resource identifier)
Thank You, See you in the next article !!
You can reach out to me here,
LinkedIn: https://www.linkedin.com/in/vaibhav-bhapkar
Email: vaibhavbhapkar.medium@gmail.com
If you want some technical topics to be discussed with group of participants please raise a request on following link: http://myblogsenquiry.somee.com/