【发布时间】:2012-04-17 00:41:42
【问题描述】:
我有以下表格
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 的权限。我需要修改查询以获得想要的结果
【问题讨论】:
标签: asp.net-mvc linq entity-framework entity-framework-4