crm - LINQ Query To Return Duplicates Exclusively -
i'm working on linq query. i'd resulting list return list of records contain duplicates exclusively, based on emailaddress1 field , grouped emailaddress1 field.
for instance:
- emailaddress1@gmail.com
- emailaddress1@gmail.com
- emailaddress2@gmail.com
- emailaddress2@gmail.com
- emailaddress2@gmail.com
- emailaddress3@gmail.com
- emailaddress3@gmail.com
etc.
any advice on this? thanks.
var contacts = (from c in xrm.contactset c.statecode != 1 orderby c.emailaddress1, c.createdon descending select new { c.firstname, c.lastname, c.emailaddress1, c.contactid, c.createdon }).tolist();
based on previous query:
var duplicatedemails = (from c in contacts group c c.emailaddress1 g g.count() > 1 select g.key).tolist(); var duplicatedcontacts = contacts.where(c => duplicatedemails.contains(c.emailaddress1));
Comments
Post a Comment