A .NET 5 core WebApi project using PostgreSQL and Dapper. No Entity Framework. Straight up SQL.
Tested on Debian (linux).
- .NET 5 WebApi
- Dapper
- PostgreSQL
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.
# 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
- No need to use using statement. Dapper will automatically open, close and dispose of the connection.
Forked from berkayyerdelen/Dapper.Webapi
MIT Licensed.