sqlserver 用户权限管理,LINQ去除它的重复菜单项
Jun 07, 2016 pm 06:02 PM
sqlserver
User rights management
事情是这样的,我有三张表,用户_角色关系表User_Role,角色_菜单关系表Role_Menu和菜单表
Menu,这三个表之间有如下关系:User_Role=>RoleId=>RoleMenu
RoleMenu=>MenuId=>Menu
它们之间的业务关系是:
当用户登陆后,通过UserId得到User_Role列表,将用户所包括的角色得出
通过User_Role找到所有对应Menu
现在有个问题,就是一个用户可以有多少角色,一个角色有多个菜单,当然,两个不同的角色可以有相当的菜单项,这时,就出现一个问题,用户在“管理员”这个角色里有“文件”这个菜单,同时它在“新闻管理员”这个角色里也有“文件”这个菜单,这样返回就会出现两个完成相同的”文件“菜单,下面,我使用匿名类和distinct方法来解决这个问题,代码如下:
代码如下:
class Program
{
static void Main(string[] args)
{
#region 实体列表初始化
List
{
new User_Role("01",1),
new User_Role("01",2),
new User_Role("02",1),
};
List
{
new Role_Menu(2,3),
new Role_Menu(1,1),
new Role_Menu(1,2),
new Role_Menu(2,1),
new Role_Menu(2,2),
};
List
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks ago
By DDD

Hot tools Tags

Hot Article
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Save File Location: Where Is It & How to Protect It?
3 weeks ago
By DDD

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to solve the problem that the object named already exists in the sqlserver database

How to import mdf file into sqlserver

What to do if the sqlserver service cannot be started

Comparative analysis of Oracle and DB2 database technology

How to recover accidentally deleted database in sqlserver

How to delete sqlserver if the installation fails?
