Skip to content

Quick Start

Required packages: Dapper.FluentMap, Microsoft.Data.Sqlite

Register an explicit map and execute a normal Dapper query.

Use this capability when the column shape and .NET model should remain separated by explicit, reviewable configuration.

using Dapper;
using Dapper.FluentMap;
using Dapper.FluentMap.Mapping;
using Microsoft.Data.Sqlite;
FluentMapper.Initialize(config =>
{
config.AddMap<CustomerMap>();
});
FluentMapper.Validate();
using var connection = new SqliteConnection("Data Source=:memory:");
var customer = connection.QuerySingle<Customer>(
"SELECT 7 AS customer_id, 'Ada' AS customer_name;");
public sealed class Customer
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
}
public sealed class CustomerMap : EntityMap<Customer>
{
public CustomerMap()
{
Map(x => x.Id).ToColumn("customer_id");
Map(x => x.Name).ToColumn("customer_name");
}
}

FluentMap registers typed metadata and applies it through the matching materialization path. SQL, connections, parameters, and lifecycle remain responsibilities of the application and Dapper.