分组后,循环子集的方法
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(); }
本文为博主原创文章,欢迎转载,但转载须注在明显位置注明【博客地址】和【原文地址】,否则将追究法律责任。http://www.cnblogs.com/cxd1008