no

Executing a Linq Query With a Bridge Table Like Aspnet_users and Aspnet_roles

Using model first approach, we add aspnet_Users, aspnet_Roles and aspnet_UsersInRoles in the edmx file. But why is aspnet_UsersInRoles missi...

Using model first approach, we add aspnet_Users, aspnet_Roles and aspnet_UsersInRoles in the edmx file. But why is aspnet_UsersInRoles missing? It's because aspnet_Users has one-to-many relationship to aspnet_Roles. To get the role of the user, we need to execute the linq statement below.
class Person {
  public string UserName { get; set; }
  public string RoleName { get; set;
}

from a in _a2REntities.aspnet_Users
select new Person {
  Name = a.Username,
  RoleName = a.aspnet_Roles.Select(p=>p.RoleName).FirstOrDefault()
}

Related

c# 3201138404204984074

Post a Comment Default Comments

Outsourcing

Are you looking for freelancers in the Philippines? Get in touch.

Donations

If you like what I do, you can support this channel by buying me a coffee. I would be grateful for your contribution! Your donations will help me create more FREE online courses and learning materials for programmers and remote workers.

item