1
我有以下表Linq查询父子分组问题
Actions
ActionID Action NextActionID
1 Submit 2
2 Forward 3
3 Approve NULL
UserActionRights
UserID ActionID
5 1
6 2
7 3
8 2
我想这样
Action(Key) UserIDs(List)
1 6
7
2 7
3 "Empty List"
输出什么我已经试过这样的情况如下
(from a in actions join uar in UserActionRights on a.NextActionID equals uar.ActionID
Select new
{
Action=a.ActionID,
UserIDs=uar.UserID
}).ToList().AsEnumerable().GroupBy(x => x.ActionID).Select(y => new
{
Action = y.Key,
UserIDs = y.Select(tp=>tp.UserID)
}).ToList()
现在当ID = 5的用户登录时,我得到空输出,因为它没有ActionID = 2,3的权限。我需要修改查询,以获得所需的结果