<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd" -->

---
title: PostgreSQL CRUD operations with C# and Dapper | daily.dev
description: A step-by-step walkthrough shows how to perform CRUD operations (Create, Read, Update, Delete) against a PostgreSQL 'Games' table using Dapper, a micro-ORM...
canonical: https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: PostgreSQL CRUD operations with C# and Dapper | daily.dev
og:description: A step-by-step walkthrough shows how to perform CRUD operations (Create, Read, Update, Delete) against a PostgreSQL 'Games' table using Dapper, a micro-ORM...
og:url: https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd
og:image: https://api.daily.dev/og/posts/CxHYYrQdD.png
og:image:alt: PostgreSQL CRUD operations with C# and Dapper
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# PostgreSQL CRUD operations with C# and Dapper

**[Code4IT](https://daily.dev/sources/code4it)** · 9 min read · 0 upvotes · 0 comments

## Summary

A step-by-step walkthrough shows how to perform CRUD operations (Create, Read, Update, Delete) against a PostgreSQL 'Games' table using Dapper, a micro-ORM built on top of Npgsql in .NET. Code examples cover inserting, querying, updating, and deleting rows with parameterized queries and automatic object mapping, alongside direct comparisons to the same operations written with the raw Npgsql library to highlight how much boilerplate Dapper eliminates.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.code4it.dev/blog/postgres-crud-dapper>

## Questions this post answers

### How do I perform CRUD operations on a PostgreSQL database using Dapper in C#?

Open an NpgsqlConnection, then use Dapper's ExecuteAsync for inserts, updates, and deletes with parameterized SQL and an anonymous object for arguments, and QueryAsync or QueryFirstAsync to automatically map SELECT results to a class like BoardGame. Dapper does not generate SQL itself, so queries must still be written explicitly, but it eliminates manual data reader mapping.

_See the full Dapper repository pattern on daily.dev when building your own PostgreSQL data layer in C#._

### What is the difference between using Dapper and raw Npgsql for database access in C#?

Dapper simplifies query execution and result mapping into single method calls like ExecuteAsync and QueryAsync, using anonymous objects for parameters, whereas raw Npgsql requires manually creating an NpgsqlCommand, adding each parameter individually, and writing a custom reader function to map NpgsqlDataReader rows into objects field by field.

_Compare Dapper against raw Npgsql approaches on daily.dev before picking a data access strategy for your project._

## Similar posts on daily.dev

- [How to Work With Dapper in .Net](https://daily.dev/posts/how-to-work-with-dapper-in-net-yzgrlyllb) · freeCodeCamp · 17 upvotes · 0 comments
- [Building CRUD API with Dapper and Dapper Plus in ASP.NET Core](https://daily.dev/posts/building-crud-api-with-dapper-and-dapper-plus-in-asp-net-core-pzojrv4vq) · We Are .NET · 0 upvotes · 0 comments
- [Dapper in Depth with ASP.NET Core 10](https://daily.dev/posts/dapper-in-depth-with-asp-net-core-10-oad4bk2bw) · C\# Corner · 1 upvotes · 0 comments
- [Milan Jovanović](https://daily.dev/posts/milan-jovanovi--lmrqyshnk) · Milan Jovanović · 2 upvotes · 0 comments

---

Tags: [#postgresql](https://daily.dev/tags/postgresql), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"PostgreSQL CRUD operations with C# and Dapper","url":"https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd"},"datePublished":"2026-10-04T13:07:24.202Z","dateModified":"2026-10-04T13:17:05.960Z","description":"A step-by-step walkthrough shows how to perform CRUD operations (Create, Read, Update, Delete) against a PostgreSQL 'Games' table using Dapper, a micro-ORM...","image":"https://media.daily.dev/image/upload/s--P4t4XyoV--/f_auto/v1722860399/public/Placeholder%2001","thumbnailUrl":"https://media.daily.dev/image/upload/s--P4t4XyoV--/f_auto/v1722860399/public/Placeholder%2001","isAccessibleForFree":true,"articleSection":"Code4IT","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Code4IT","logo":"https://media.daily.dev/image/upload/s--OaaG4G10--/f_auto,q_auto/v1791119049/logos/code4it?_a=BAMAMicg0","url":"https://daily.dev/sources/code4it"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"postgresql,c#","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Code4IT","item":"https://daily.dev/sources/code4it"},{"@type":"ListItem","position":3,"name":"PostgreSQL CRUD operations with C# and Dapper"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/postgresql-crud-operations-with-c-and-dapper-cxhyyrqdd#faq","mainEntity":[{"@type":"Question","name":"How do I perform CRUD operations on a PostgreSQL database using Dapper in C#?","acceptedAnswer":{"@type":"Answer","text":"Open an NpgsqlConnection, then use Dapper's ExecuteAsync for inserts, updates, and deletes with parameterized SQL and an anonymous object for arguments, and QueryAsync or QueryFirstAsync to automatically map SELECT results to a class like BoardGame. Dapper does not generate SQL itself, so queries must still be written explicitly, but it eliminates manual data reader mapping. See the full Dapper repository pattern on daily.dev when building your own PostgreSQL data layer in C#."}},{"@type":"Question","name":"What is the difference between using Dapper and raw Npgsql for database access in C#?","acceptedAnswer":{"@type":"Answer","text":"Dapper simplifies query execution and result mapping into single method calls like ExecuteAsync and QueryAsync, using anonymous objects for parameters, whereas raw Npgsql requires manually creating an NpgsqlCommand, adding each parameter individually, and writing a custom reader function to map NpgsqlDataReader rows into objects field by field. Compare Dapper against raw Npgsql approaches on daily.dev before picking a data access strategy for your project."}}]}
```

