文档中要附上数据字典,当然这已经有很多现成的工具了,但在用linq to sql,又想尝试一种新的方法。

幸运,MS给我们准备的方法使用非常简单,只需如此:

 

class Program
{
   
static void Main(string[] args)
    {
        NorthwndDataContext db
= new NorthwndDataContext();

        Console.WriteLine(
"Database: {0}",db.Mapping.DatabaseName);
        var tables
= from t in db.Mapping.GetTables()
                     orderby t.TableName
                     select t;
       
foreach (var table in tables)
        {
            Console.WriteLine(table.TableName);
           
foreach (var col in table.RowType.DataMembers)
            {
                Console.WriteLine(
"\t{0}\t{1}", col.MappedName,col.DbType);
            }
        }
        Console.ReadLine();
    }
}

相关文章:

  • 2022-03-07
  • 2022-01-01
  • 2022-12-23
  • 2021-11-04
  • 2021-10-23
  • 2021-07-13
  • 2021-12-26
猜你喜欢
  • 2021-07-27
  • 2021-10-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-15
  • 2021-10-21
相关资源
相似解决方案