发布时间:2024-01-17 11:33:32来源:https://www.cnblogs.com/bamboo-zhang/p/10128920.html阅读(636)
1、linq列转行(如图从上到下,action_type即power字段),其实严格意义上来说,并不是linq,只是用了循环
List leaf = new List();
//列出所有操作权限
managerList.Where(t => t.action_type.Length > 0).ForEach(
a => a.action_type.Split(',').ForEach((t) => leaf.Add(new NavigationDto {
id = a.id+"_"+ t,
parent_id=a.id,
name = t,
title =t
})));
2、linq行转列 (如图从下到上,action_type即power字段)
var actPower = leafPower.GroupBy(t => t.navigation_id).Select(
t => new dt_manager_role_value() { navigation_id = t.Key, role_id = RoleID,
action_type = string.Join(",",t.Select(p=>p.action_type))});
关键字: 行转列
上一篇: JS判断null
1635
1843
1369
1751
1602
1016
1318
1594
944
1531
9579
5991
5517
5113
4563
4270
3412
3331
3326
3264