c# - how to filter from nested collections without ForEach? -
i have entity type property type list of b. type b has property of type list of c. i want apply filter on object of such there c objects in list of c selected property true. this can done like: a obja = a.listb.foreach(b => {b.listc.removeall(c => c.selected == false);}); but don't have remove c objects have selected = false. want filter them. any ideas? more explanation: there object of type a, list of b property. in each b object of a's list of b, there exists list of c property. c object has selected property. now, need is- object of list of b, in each of b's list of c has c objects have selected = true. desirable output type a. list b shouldn't filtered list c needs filtered. what this: a.listb.where( b => b.listc.exists( c => c.selected ) ) is want?