Cant find any way to group by multi dapper result

北城余情 提交于 2019-12-11 15:07:33

问题


I have this query:

        const string query = @"
           select *
             from [Users] u
        left join [UserRoles] ur
               on [ur].[UserId] = [u].[UserId]
        left join [Roles] r
               on [r].[RoleId] = [ur].[RoleId]
        left join [ExternalLogins] el
               on [el].[UserId] = [u].[UserId];
        ";

and next class structure:

public sealed class User : IUser<string>
{
    public string Id {
        get { return this.UserId.ToString(); }
    }

    public Guid UserId { get; set; }
    public string PasswordHash { get; set; }
    public string SecurityStamp { get; set; }
    public string UserName { get; set; }

    public IQueryable<UserLoginInfo> UserLoginInfos;
    public IQueryable<Role> Roles;
}

And i want to get IEnumerable<User> from Dapper using single SQL query (this at start).

            var rows = connection.Query(query).ToArray();
            if (rows.Length == 0) {
                return null;
            }

            var users = ...

            return users;

Is there any example?

来源:https://stackoverflow.com/questions/22296830/cant-find-any-way-to-group-by-multi-dapper-result

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!