实体框架中的过滤器列表

发布于 2024-11-17 01:43:37 字数 764 浏览 8 评论 0原文

我一直在与 dotnetnuke 门户合作,在那里我创建了一个部门链接模块。在这个模块中,我有 colDepartmentPageLinks,它是列表类型,并向我返回特定部门的链接列表并与数据列表绑定,但现在我必须根据模块 id 过滤 colDepartmentPageLinks,模块 id 也是此 DepartmentPageLinkInfo 列表中的一个字段。

  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();

i have been working with dotnetnuke portal and there i have created a module for department links. where in this modulei have colDepartmentPageLinks which is type of List and returns me the list of links of particular departments and bind with the datalist but now i have to filter the colDepartmentPageLinks based on module id and module id is also a field in this DepartmentPageLinkInfo list.

  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();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九局 2024-11-24 01:43:37

您可以修改您的 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();

You could either modify your objDepartmentPageLinks.GetDepartmentPageLinks(TabId) method so that it accepts ModuleId as an arguement (after modifying your GetDepartmentPageLinks method accordingly) or you could run some quick LINQ to filter the colDepartmentPageLinks list just prior to databinding:

//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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文