开发者

Entity Framework Many To Many Relationship

I'm using the default ASP.NET profile and membership prov开发者_StackOverflow社区ider. I want to create a ASP List View with the name of the user and their role. When I try using this functionality I get a error:

Code behind:

public List<aspnet_Users> GetUsers(int startRowIndex, int maximumRows)
{
    this.entities.aspnet_Users.Include("aspnet_Roles").OrderBy(u => u.UserId).Skip(startRowIndex).Take(maximumRows).ToList();
}

Page directive:

<%# Eval("aspnet_Roles.RoleName")%>

It's not working because it's a many to many relationship in the database. How do I change my code behind method to map across the many to many relationship?


Don't do this. You shouldn't map the membership tables. The ASP.NET membership API already has a method to get a page of member data. You're reinventing the wheel, and replacing it with a version where you can't change the tire.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜