Linq:获取 DataContext 中所有表的列表 [英] Linq: Get a list of all tables within DataContext
本文介绍了Linq:获取 DataContext 中所有表的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含 100 多个表的 DataContext(Linq 到 Sql),是否可以获得所有这些表的列表并让我们说将它们打印到控制台?这可能是一个愚蠢的问题.
I have a DataContext (Linq to Sql) with over 100 tables, is it possible to get a list of all those tables and lets say print them to the console? This might be a silly question.
谢谢.
推荐答案
它比上面的要容易得多,而且不需要反思.Linq to SQL 有一个 Mapping 属性,您可以使用它来获取所有表的枚举.
It's much easier than above and no reflection required. Linq to SQL has a Mapping property that you can use to get an enumeration of all the tables.
context.Mapping.GetTables();
这篇关于Linq:获取 DataContext 中所有表的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文