Dapper Tutorial Dapper.FluentMap Library
Overview
Dapper.FluentMap is a small library which allows you to fluently map properties of your domain classes to the database columns. This library functionality is similar to Entity Framework Fluent API and keeps your domain classes clean of mapping attributes.
NuGet Installation
Dapper.FluentMap is available through NuGet: https://www.nuget.org/packages/Dapper.FluentMap/
You can easily install this library by running the following command:
PM> Install-Package Dapper.FluentMap
APIs
There are two types of mapping supported in Dapper.FluentMap
- Manual mapping
- Convention based mapping
You can map property names manually using the EntityMap
public class InvoiceMap : EntityMap<Invoice> { public InvoiceMap() { // Map property 'InvoiceID' to column 'Id'. Map(i => i.InvoiceID).ToColumn("Id"); // Ignore the 'Detail' and 'Items' properties when mapping. Map(i => i.Detail).Ignore(); Map(i => i.Items).Ignore(); } }
Initialize your mapping at the start of your application.
FluentMapper.Initialize(config =>
{
config.AddMap(new InvoiceMap());
});
Unfortunately, there is no proper documentation available for this library, but you can get a little bit of help from: https://github.com/henkmollema/Dapper-FluentMap
Support
This library is supported, and you will get your answers within next few days.
- henkmollema@gmail.com
- https://github.com/henkmollema/Dapper-FluentMap/issues