Skip to content

SQL Server Example

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

Use FluentMap with a SqlConnection while retaining parameterized SQL.

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

await using var connection = new SqlConnection(connectionString);
var row = connection.QuerySingle<Customer>(
"SELECT customer_id, customer_name FROM dbo.Customers WHERE customer_id = @id",
new { id = 7 });

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