Get generated tablename for an entity?
If I have the t开发者_StackOverflow社区ype 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.
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);
精彩评论