The Dapper Developer

download

Sometimes you get a NUGET package that just makes a good first impression & looks the part & this weeks mention is one of those, ladies & gentleman,  i present to you, Dapper.

Dapper is a very simple lightweight ORM (a micro ORM if you will) that is nothing but a pleasure to work with.  It is lean & non intrusive to your code base, & most importantly it runs fast.

Dapper is a great tool to consider on a project where more complex database considerations such as transaction mgmt, etc are not paramount to an application & you just want to do simple CRUD.  Typically for apps like this a developer will fire open NUGET manager & download the latest Entity framework library, Linq to SQL or perhaps handroll ADO.NET calls from scratch & attempt to plumb all the bits together just to do be doing a simple query or write operation, this can be quite taxing & for a lot of the time feels like overkill.

Well, Dapper eliminates all of that, download from NUGET, and if all your doing is performing a simple query than the following snippet will do this for you

dapper_code1

Everything within the using statement is what Dapper will perform, elegant right?

Person is just a typical POCO class with properties that match to what is being returned from SQL query, just to prove there is no magic here it is

dapper_code2

The magic behind Dapper is that it is an extension to the IDBConnection interface so its piggy backing on the underlying ADO.NET framework.

It has come to my rescue lately a lot for doing work around automated integration tests where i want to verify data in a table has been created, updated, etc.   In these situations i wanted something quick & easy to use for talking to a database without any manual plumbing or bloated features slowing things down & am delighted to say Dapper has exceeded those requirements.

For the benefit of this post i have put together a small console application demonstrating CRUD operations using Dapper on my GITHub page, so please feel free to download, the above code samples are taken from it.

Everyone likes to look Dapper, now your code can too!

One thought on “The Dapper Developer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s