开发者

How to get comma-separated values in Linq?

开发者 https://www.devze.com 2022-12-29 07:32 出处:网络
I have the query below: var users = (from a in dc.UserRoles join u in dc.Users on a.intUserId equals u.ID

I have the query below:

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.vc开发者_如何学JAVAhFunction
                             });

I require all the values of "Name =u.FullName" to be comma-separated in a single record group by intRoleId. I mean for every role I need all the usernames in a sigle record comma separated. Any suggestion?


You want to check out the IEnumerable.Aggregate() method.

0

精彩评论

暂无评论...
验证码 换一张
取 消