Entity framework 实体框架中的过滤列表
我一直在使用dotnetnuke门户,在那里我创建了一个部门链接模块。其中,在此模块中,我有colDepartmentPageLinks,它是列表类型,并返回特定部门的链接列表,并与datalist绑定,但现在我必须根据模块id筛选colDepartmentPageLinks,模块id也是此DepartmentPageLinkInfo列表中的一个字段Entity framework 实体框架中的过滤列表,entity-framework,filter,dotnetnuke,records,Entity Framework,Filter,Dotnetnuke,Records,我一直在使用dotnetnuke门户,在那里我创建了一个部门链接模块。其中,在此模块中,我有colDepartmentPageLinks,它是列表类型,并返回特定部门的链接列表,并与datalist绑定,但现在我必须根据模块id筛选colDepartmentPageLinks,模块id也是此DepartmentPageLinkInfo列表中的一个字段 DepartmentPageLinkController objDepartmentPageLinks = new DepartmentPag
DepartmentPageLinkController objDepartmentPageLinks = new DepartmentPageLinkController();
List<DepartmentPageLinkInfo> colDepartmentPageLinks;
//get the content from the DepartmentPageLink table
int TabId = this.TabId;
int ModuleId = this.ModuleId;
colDepartmentPageLinks = objDepartmentPageLinks.GetDepartmentPageLinks(TabId);
lstContent.DataSource = colDepartmentPageLinks;
lstContent.DataBind();
DepartmentPageLinkController objDepartmentPageLinks=newdepartmentpagelinkcontroller();
列出PartmentPageLinks;
//从DepartmentPageLink表中获取内容
int TabId=this.TabId;
int ModuleId=this.ModuleId;
colDepartmentPageLinks=objDepartmentPageLinks.GetDepartmentPageLinks(TabId);
lstContent.DataSource=colDepartmentPageLinks;
lstContent.DataBind();
您可以修改objDepartmentPageLinks.GetDepartmentPageLinks(TabId)方法,使其接受ModuleId作为参数(在相应修改GetDepartmentPageLinks方法之后),或者在数据绑定之前运行一些快速LINQ来过滤colDepartmentPageLinks列表:
//get the content from the DepartmentPageLink table
int TabId = this.TabId;
int ModuleId = this.ModuleId;
colDepartmentPageLinks = objDepartmentPageLinks.GetDepartmentPageLinks(TabId);
colDepartmentPageLinks = (From dpl In colDepartmentPageLinks Where dpl.ModuleId = intModuleId Select dpl).ToList;
lstContent.DataSource = colDepartmentPageLinks;
lstContent.DataBind();
谢谢,伙计。我更改了objDepartmentPageLinks.GetDepartmentPageLinks(TabId)方法,以便它接受ModuleId作为参数。