Dapper Mapper Getting Started


Dapper.Mapper is a small NuGet library that extends and simplifies the multi-mapping functionality of Dapper.

  • It allows you to map a single row to multiple objects.
  • It also automatically figures out the relationships between the returned objects and assigns them.

Setup

To start using the Dapper.Mapper in your application. You will need to install the Dapper.Mapper NuGet package.

So let's open the Visual Studio and create a new project.

Create a new project

Select the Create a new project option.

Select Console Application template

Choose C# as language, Windows as a platform, and Console as the project type. In the template pane, select Console Application and click the Next button.

Configure your new project

Enter the project name, you can change the location and solution name, but we will leave it and click on the Next button.

Additional Information

On the Additional Information dialog, select the target framework and then click on the Create button.

Console Application created

You can see a new console application project is created. Now, to install a Dapper.Mapper, right-click on the Solution Explorer project, and select Manage NuGet Packages...

Install Dapper.Mapper

Select the Browse tab and search for Dapper.Mapper and install the latest version by pressing the Install button.

Dapper.Mapper installed successfully

Once Dapper.Mapper has been successfully installed. You need to install System.Data.SqlClient NuGet package.

You are now ready to start your application.