public ActionResult GetCategoryTreeJson() { var watch = CommonHelper.TimerStart(); var categorydata = categoryCache.GetList(null).ToList(); //CategoryBLL.Instance.GetList(null).ToList(); var treeList = new List <TreeEntity>(); foreach (CategoryEntity item in categorydata) { TreeEntity tree = new TreeEntity(); bool hasChildren = categorydata.Count(t => t.ParentID == item.CategoryID) == 0 ? false : true; tree.id = item.CategoryID.ToString(); tree.text = item.Name; tree.value = item.ParentID == null ? "0" : item.ParentID.ToString(); if (item.ParentID == "0") { tree.parentId = "0"; } else { tree.parentId = item.ParentID == null ? "0" : item.ParentID.ToString(); } tree.isexpand = true; tree.complete = true; tree.hasChildren = hasChildren; tree.Attribute = "Sort"; tree.AttributeValue = "Category"; treeList.Add(tree); } var costtime = CommonHelper.TimerEnd(watch); Logger.Debug("获取分类请求时间:" + costtime); return(Content(treeList.TreeToJson())); }