This repository contains a .NET Web API project showcasing the use of Dapper as the Object-Relational Mapping (ORM) tool for interacting with a SQL Server database. The API manages products using CRUD operations.
The project structure follows a typical ASP.NET Web API pattern, and Dapper is used for data access.
-
Controllers:
ProductController
: Manages CRUD operations for products.
-
Models:
Product
: Represents a product entity.
- Endpoint:
GET /api/Product
- Description: Retrieve a list of all products.
- Response: Array of products.
- Endpoint:
POST /api/Product
- Description: Add a new product.
- Request Body: JSON representing the new product.
- Response: OK with the added product details.
- Endpoint:
DELETE /api/Product
- Description: Remove a product by ID.
- Request Body: JSON representing the product to be removed.
- Response: OK with a message indicating that the product is deleted.
- Clone this repository.
- Set up a SQL Server or another compatible database and update the connection string in
appsettings.json
. - Run the application using Visual Studio or
dotnet run
. - Test the API using a tool like Postman or Swagger.
- ASP.NET Core
- Dapper
- Microsoft.Extensions.Configuration
- Microsoft.Data.SqlClient
Feel free to customize and extend this project based on your specific requirements. For any issues or improvements, please create an issue or submit a pull request.
Happy coding!