In Dapper, the order of columns matters when performing 1-to-many mappings using the Query
method with multi-mapping. Here's what you need to know:
Id Column Position:
The split-on column (usually the Id) must appear first in the column sequence for each entity
Dapper splits rows when it sees a duplicate Id in this column.
Proper Sequence Example:
sql
SELECT
u.Id, u.Name, -- User columns (must start with Id)
p.Id, p.Title, p.UserId -- Post columns (must start with Id)
FROM Users u
JOIN Posts p ON u.Id = p.UserId