开发者

Many to Many LINQ TO SQL Query

开发者 https://www.devze.com 2022-12-22 18:57 出处:网络
I have the following tables: Users Roles UserRoles开发者_JAVA百科 MenuItems RoleMenuItems A User can have multiple Roles and a MenuItem can be accessed by multiple Roles. Now I want to write a metho

I have the following tables:

Users

Roles

UserRoles

开发者_JAVA百科 MenuItems

RoleMenuItems

A User can have multiple Roles and a MenuItem can be accessed by multiple Roles. Now I want to write a method as follows:

public IList<MenuItems> GetMenuItems(UserRoles userRoles)
{
   var menus = // LINQ query to get the MenuItems by UserRoles 

   return menus.ToList();
}

Is there a way to do this?


userRoles.SelectMany(i => i.MenuItems);

0

精彩评论

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