Have you read ScottGu's post about Dynamic LINQ? Might help: http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspxNothing in there about using a table dynamically though. You might be asking LINQ to do something that it can't.
Also, this isn't specific to dblinq. More appropriate to post this question on StackOverflow. On Fri, Feb 13, 2009 at 7:48 AM, Blair <[email protected]> wrote: > > Hi > > I have a feeling this is not possible but I thought I should ask in > any case. > > Is it possible to use DBLinq/Linq to query a table dynamically. > Something like: - > > string tableName = "my_table"; > var q = from p in db.GetTableX(tableName) select p; > > I have used GetTableX here as the existing methods GetTable doesn't > allow you to do this. > > I have several tables that all have an ID column and I would select a > row that has a particular ID. > > I have tried several methods including instantiating a generic > instance using Activator.CreateInstance and invoking a CreateQuery as > a GenericMethod. Unfortunately both methods just return an Object > which cannot be enumerated with Linq's select construct. > > I can see why this is tricky since the "<from> * <in> * <where> * > <select>" grammar needs strong typing. > > Thanks in advance, > Blair > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DbLinq" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/dblinq?hl=en -~----------~----~----~----~------~----~------~--~---
