Dapper Integration
Required package:
Dapper.FluentMap
Problem solved
Section titled “Problem solved”Use public Dapper type-map and query contracts with FluentMap.
When to use it
Section titled “When to use it”Use this capability when the column shape and .NET model should remain separated by explicit, reviewable configuration.
Example
Section titled “Example”public sealed class CustomerMap : EntityMap<Customer>{ public CustomerMap() { Map(x => x.Id).ToColumn("customer_id"); Map(x => x.Name).ToColumn("customer_name"); }}How it works
Section titled “How it works”FluentMap registers typed metadata and applies it through the matching materialization path. SQL, connections, parameters, and lifecycle remain responsibilities of the application and Dapper.
Dapper 2.1.89 boundary
Section titled “Dapper 2.1.89 boundary”- Dapper owns ordinary
Query<T>()materialization,DynamicParameters, its IL-diagnostic suppressions and its separate StrongName packages. - FluentMap owns mapping metadata and the value assignment performed by
QueryMapped*,ReadMapped*and eligible generated materializers. - FluentMap therefore implements matching verified conversions for
DateTimetoDateOnly,DateOnlyto midnightDateTime,DateTime/TimeSpantoTimeOnly, andTimeOnlytoTimeSpan. - Nullable values, immutable constructors, nested members and property converters are covered in runtime and generated tests. No other implicit date/time conversion is claimed.
The public DynamicParameters.AddParameters(IDbCommand) change is upstream Dapper API. FluentMap passes DynamicParameters through non-strict mapped queries but does not wrap that method. Strict-generated queries use explicit GeneratedParameters instead.