开发者

Get generated tablename for an entity?

开发者 https://www.devze.com 2022-12-20 02:24 出处:网络
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 ta

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);
0

精彩评论

暂无评论...
验证码 换一张
取 消