C# / LINQ / get all elements of sub-collection matching a condition? -


i have :

observablecollection<x> x_collection = new observablecollection();  public class x {     public x()      {           items = new observablecollection<y>();          for(int = 0; < 10; i++)          {               items.add(new y(i % 2 == 0));          }     }     public observablecollection<y> items {get; set;} }  public class y {     public y() : this(true) {}     public y(bool y) { myproperty = y; }     public bool myproperty { get; set; } } 

how create linq query return ienumerable or observablecollection y elements have myproperty == true? realize it's easy question i'm pretty confused linq atm.

if possible i'd ask lambda-query - they're easier me understand

var result = items.where( y => y.myproperty );  var biggerresult = x_collection.selectmany( x => x.items.where( y => y.myproperty ) ); 

Comments

Popular posts from this blog

unicode - Are email addresses allowed to contain non-alphanumeric characters? -

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -