Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rahulmule/dotnetwebapi-dapper-demo
This is a simple .NET 6 Web API project that uses Dapper as the ORM (Object-Relational Mapping) to interact with a SQL Server database. The project includes basic CRUD (Create, Read, Update, Delete) operations for managing products.
https://github.com/rahulmule/dotnetwebapi-dapper-demo
dapper dotnet-6 dotnetcore dotnetwebapi sql-server-database web-api
Last synced: 3 days ago
JSON representation
This is a simple .NET 6 Web API project that uses Dapper as the ORM (Object-Relational Mapping) to interact with a SQL Server database. The project includes basic CRUD (Create, Read, Update, Delete) operations for managing products.
- Host: GitHub
- URL: https://github.com/rahulmule/dotnetwebapi-dapper-demo
- Owner: RahulMule
- Created: 2024-01-05T21:50:17.000Z (10 months ago)
- Default Branch: master
- Last Pushed: 2024-01-05T22:00:31.000Z (10 months ago)
- Last Synced: 2024-11-11T00:16:35.411Z (3 days ago)
- Topics: dapper, dotnet-6, dotnetcore, dotnetwebapi, sql-server-database, web-api
- Language: C#
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# .NET Web API with Dapper Demo
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.
## Project Structure
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.## API Endpoints
### 1. Get All Products
- **Endpoint:** `GET /api/Product`
- **Description:** Retrieve a list of all products.
- **Response:** Array of products.### 2. Add Product
- **Endpoint:** `POST /api/Product`
- **Description:** Add a new product.
- **Request Body:** JSON representing the new product.
- **Response:** OK with the added product details.### 3. Remove Product
- **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.## How to Run
1. Clone this repository.
2. Set up a SQL Server or another compatible database and update the connection string in `appsettings.json`.
3. Run the application using Visual Studio or `dotnet run`.
4. Test the API using a tool like [Postman](https://www.postman.com/) or [Swagger](https://swagger.io/).## Dependencies
- ASP.NET Core
- Dapper
- Microsoft.Extensions.Configuration
- Microsoft.Data.SqlClientFeel 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!