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:

  1. emailaddress1@gmail.com
  2. emailaddress1@gmail.com
  3. emailaddress2@gmail.com
  4. emailaddress2@gmail.com
  5. emailaddress2@gmail.com
  6. emailaddress3@gmail.com
  7. 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

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -