如何在Linq中获取以逗号分隔的值?

时间:2010-05-07 21:56:07

标签: linq-to-sql

我有以下查询:

var users = (from a in dc.UserRoles
                             join u in dc.Users on a.intUserId equals u.ID
                             join r in dc.Roles on a.intRoleId equals r.ID
                             where r.intClientId == clientID
                             select new UserRoleDetail
                             {
                                 ID = a.ID,
                                 intUserId = a.intUserId,
                                 intRoleId = a.intRoleId,
                                 Name =u.FullName, //Here I need comma separated values.
                                 intAssignedById = a.intAssignedById,
                                 RoleName = r.vchName,
                                 Function = u.vchFunction
                             });

我要求"Name =u.FullName"的所有值在intRoleId的单个记录组中以逗号分隔。我的意思是每个角色我都需要将sigle记录中的所有用户名分开。有什么建议吗?

1 个答案:

答案 0 :(得分:0)

您想查看IEnumerable.Aggregate()方法。