반복 추출 하위 메뉴

3685 단어 귀속
1 기본 방법:
 if (perlist != null && perlist.Count > 0)
            {
               
                foreach(AuthPermission per in perlist)
                {
                    if (per.parentId == 0)
                    {
                        sbStr.Append( per.mName + ",sun(");
                        getSunPermission(perlist, per.menuId, sbStr);
                        sbStr.Append(")");
                    }
                }
            }

2귀속
 /// <summary>
        ///  
        /// </summary>
        /// <param name="perList"></param>
        /// <param name="thisMenuId"></param>
        /// <returns></returns>
        public void getSunPermission(IList<AuthPermission> perList, int thisMenuId, StringBuilder menuStr)
        {
           
            IList<AuthPermission> sunlist = (from per in perList where per.parentId == thisMenuId select per).Reverse<AuthPermission>().ToArray();

            if (sunlist == null || sunlist.Count <= 0)
            {
                return ;
            }
            else {
                
                foreach (AuthPermission per in sunlist)
                {
                    menuStr.Append(""+per.mName+",");
                    getSunPermission(perList, per.menuId, menuStr);
                }
            }

        }

좋은 웹페이지 즐겨찾기