I think this translates into from p in ParentColl from c in p.ChildColl where c.Type == "Foo" select c;
which I think makes it easier to visualize what is going on (also, you can add more "froms" in easily Michael M. Minutillo Indiscriminate Information Sponge http://codermike.com On Fri, Mar 2, 2012 at 8:06 AM, David Burela <[email protected]> wrote: > I only discovered that one myself a few weeks ago while studying for my > final MCPD exam. > Had no idea that it existed, but now it makes so much sense that it does. > Thanks for sharing it Greg! > > -David Burela > > > On 2 March 2012 09:29, Greg Keogh <[email protected]> wrote: > >> Just a Friday morning heads up. Last night I had to search through a >> collection of object collections, and knew I wanted a “flatten” operator >> like Mathematica and other languages have, but couldn’t find one. I started >> coding LINQ Aggregate with Concat and creating a LISP-like clever mess. I >> thought this was a bit silly so I flipped through one of my books and >> suspected that SelectMany might be what I want. The description of the >> operator was a bit misleading (and so is the name), but it turns out that >> SelectMany is actually a “Flatten” in disguise. So you can simply do this: >> **** >> >> ** ** >> >> ParentColl.SelectMany(p => p.ChildColl).Where(c => c.Type == "Foo");**** >> >> ** ** >> >> Greg**** >> > >
