Fasten your Data Layer with Dapper (A .NET Micro ORM)

Jawadhasan
6 min readJan 29, 2021

Introduction

Dapper is .NET based light-weight, fast and simple to use Micro ORM created by brilliant Stack Exchange team. The word ORM means Object Relation Mapper, means it facilitates mapping b/w .NET objects and database and that is its focus.

One great thing about Dapper that it works with any database. So, its not just for SQL Server. You can use it with PostgreSQL, MySQL or others.

You can download the code for sample application from this GitHub repo.

Simplified API

The simple API from Dapper, make it very easy to use. Dapper provide three primary helper methods:

  • A Query method that maps to strongly typed objects.
  • A Query method that maps to dynamic objects.
  • An Execute method for commands that do not return results (e.g. Insert)

We will see these functionalities in action by creating a .NET Core Application.

Create .NET Core Console Application

I started by creating a .NET Core Console application using visual studio:

Install Nuget Packages

First we install dapper main package to our project.

--

--

Jawadhasan

Software Solutions Team Lead | Cloud Architect | Solutions Architect