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 AttachmentPaths).
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?
Should Produce an IEnumerable of annonymous types with the following properties:
Note: Yes this can be turned into 1 linq statement, but i broke it into two for clarity purposes