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

Discussion in 'ASP .Net' started by Joey, Apr 23, 2008.

  1. Joey

    Joey Guest

    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?
     
    Joey, Apr 23, 2008
    #1
    1. Advertising

  2. Joey

    bruce barker Guest

    RE: HowTo? LINQ Query Table Name (Range Variable) Not Known Until Runt

    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?
    >
     
    bruce barker, Apr 23, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    1
    Views:
    588
    Lowell Heddings
    Dec 9, 2004
  2. Marco Herrn
    Replies:
    14
    Views:
    496
    Peter Otten
    Sep 16, 2003
  3. Bobby Chamness
    Replies:
    2
    Views:
    2,426
    Joe Smith
    Apr 22, 2007
  4. George

    Linq or not Linq

    George, Nov 4, 2008, in forum: ASP .Net
    Replies:
    4
    Views:
    378
    Mike Gleason jr Couturier
    Nov 5, 2008
  5. Guest
    Replies:
    4
    Views:
    133
    Guest
    Dec 9, 2004
Loading...

Share This Page