If you look in the following path file:\\C:\Program Files\Microsoft Visual Studio 9.0\Samples\1033\ you will see a zip file called
CSharpSamples.zip. Inside is a folder called "LinqSamples" and another called "LanguageSamples". The LinqSamples includes a folder
called DynamicQuery which shows how to do this.
For example:
var query =
db.Customers.
Where("City = @0 and Orders.Count >= @1", "London", 10).
OrderBy("CompanyName").
Select("new(CompanyName as Name, Phone)");
I have used this will LINQ to SQL and it works well. I don't understand why Microsoft didn't make this a standard part of .NET 3.5
(since they almost did it with LinqDataSource).
I haven't tried it with XML. Let us know how it works.
Mike
You can use the CSharpCodeProvider to compile code, if that helps.
--
Jon Skeet - <
[email protected]>
Web site:
http://www.pobox.com/~skeet
Blog:
http://www.msmvps.com/jon_skeet
C# in Depth:
http://csharpindepth.com
Thanks Jon, What I am trying to do is similar to SQL, I want to build
the Linq on the fly on which columns to display and then like sql
executescalar or something, is it possible to run the build linq? I
want to execute the linq statement I build.