HowTo? LINQ Query Table Name (Range Variable) Not Known Until Runtime

J

Joey

I am querying a DataSet with LINQ. I am running into a problem when
trying to construct my query because in the "from" clause I do not
know the table name (range variable) until runtime. Possible table
names might include "SomeTable1" or "SomeTable236" etc...
Unfortunately when I try to use something like "from SomeTable +
MyChangingNumber.ToString() in..." in my from clause it does not work.
How can I set this up to use a range variable whose value is dynamic /
not known until runtime?
 
B

bruce barker

Linq does not support this. the lambda expression that represents the table
name is converted to an expression tree at compile time (so no variables
allowed). you can write you own method to create the expression tree at
runtime, and then construct the linq query.


-- bruce (sqlwork.com)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,570
Members
45,045
Latest member
DRCM

Latest Threads

Top