Due to the bad database structure, it's impossible to get result as expected. The main reason is that that there's no relationship between
DuplicateCol
and
TitleName
fields. So, joining the data based on
RoleID
field:
var result = (from r in Roles.AsEnumerable()
join rl in RolesLink.AsEnumerable() on r["RoleID"] equals rl["RoleID"]
join rt in RolesTitle.AsEnumerable() on r["RoleID"] equals rt["RoleID"]
select new
{
RoleName = r["Name"],
DuplicateCol = rl["DuplicateCol"],
TitleName = rt["TitleName"]
})
.GroupBy(x=>x.RoleName);
returns:
Key= Admin
RoleName DuplicateCol TitleName
Admin Title_ID Title_1
Admin Title_ID Title_3
Admin Title_Name Title_1
Admin Title_Name Title_3
Key= Account
RoleName DuplicateCol TitleName
Account Title_ID Title_2