I have a DB with 3 tables:
User{UserId,UserName}
Role{RoleId,RoleName}
User_Role{UserId,RoleId}
This query:
int userIdPassByUrl = 0;
MyDbContext ctx = new MyDbContext();
var query = (from role in ctx.Role
join userRole in ctx.User_Role on role.RoleId equals userRole.RoleId
where userRole.UserId == userIdPassByUrl
select new { role.RoleId, role.RoleName }).Distinct();
I need to show the result of the above query in a Gridview with an EntityDataSource, either code or set it in the design mode.
this is my EntitydataSource:
<asp:EntityDataSource ID="EdsRolesByUser" runat="server"
ConnectionString="name=myDbEntities"
DefaultContainerName="myDbEntities" EnableFlattening="False"
EntitySetName="Roles" EntityTypeFilter="Role"
Select="it.[RoleId], it.[RoleName]">
</asp:EntityDataSource>
Any help would be appreciated, thanks.