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

ruby - When to use an ORM (Sequel, Datamapper, AR, etc.) vs. pure SQL for querying -

php - PHPDoc: @return void necessary? -

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