1/30/2024 0 Comments Idatabase tutorialNow, we will test AddCustomer method which accepts customer object as parameter and insert it into customers table. Here, GetCustomerById method gets customer object based on the provided id parameter. Note, I used the Fiddler tool in order to test CRUD operations.Īs you can see below, GetCustomers method returns all data rows from customers table. _customerRepository.DelecteCustomer(id)._customerRepository.UpdateCustomer(id, customer)._customerRepository.AddCustomer(customer).return _customerRepository.GetCustomerById(id).public Customer GetCustomerById( int id).return _customerRepository.GetAllCustomers().private readonly ICustomerRepository _customerRepository = new CustomerRepository().public class CustomerController : Controller.In the next dialog, name the controller as CustomerController and then click Add. Right click on the controllers folder> Add > Controller> selecting API Controller – Empty > click Add. Now, we are going to create a controller. If its not specified, we can use the attributes which are offered by NPoco ORM. It will be assumed that the table name will be the class name and primary key will be ‘id’. This is a case insensitive match.īy default no mapping is required. I’d like to point out, NPoco works by mapping the column names to the property names on the customer object. Note that IDatabase provides all necessary methods to perform CRUD operations. After that, we proceeded to perform CRUD operations.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |