...

/

Data Repositories for Entities and Web API Controller

Data Repositories for Entities and Web API Controller

Learn about creating a data repository for CRUD operations, implementing it asynchronously, and designing a Web API controller.

Creating data repositories for entities

Defining and implementing a data repository to provide CRUD operations is good practice. The CRUD acronym includes the following operations:

  • C for Create

  • R for Retrieve (or Read)

  • U for Update

  • D for Delete

Press + to interact

We will create a data repository for the Customers table in Northwind. There are only 91 customers in this table, so we will store a copy of the whole table in memory to improve scalability and performance when reading customer records.

Note: In a real web service, we should use a distributed cache like Redis, an open-source data structure store that can be used as a high-performance, high-availability database, cache, or message broker.

Make repository API asynchronous

We will follow a modern good practice and make the repository API ...