mgutz / Mgutz.DapperPg

.NET 5 WebApi project with Dapper and PostgreSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mgutz.DapperPg

A .NET 5 core WebApi project using PostgreSQL and Dapper. No Entity Framework. Straight up SQL.

Tested on Debian (linux).

Technologies

  • .NET 5 WebApi
  • Dapper
  • PostgreSQL

Testing

In a terminal start postgres

docker-compose up

In another terminal, run the project

# first DB run migrations with your own utility
dat up

# run server
dotnet run --project Mgutz.DapperPg

Browse http://localhost:5000/swagger to interact with the API through swagger UI.

Interact with API via Terminal

# create a product
curl -H 'Content-Type: application/json' -d '{"name": "Apple", "cost": 0.50}' http://localhost:5000/api/product -v

# list products
curl http://localhost:5000/api/product

# get product id=1000
curl http://localhost:5000/api/product/1000

Notes

  • No need to use using statement. Dapper will automatically open, close and dispose of the connection.

Credit

Forked from berkayyerdelen/Dapper.Webapi

LICENSE

MIT Licensed.

About

.NET 5 WebApi project with Dapper and PostgreSQL


Languages

Language:C# 98.7%Language:Shell 1.3%