.net - LINQ check for duplicates in nested collection -


i have collection col1 , each 1 of has collection col2.

i want know if col2 have duplicate value, , when col2.type= "atype".

col1    col2    type    value col1a   col2a   atype   10 col1a   col2b   btype   10 col1a   col2c   atype   15 col1b   col2a   atype   10 col1b   col2b   ctype   20 col1b   col2c   atype   30 

^ return false, there no duplicates in col2 atype

col1    col2    type    value col1a   col2a   atype   10 << dupe col1a   col2b   btype   15 col1a   col2c   atype   10 << dupe col1b   col2a   atype   10 col1b   col2b   ctype   20 col1b   col2c   atype   30 

^ return true

bool anydups = col1     .any(c1 => c1.col2         .where(c2 => c2.type == "atype")         .groupby(c2 => c2.value)         .any(g => g.count() > 1)); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -