How to get comma-separated values in Linq?
Posted
by Mujtaba Hassan
on Stack Overflow
See other posts from Stack Overflow
or by Mujtaba Hassan
Published on 2010-05-07T21:56:07Z
Indexed on
2010/05/07
22:08 UTC
Read the original article
Hit count: 225
linq-to-sql
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.vchFunction
});
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?
© Stack Overflow or respective owner