Dynamic LINQ
Something I just saw for the first time is a Microsoft C# sample application called DynamicQuery. This allows you to enter part of a LINQ query as a string.
If you have Visual Studio 2008 installed, you can find the samples in this directory: C:\Program Files\Microsoft Visual Studio 9.0\Samples\1033. Then extract the file CSharpSamples.zip. The sample will be found at CSharpSamples\LinqSamples\DynamicQuery.
From the sample you will see that you can do perform things like this:
var query = db.Customers.Where( "City == @0 and Orders.Count >= @1", "London", 10). OrderBy("CompanyName"). Select("New(CompanyName as Name, Phone)");
All of the heavy lifting happens in the Dynamic.cs file that has 11 classes. The interface happens through DynamicQuery static class, which extends the IQueriable interface with new Where, OrderBy, and Select methods. To use these extensions you have to include this line in your code: using System.Linq.Dynamic; along with the Dynamic file in your project.
I don’t have a use for this quite yet, but I think its time will come.


