HamidMolareza / ApiWithDapper-Sample

A sample project for using ASP API with Dapper

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Build Status

GitHub Pull Requests welcome

code with love by HamidMolareza

About

Project Overview

This project is a sample ASP.NET Core Web API for a Todo application that uses Dapper as the ORM (Object-Relational Mapper). The Todo API provides a simple yet effective way to manage tasks, illustrating the integration of Dapper for efficient database operations in an ASP.NET Core environment.

Purpose

The primary purpose of this project is to demonstrate the implementation of a RESTful API for managing Todo items using ASP.NET Core and Dapper. It serves as a practical example for developers looking to understand how to build lightweight, high-performance APIs with a focus on simplicity and efficiency.

Project Goals

  • Simplify Task Management: Provide a straightforward and efficient way to handle task creation, retrieval, updating, and deletion.
  • Demonstrate Dapper Integration: Showcase how to integrate Dapper with ASP.NET Core to perform database operations efficiently.
  • Educate and Guide Developers: Serve as an educational resource for developers learning to build APIs using modern technologies.

Built With

  • .NET 8

Getting Started

Prerequisites

  • Clone project
  • Install dotnet 8 or docker

How to run?

Approach 1: Use dotnet

dotnet restore src
dotnet build src
dotnet run --project src/ApiWithDapper.csproj

Approach 2: Use docker

docker compose up

Finally you can remove the image with the below command:

docker rmi -f api-with-dapper

How to use?

After the project is executed, you can use swagger or Todo.http file.

Project Structure

src
├── API
│   ├── ApiWithDapper.csproj
│   ├── appsettings.Development.json
│   ├── appsettings.json
│   ├── Helpers
│   │   ├── DatabaseInitilizer.cs
│   │   ├── PageData.cs
│   │   └── PaginationHelpers.cs
│   ├── http
│   │   └── Todo.http
│   ├── Migrations
│   │   └── Init_20240628005459.cs
│   ├── Program.cs
│   ├── Properties
│   │   └── launchSettings.json
│   └── Todo
│       ├── ITodoRepository.cs
│       ├── TodoController.cs
│       ├── Todo.cs
│       └── TodoRepository.cs
├── src.sln
└── TestProject
    ├── GlobalUsings.cs
    ├── PaginationHelpersTests.cs
    ├── TestProject.csproj
    ├── TodoControllerTests.cs
    └── TodoRepositoryTests.cs

Contributing

First off, thanks for taking the time to contribute! Contributions are what make the free/open-source community such an amazing place to learn, inspire, and create. Any contributions you make will benefit everybody else and are greatly appreciated.

Please read our contribution guidelines, and thank you for being involved!

Authors & contributors

The original setup of this repository is by HamidMolareza.

For a full list of all authors and contributors, see the contributors page.

Security

This project follows good practices of security, but 100% security cannot be assured. This project is provided "as is" without any warranty.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the GPLv3.

See LICENSE for more information.

About

A sample project for using ASP API with Dapper

License:GNU General Public License v3.0


Languages

Language:C# 94.0%Language:Dockerfile 3.4%Language:JavaScript 2.6%