0

我的数据表中有 2 列(电子邮件 ID 作为第一列有重复值)和超过 1 行。现在我需要根据电子邮件 ID 按行分组并将新结果写入另一个数据表。

当前结果:

MailID Name
v@v.in Venil
v@v.in Neithal 
a@a.in Iniyan
a@a.in Kavin
b@b.in Oviya
b@b.in Thamizh

预期结果:

MailID Name
v@v.in Venil, Neithal
a@a.in Iniyan, Kavin
b@b.in Oviya, Thamizh

请向我提供 linq 代码以实现上述结果。提前致谢。

4

3 回答 3

1
from email in emailTable
group email by email.id into grp
order by grp.Key
select new { Email = g.Key, Names = /*Your code here to get the names be in comma separated or however*/ }
于 2013-10-07T04:47:29.553 回答
0
var results = collection.GroupBy(p => p.emailID).ToList();

That is what you need.

于 2013-10-07T04:49:13.563 回答
0

使用分组:

from email in emailAddresses
group email by email.emailId
于 2013-10-07T04:46:00.407 回答