zoukankan      html  css  js  c++  java
  • 关于大类小类的输出问题

    当要输出 类别 ----类别下的小分类

         类别-----类别下的小分类

    Model

        /// <summary>
        /// 词条的列表  有百科类型
        /// </summary>
        public class WordList
        {
            public string BaikeType { get; set; }
            public Guid BaikeTypeID { get; set; }
            public List<Word> List { get; set; }
        }

    Linq查询语句:

    var list = from t in _db.BaiKeType
                               select new WordList
                               {
                                   BaikeType = t.Name,
                                   BaikeTypeID = t.ID,
                                   List = (from w in _db.Word
                                           where w.BaikeTypeID == t.ID
                                           select w).ToList<Word>()//有点子查询的意思
                               };
                    return list.ToList<WordList>();

    //前台输出

    <%List<SouGeWeb.Models.WordList> list = ViewData["list"] as List<SouGeWeb.Models.WordList>;%>
            <%foreach (SouGeWeb.Models.WordList item in list)
              {%>
            <h3>
                <%=item.BaikeType %></h3>
            <ul>
                <%foreach (SouGeDB.Word word in item.List)
                  {%>
                <li><a href="/gebing.html?bId=<%=word.ID %>">
                    <%=word.Title%></a></li>
                <%} %>
            </ul>
            <% } %>

  • 相关阅读:
    1722 最优乘车 1997年NOI全国竞赛
    5969 [AK]刻录光盘
    tarjan算法讲解
    求有向图的强连通分量个数 之 Kosaraju算法
    信使
    1405 奶牛的旅行
    P1828 香甜的黄油 Sweet Butter
    洛谷P2235 [HNOI2002]Kathy函数
    「BZOJ1010」[HNOI2008] 玩具装箱toy(斜率优化)
    BZOJ 1974 [Sdoi2010] auction 代码拍卖会(数位dp)
  • 原文地址:https://www.cnblogs.com/nanxiaoxiang/p/2704407.html
Copyright © 2011-2022 走看看