Skip to content

Immutable Domain Model

Required package: Dapper.FluentMap

Materialize a constructor-based aggregate with mapped columns.

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

public sealed class Customer
{
public Customer(int id, string name)
{
Id = id;
Name = name;
}
public int Id { get; }
public string Name { get; }
}
var customer = connection.QueryMappedSingle<Customer>(sql);

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