This works:
var query = (from user in _context.Users
join role in _context.UserRoles on user.UserID equals role.UserId
where user.Username == username
select role.Role).ToArray();
How do I do the same in the method syntax?
//here role.Role has multiple values
var query2 = _context.Users.Join(_context.UserRoles, u=>u.UserID,ur=>ur.UserId,
(u,ur)=> new { ur.Role }).ToArray();
The above code throws an error:
Cannot implicitly convert type<anonymous // type string Role>[] to 'string[]'
Better to stay with LINQ query syntax which is closer to the SQL and you can easily modify your query. Anyway here is your translation: