Reusable Mapping Methods
What this page covers#
This page shows how to centralize manual mapping logic.
Example#
using Microsoft.Data.SqlClient; public static class UserMap { public static User Map(SqlDataReader reader) => new() { UserId = reader.GetInt32(reader.GetOrdinal("UserId"Why this helps#
This can reduce duplication and keeps the call site cleaner when the same row shape appears in several places.