1
public class Mailing
{
public string To { get; set; }
public string AttachmentPath { get; set; }
public int AttachmentCount { get; set; }
}
给这个结构,我有一个IList<Mailing> mailingList
其中To
具有的DUP和AttachmentPath
是每个独特。Linq的分组查询
我需要发送邮件到邮件列表,其中每个唯一To
有多个附件(即AttachmentPath
s)。
这部分工作 - 我可以得到附件计数和迭代和添加附件,因为我需要但我认为这是丑陋的。我还需要限制每组附件中的一封电子邮件,其中下面的内容完全中断。
var investorMailings = (from m in mailingList
group m by new
{
m.GroupBy,
m.To
}
into g
select new DistintInvestorMailing
{
To = g.Key.To,
AttachmentCount = g.Count()
}).ToList();
有什么想法?
什么是'm.GroupBy'? – 2010-04-19 19:23:53
请忽略m.GroupBy。我忘了把它留下了,请在这个例子中忽略m.GroupBy。 – CurlyFro 2010-04-19 19:30:48