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 ...

Get Building Microservices with .NET Core now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.