问题
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