views:

9

answers:

1

I want to set this Array with the result of ths Query but I can't. How do I do it ?

String[] q = (from p in MDB.aspnet_Memberships
                      where p.aspnet_User.aspnet_UsersInRoles.Single().aspnet_Role.RoleName.ToString() == GroupDDL.SelectedItem.ToString()
                      select new{p.UserId }).ToArray();

Exception :

Cannot implicitly convert type 'AnonymousType#1[]' to 'string[]'

A: 

You're selecting a new anonymous object by using the braces. When you do "select new { p.UserID }", the compiler creates a brand new object type. You just want the userID's themselves, not a new object wrapping them up. Try just

select p.UserId).ToArray();

as your select clause.

womp