分组后,循环子集的方法

            var rightScopes = db.RightScope.ToList();
            var rightScopeType = rightScopes.OrderBy(rs => rs.ClaimValue).GroupBy(rs => rs.ClaimType);

            //一级目录.得到ClaimType分组.每一个分组.增加一级.容易查看.
            foreach (var item in rightScopeType)
            {
                tree_children.name = item.Key;

                //二级目录..得到一个分组.显示出来.
                foreach (RightScope rs in item)
                {                   
                    tree_children_last.type = rs.ClaimType;
                    tree_children_last.value = rs.ClaimValue; 
                }               
            }       

 分组后,直接Tolist()取得子集的方法

            var rightScopeType = rightScopes.OrderBy(rs => rs.ClaimValue).GroupBy(rs => rs.ClaimType);
            foreach (var item in rightScopeType)
            {               
                tree_children.name = item.Key;
                RightScope rs =item.Tolist();                           
            } 

 

posted on 2018-06-06 16:02  cxd1008  阅读(171)  评论(0编辑  收藏  举报