public List <Models.ProductMenuModel> MenuList(string modelId)
        {
            var queryMenu = ProductMenuLimitRepository.GetQuery(o => o.ModuleId == modelId);
            var q         = from x in queryMenu
                            where x.Type != 3
                            orderby x.SortOrder
                            select new {
                x,
                Haslimit = queryMenu.Any(o => o.PMenuId == x.MenuId && o.Type == 3)
            };
            var ms    = q.ToList();
            var menus = new List <Models.ProductMenuModel>();

            foreach (var m in ms)
            {
                var pm = new Models.ProductMenuModel();
                m.x.ToCopyProperty(pm);
                pm.HasLimit = m.Haslimit;
                menus.Add(pm);
            }
            var list = new List <Models.ProductMenuModel>();

            foreach (var menu in menus.Where(o => o.PMenuId <= 0))
            {
                SetChilds(menu, menus);
                menu.Index = list.Count;
                list.Add(menu);
            }
            return(list);
        }
        void SetChilds(Models.ProductMenuModel menu, List <Models.ProductMenuModel> alls)
        {
            menu.Childrens = alls.Where(o => o.PMenuId == menu.MenuId).ToList();
            int i = 0;

            foreach (var child in menu.Childrens)
            {
                child.Index    = i++;
                child.ParentId = menu.Id;
                SetChilds(child, alls);
            }
        }