Skip to content

Property Converters

Required package: Dapper.FluentMap

Convert database values before assigning them to mapped properties.

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

Map(x => x.Status)
.ToColumn("status_code")
.ConvertFromDatabaseUsing<ProductStatusConverter, string>();

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

Property converters run before Dapper type handlers and FluentMap default conversion. They are the verified solution when a provider exposes date/time data in another CLR representation, such as SQLite ISO text:

Map(x => x.BusinessDate)
.ToColumn("business_date")
.ConvertFromDatabaseUsing<string, DateOnly>(value =>
DateOnly.ParseExact(value, "yyyy-MM-dd", CultureInfo.InvariantCulture));

Database NULL remains null for nullable targets and does not invoke the converter.