public class Mailing
{
public string To { get; set; }
public string AttachmentPath { get; set; }
public int AttachmentCount { get; set; }
}
giving this structure i have a IList<Mailing> mailingList
where To
has dups and the AttachmentPath
is unique per To.
i need to send emails to the mailingList where each unique To
has multiple attachments (ie AttachmentPath
s).
this partially works -- i can get the attachment count and iterate and add attachements as i need but i think this is ugly. i also need to limit a single email per group of attachments where the below completely breaks.
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();
any ideas?