Monday, May 21, 2012

Use of LINQ on Arbitrary Tables

I love LINQ esp. LINQ to SQL. The use of LINQ for static tables (where the structure of the table is known before hand) is great.



I now have a list of tables where I only know the Table Name (as a string). I also know that each row in the table would have an ID/Primary Key(int) and a number of undetermined columns whose datatypes are varchar/string. I can get the names of the columns using SMO.



I am wondering what is the best way to query these columns e.g. run a distinct on each of them? LINQ to SQL seems to be pretty efficient by converting the query directly to SQL. I would prefer not to write the SQL by hand.



Please let me know your ideas.



Thank you,
O. O.





No comments:

Post a Comment