I have a query that I need to create as a string, transport over WCF and and then compile into LINQ at the other end. The reason that I'm not transporting the actual LINQ query itself over WCF is because the method which produces the query should have no knowledge of the source type used in the query (i.e. no dependencies).
Here's the problem then: I pass my query over the wire as a string, have CSharpCodeProvider try and compile it and it can't find the data source referenced in the query (serverSource in the code below). How do I go about creating this query and compiling with CSharpCodeProvider?
var newQuery = @"using System.Linq;" +
"public class SIQuery" +
"{" +
"public static void Main(string[] args)" +
"{" +
"var siQuery = from e in " + serverSource + " where e % 5 == 0 select e;" +
"}" +
"}";
I've tried defining serverSource before compiling at runtime (var serverSource = application.GetStreamable<long>("serverSource");
) but this doesn't have any affect on the outcome (the fact that serverSource can't be found).
Thanks in advance!