less than 1 minute read

A few days ago, I was looking for a way to save time when writing CRUD operations. I found a great solution — it's called Dapper.

To generate a C# class from your database, you can use this Gist:

https://gist.github.com/anirugu/9fb82ce773c45578f42f7a6d899f3221

Once done, add Dapper and Dapper.Contrib to your project via NuGet.

You will no longer need to manually open a DataReader and write the same boilerplate reading and mapping code over and over again.

Dapper.Contrib gives you convenient functionality for operations like Insert and Update. You still need to write your SQL queries, but the code becomes much cleaner and easier to maintain. Last year, I was working on a C# project where the codebase became a tangled mess — a single-line SELECT, INSERT, or UPDATE statement followed by 100+ lines of DataReader mapping code.

Dapper can save you a significant amount of time by eliminating that repetitive boilerplate, and it does the job very well.

https://github.com/StackExchange/Dapper

https://stackoverflow.com/questions/tagged/dapper

Happy Coding Smile

Tags: ,

Categories:

Updated: