• 关于大类小类的输出问题


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

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

    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>
            <% } %>

  • 相关阅读:
    bzoj1014: [JSOI2008]火星人prefix
    bzoj1934: [Shoi2007]Vote 善意的投票&&bzoj2768:[JLOI2010]冠军调查
    bzoj2705: [SDOI2012]Longge的问题
    bzoj4653: [Noi2016]区间
    bzoj2456: mode
    bzoj5018: [Snoi2017]英雄联盟
    关于树论【左偏树】
    caioj1522: [NOIP提高组2005]过河
    caioj1421&&hdu2167: [视频]【状态压缩】选数
    Linux下全局安装composer方法
  • 原文地址:https://www.cnblogs.com/nanxiaoxiang/p/2704407.html
Copyright © 2020-2023  润新知