我想按群组对所有用户名称进行分组。我试过了:
var query = from u in db.Users
group p by u.UserGroup
select u.FullName;
我该如何解决?
答案 0 :(得分:3)
这将返回匿名对象的序列,包含用户组和该组中的所有名称:
var query = from u in db.Users
group u by u.UserGroup into g
select new {
UserGroup = g.Key,
Names = g.Select(x => x.FullName)
};