DEV Community

What is Dapper, and why you should consider it for your .NET projects

Kevin Griffin @ #Shedquarters on May 18, 2020

This post was originally hosted on my site, https://consultwithgriff.com - check it out! On the speaking circuit, I've been doing a good number ...
Collapse
 
1kevgriff profile image
Kevin Griffin @ #Shedquarters

Thanks everyone for the great feedback. I've updated the article with some more examples and hopefully more detail.

I didn't want to turn this into a reference too much, so I can understand if there are unanswered questions. I'd love to help you explore more if I can. More follow up posts coming down the pipe.

Collapse
 
1kevgriff profile image
Kevin Griffin @ #Shedquarters • Edited

I used to use EF heavily when it was database-first because I feel like that's how these types of libraries should be used. The jump to code-first left me confused because I didn't think about my systems like that.

And you're right, strongly typed queries are a big win. The number of times I've accidentally fat fingered a query going into Dapper or tried to map a datetime or a long. But that's far less pain than issues I've had with EF.

Thanks for the comment!

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

I use Dapper in pretty much every project now too. I've used it with MSSQL and Postgres. I also use it from F# -- it maps nicely onto F# record types. (I did have to add some type handlers for Option types.) Dapper is a great low investment, high return library.

Collapse
 
1kevgriff profile image
Kevin Griffin @ #Shedquarters

Yes! Thank you for reminding me about type handlers! I need to write about them- because that's a great feature. I've written a handful myself. Extremely useful.

Collapse
 
peledzohar profile image
Zohar Peled

I totally agree. Dapper is my number one choice every time.
My first (and hopefully last) encounter with EntityFramework was back in one of it's early versions (IIRC 1.2) and it was terrible in every way. After that, I used to just build "populators" to iterate through dataReaders and populate my objects. I've only been working with Dapper for the last couple of years and I've barely scratched the surface of what it can do, but for my needs it's auto-mapping abilities is more than enough.

I think what I like most about it is what I hated most about EF - it's the fact I write my own SQL. I like SQL and I'm pretty damn good with it, if I might say so myself - and I consider that fact a great benefit over full-scale ORMs.

Collapse
 
1kevgriff profile image
Kevin Griffin @ #Shedquarters

During my talk, I made a similar comment. I'm not amazing with SQL, but I'm pretty good for most stuff and I know how to write SQL that works well with my overall application.

With EF, it always felt like I was throwing a dart at the wall in a black box. I really like knowing what's going on, simply because I'm telling the library/framework to do it.

Thanks for the comment!

Collapse
 
thisdotmedia_staff profile image
This Dot Media

Really great article Kevin! Clears a lot of important questions on Dapper 👐🏻

Collapse
 
1kevgriff profile image
Kevin Griffin @ #Shedquarters

Thank you for the kind words!

Collapse
 
thisdotmedia_staff profile image
This Dot Media

Our pleasure 😊

Collapse
 
vbilopav profile image
vbilopav
Collapse
 
1kevgriff profile image
Kevin Griffin @ #Shedquarters

Will do!

Collapse
 
1kevgriff profile image
Kevin Griffin @ #Shedquarters

Yup - that's good feedback and I'm working on updates to help show off a bit more.