I have this piece of code:
public string[] GetUsergroupRoles(string username)
{
var qry = from ug in _entities.Usergroups
from r in _entities.Roles
from u in _entities.Users
where u.Username == username
group r by
new
{
r.RoleID
};
return qry.ToArray();
}
I get error “…Data.Models.Role>[]’ to ‘string[]’. An explicit conversion exists (are you missing a cast?)”
whats needed to make it return an array of strings?
/M
Well, you’re creating a sequence of groups (and I’m not sure why you’re using an anonymous type to do so – you should be able to just use
group r by r.RoleID).What string would you expect from each group?