Search code examples
c#linqlinq-to-sqlc#-4.0expression-trees

using reflection and linq for dynamic linq


I wrote this code:

string Dcname = "DataClasses1DataContext";
string TableName = "Order";
var dc =(DataContext)Activator.CreateInstance(typeof(DataContext), Dcname);
ITable mytbl=(ITable)dc.GetType().GetProperty(TableName).GetValue(dc,null);

I want to query mytable using linq or Expression Tree.

How I can do this?


Solution

  • I think you need to use Linq compiler for such scenario.