LINQ table enumeration with column enumeration?

LINQ to SQL Trick: Get all Table and Column Names: blogs.msdn.com/jomo_fisher/archive/2007/....

What you are describing is essentially an ORM Linq to SQL is an ORM that will create prototype c# classes for you that contain the information you are describing. It has excellent support for the kind of data binding that you have illustrated.

We are using Linq to SQL however I have no idea how to reference the column names are strings. Any links to offer so I can read up? I feel like I'm missing something entirely obvious.

– Nazadus May 26 '09 at 15:22.

I think you are looking for this. DataContext.Mapping. GetTable(yourTable).RowType.DataMemebers().

I can think of two ways to do this. A) Use SMO to get all the tables / columns in a database. You need to reference: Microsoft.SqlServer.

ConnectionInfo Microsoft.SqlServer.Management.Sdk. Sfc Microsoft.SqlServer. Smo Then, you can do something like this: ServerConnection connection = new ServerConnection("."); Server server = new Server(connection); Database db = server.

Databases"Northwind"; foreach (Table table in db. Tables) { foreach (Column column in table. Columns) { Console.

WriteLine("Table: {0}, Column: {1}",table. Name,column.Name); } } } B) Use reflection to reflect over your assembly with the dataclasses generated by Linq to Sql. Anything with a Table attribute is a table, and anything with a Column attribute is a column.

Let me know if you need a sample...

I've found posts that describe one or the other, but not both. I'm currently using this method which while it works, it means I have to manually create my tables in a list. I have a seperate command line project which generates the SomeNameSpace.

SomeTable class manually and I add the generated class file in to the project. Is there a better way to do this other than manually have to do the databaseContext.ColumnNames()? We're using LinqToSQL.

Moving to ADO.NET also an option on the table, but at the moment we have no pressing need to. I know L2S does databinding but what I'm after is getting a list of column names as strings from a table. L2S doesn't offer this or it's not apparent on my side.

I'd like to do something like: SomeTable.SomeColumn.ToString() or something. SubSonic has this. All are very good answers and lead me to the answer.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions