Defining and implementing a data repository to provide CRUD operations is good practice:
- C for Create
- R for Retrieve (or Read)
- U for Update
- D for Delete
We will create a data repository for the Customers table in Northwind. We will follow modern good practice and make the repository API asynchronous.
In the NorthwindService project, create a Repositories folder.
Add two class files to the Repositories folder named ICustomerRepository.cs and CustomerRepository.cs.
ICustomerRepository should look like this:
using Packt.CS7;using System.Collections.Generic;using System.Threading.Tasks;namespace NorthwindService.Repositories{ public interface ICustomerRepository { Task<Customer> CreateAsync(Customer c); ...