I love LINQ. LINQ is just fun to use. I love the fact that I can query the same way across databases, XML documents and objects (alright XML is slightly different, but...)
Today I had the task of querying down a complex set of objects that each own a collection data member. I needed to get to some data 4-layers deep and thought the LINQ query would get pretty nasty. That is until I learned that I can use the "from" keyword multiple times in the same LINQ query.
My example will be very contrived to save having to look at a lot of extra code for different collections, so I'll go ahead and just nest the same collection several layers down, just so we get the concept.
I have a Person class:
If I set up a new List<Person> like so:
Check out how easy it is to get to data that is below the top layer:
And I'll put a shameless plug out there for LINQPad since I took a screenshot from its results above. It is a fantastic tool for crafting LINQ queries and is a wonderful sandbox for small .NET proof-of-concept projects because you can write small programs without creating a Visual Studio project or solution.