【发布时间】:2013-12-06 22:56:45
【问题描述】:
我使用 Code First 所以它创建了实体并生成了 dbset 并使用 LINQ 来实现我的数据。我是 LINQ 新手,我想了解以下内容
这是我的一张桌子我的模型
namespace MISSanctions.Models
{
using System;
using System.Collections.Generic;
public partial class tbl_navigation_menus
{
public long tbl_nav_id { get; set; }
public string tbl_controller { get; set; }
public string tbl_method { get; set; }
public string tbl_menu_name { get; set; }
public long tbl_parent_id { get; set; }
public string tbl_view { get; set; }
public long tbl_child_id { get; set; }
public byte tbl_active { get; set; }
}
}
它与表 tbl_nav_rights 有关系
namespace MISSanctions.Models
{
using System;
using System.Collections.Generic;
public partial class tbl_nav_rights
{
public long tbl_nav_right_id { get; set; }
public long tbl_user_id { get; set; }
public long tbl_nav_id { get; set; }
public long tbl_nav_active { get; set; }
}
}
我想选择 tbl_user_id 的权限为 11796 。意味着 11769 将拥有多个权限,我想将上面的 tbl_navigation_menus 加入表格,其中包含导航名称控制器名称和方法以及一些图标图像。
我想创建一个单独的模型,它返回用户 ID 11769 的数据。我正在创建一个这样的模型,但对如何获取模型中的多行感到困惑
这是将返回给视图的主导航模型
namespace MISSanctions.Models
{
public class AdminNavigationList
{
public int Userid {get;set;}
public int tbl_nav_id{get;set;}
public string tbl_controller { get; set; }
public string tbl_method { get; set; }
public string tbl_menu_name { get; set; }
public int tbl_parent_id { get; set; }
public bool active { get; set; }
public string tbl_icon { get; set; }
}
}
然后我将循环显示导航..请帮助我实现它
【问题讨论】:
标签: c# asp.net asp.net-mvc-3 linq