Locked Pulling Dynamic table name using linq

  • Saturday, September 24, 2011 1:10 AM
     
     

    I have a scenario where I have a class that can be pulling data from many tables. The table select depends on the user interface. I am using LINQ but don't know how to dynamically select a table and its columns in a LINQ code. What if I want to have another join in my LINQ expression pulling data from a different table. Please help new to LINQ.

     

    thanks

    Saritha


    saritha k

All Replies

  • Monday, December 19, 2011 7:52 PM
     
     

    dynamically select my Table at runtime with Dynamic LINQ

    http://stackoverflow.com/questions/5032228/how-can-i-dynamically-select-my-table-at-runtime-with-dynamic-linq

    Please check above link to use dynamic table in Linq

  • Thursday, January 05, 2012 4:52 AM
     
      Has Code

    Hi,

    I think Entity SQL is best option for dynamic query. you can create command object and using the EntityCommandReader you can read the data.

    EntityCommand cmd = conn.CreateCommand();
    
    cmd.CommandText = @" SELECT VALUE p 
    
    FROM AdventureWorksEntities.Product AS p
    
    ORDER BY p.ListPrice ";
    
    
    <p>DbDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess);
    while (rdr.Read()) { }
    Hope, this will help you out. Feel free to contact in case of query.

    If this post answers your question, please click Mark As Answer. If this post is helpful please click Mark as Helpful.
    • Edited by Tejas T Thursday, January 05, 2012 4:53 AM
    •  
  • Monday, February 06, 2012 8:16 AM
     
     

    Hello,

    Check out the links below. It may help you.

    http://stackoverflow.com/questions/5032228/how-can-i-dynamically-select-my-table-at-runtime-with-dynamic-linq

    http://stackoverflow.com/questions/953911/dynamic-linq-setting-orderby-expression-type-at-runtime

    http://stackoverflow.com/questions/3673603/dynamic-table-name-linq-to-sql-dynamic-linq

    http://tomasp.net/blog/dynamic-linq-queries.aspx

  • Wednesday, February 08, 2012 5:49 AM
     
     

    http://boardreader.com/thread/Pulling_Dynamic_table_name_using_linq_5q8s8__4b8747b7-bc42-4330-9759-64438de8d72f.html

    http://forums.silverlight.net/t/170619.aspx

    http://stackoverflow.com/questions/5032228/how-can-i-dynamically-select-my-table-at-runtime-with-dynamic-linq