Building Microservices with .NET Core
by Soumya Mukherjee, Gaurav Aroraa, Lalit Kale, Manish Kanwar
Adding a repository
In our monolithic application, we have a common repository throughout the project. In ProductService, by virtue of following all the principals learned until now, we will create microcomponents, which means separate repositories encapsulating the data layer.
A repository is nothing but a simple C# class that contains logic to retrieve data from the database and map it to the model.
Create a new folder and name it Persistence. Add the IProduct interface and a Product class that will implement the IProduct interface. Again, we named the folder Persistence in our effort to follow the general principal for easy identification. The following code snippet provides an overview of the Product class (it is still without any implementation ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access