Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > HowTo? LINQ Query Table Name (Range Variable) Not Known Until Runtime

Reply
Thread Tools

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

 
 
Joey
Guest
Posts: n/a
 
      04-23-2008
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?
 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      04-23-2008
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)


"Joey" wrote:

> 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?
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linq or not Linq George ASP .Net 4 11-05-2008 04:53 PM
Accessing DropDownList info and values that aren't known until runtime? ASP .Net 1 12-09-2004 05:43 AM
How to access DropDownList info and values that aren't known until runtime? ASP .Net Web Controls 4 12-09-2004 01:35 AM
How to access symbol when its dimensionality is not known till runtime (About to giveup) Christopher M. Lusardi C++ 2 12-18-2003 05:40 PM
How to instatiate a class of which the name is only known at runtime? Marco Herrn Python 14 09-15-2003 11:56 PM



Advertisments