文档中要附上数据字典,当然这已经有很多现成的工具了,但在用linq to sql,又想尝试一种新的方法。
幸运,MS给我们准备的方法使用非常简单,只需如此:
1: class Program
2: {
3: static void Main(string[] args)
4: {
5: var db = new NorthwindDataContext();
6:
7: Console.WriteLine("Database: {0}", db.Mapping.DatabaseName);
8: var tables = from t in db.Mapping.GetTables()
9: orderby t.TableName
10: select t;
11: foreach (var table in tables)
12: {
13: Console.WriteLine(table.TableName);
14: foreach (var col in table.RowType.DataMembers)
15: {
16: Console.WriteLine("/t{0}/t{1}", col.MappedName, col.DbType);
17: }
18: }
19: Console.ReadLine();
20: }
21: }