If I have the type of my entity generated by linq2sql, how can I get the name of the table the entity belongs to? I want the tablename generated by linq2sql not the database table name.
A:
Here is some code that would get all table names from a database. You could easily modify this to get the name of a single table.
var model = yourDBContext.Mapping;
foreach (var mt in model.GetTables())
Console.WriteLine(mt.TableName);
Randy Minder
2010-02-11 20:39:54