Skip to content

Automatic multi mapping : would this be possible ? #350

@christopheblin

Description

@christopheblin

At the moment, you have to write something like :

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();

Would it be possible to support something like :

var sql = @"select p.id, p.title, p.content, u.Id as owner__id, u.Name as owner__Name
from Posts p 
left join Users u on u.Id = p.OwnerId 
Order by p.Id";

var data = connection.Query<Post>(sql);
var post = data.First();

As you can see double underscore would be understood as "nested object" and I do not have to specify the "strange" function.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions