Do not miss a great article about the internals of building dynamic LINQ queries – Dynamically Composing Expression Predicates.
I’ve still not quite bought the idea of LINQ. It’s compact, descriptive and strongly timed – all great, but … Actually I’d like to say: BUT! This “but” is a big question mark for the LINQ’s feasibility. It’s not flexible enough for our day-to-day tasks. It’s as hard-coded as “foreach” contract. More descriptive and nice looking, but still a very fancy “foreach” loop.
I think Dynamic LINQ is about to change my perspective on LINQ, but, while it gives more flexibility, it breaks the nice and fit LINQ constructs and brings us back to SQL-like queries where we have no strong types and no compiler-time check. Bottom line – back to square one.
I think we need either another .NET compiler revision to support dynamic LINQ (where it’ll allow us to emit LINQ queries from strings) or a some kind of LINQ Dom in-memory compiler library. I’m, actually, leaning towards the lateral (see my post CodeDom extensions and dynamic LINQ (string/script to LINQ emitting)).