tags:

views:

63

answers:

2

Sorry if I didn't explained it right in the title, but here it goes:

I want to do execute a LINQ query, and I have the name of the table to query stored in a variable:

string tableName = "SomeTable";

DataContext db = new DataContext();

var vResult = from t in db.tableName
where t.Id = ....
A: 

You might want to look at DataContext.ExecuteQuery<T>. However, that still doesn't solve the problem that your results might be different types.

David B
+2  A: 

Use Reflection on the DataContext to find a property named tableName

Paul Betts