I have been going through Dapper's Multi Mapping documentation but remain confused.
This is the example from Dapper documentation
class Post { public int Id { get; set; } public string Title { get; set; } public string Content { get; set; } public User Owner { get; set; } } class User { public int Id { get; set; } public string Name { get; set; } } var sql = @"select * from #Posts p left join #Users u on u.Id = p.OwnerId Order by p.Id"; var data = connection.Query<Post, User, Post>(sql, (post, user) => { post.Owner = user; return post;}); var post = data.First(); What confuses me is where the variable post and user came from? I see in this line ...
connection.Query<Post, User, Post>
that Post and User are the models and I understand that ..
(post, user) => { post.Owner = user; return post;}
is a function that defines the mapping, but where do post and user get instantiated?