コード例 #1
0
        private void QueryLevelMenus(List <SysMenu> sysMenus, SysMenuDto menuDto)
        {
            var order = 1;
            List <SysMenuDto> menuDtos = sysMenus.Where(f => f.ParentId == menuDto.Key).OrderBy(f => f.ShowOrder).Select(f =>
            {
                var m = new SysMenuDto()
                {
                    Group = true, Key = f.Id, Order = order++
                };
                m.CopyFrom(f);
                return(m);
            }).ToList();

            menuDtos.ForEach(f =>
            {
                QueryLevelMenus(sysMenus, f);
            });
            menuDto.Children = menuDtos;
        }
コード例 #2
0
        /// <summary>
        /// 组装菜单层级数据
        /// </summary>
        /// <param name="sysMenus"></param>
        private List <SysMenuDto> QueryLevelMenus(List <SysMenu> sysMenus)
        {
            List <SysMenuDto> menuDtos = sysMenus.Where(f => f.ParentId == 0).Select(f =>
            {
                var m = new SysMenuDto()
                {
                    Group = true, Key = f.Id
                };
                m.CopyFrom(f);
                return(m);
            }
                                                                                     ).OrderBy(f => f.ShowOrder).ToList();

            menuDtos.ForEach(f =>
            {
                QueryLevelMenus(sysMenus, f);
            });

            return(menuDtos);
        }