【发布时间】:2013-09-16 19:21:41
【问题描述】:
我有三个相关的表。
Letter(Id,Name)
SendLetter(Id,LetterId)
ReciveLetter(Id,SendLetterId,Type,User)
我想获取 Group By SenLetterId & Type 的 ReciveLetter 记录。
我使用这个查询。
var dashbord = from d in db.ReceiveLetter
where (d.SendLetter.LetterId == LetterId)
group d by new { d.SendLetter, d.SendType } into g
select new Items{ ...... };
它是按 SendLetterId 和 Type 分组的项目。我想为每个分组项目选择用户名的加入。
例如:
SendLetter:
1 1
2 1
ReciveLetter:
1 1 Type1 A
1 1 Type1 B
1 1 Type2 C
1 2 Type1 D
1 2 Type1 E
Result:
1 1 Type1 A,B
1 1 Type2 C
2 1 Type1 D,E
【问题讨论】:
-
选择加入用户名?你的意思是你想从每个组中获取用户名?
-
我想加入每个组的所有用户名