Checking for duplicates in a complex object using Linq or Lambda expression -


i've started learning linq , lambda expressions, , seem fit finding duplicates in complex object collection, i'm getting little confused , hope can put me on path happy coding.

my object structured list.list.uniquecustomeridentifier

i need ensure there no duplicate uniquecustomeridentifier in entire complex object. if there duplicates, need identify duplicated , return list of duplicates.

  • unpack hierarchy
  • project each element uniqueid property
  • group these id's up
  • filter groups groups have more 1 element
  • project each group group's key (back uniqueid)
  • enumerate query , store result in list.

var result =    mylist     .selectmany(x => x.innerlist)     .select(y => y.uniquecustomeridentifier)     .groupby(id => id)     .where(g => g.skip(1).any())     .select(g => g.key)     .tolist() 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -