<#@ template debug="true" hostspecific="true" language="C#" #> <#@ assembly name="System.Core" #> <#@ assembly name="System.Data" #> <#@ assembly name="System.Xml" #> <#@ assembly name="System.Configuration" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.Text" #> <#@ import namespace="System.Collections.Generic" #> <#@ import namespace="System.Data.SqlClient" #> <#@ import namespace="System.Data" #> <#@ output extension=".cs" #> using System;

namespace EIR.Module { <#     //System.Diagnostics.Debugger.Launch();//---进入调试     string nameClass= System.IO.Path.GetFileNameWithoutExtension(this.Host.TemplateFile);     string configPath=Host.ResolveAssemblyReference("$(ProjectDir)")+"app.config";     var configPathMap=new System.Configuration.ExeConfigurationFileMap(){ExeConfigFilename=configPath};     var appConfig=System.Configuration.ConfigurationManager.OpenMappedExeConfiguration(configPathMap, System.Configuration.ConfigurationUserLevel.None);     var connSection= appConfig.GetSection("connectionStrings") as System.Configuration.ConnectionStringsSection;      string cnnstr= connSection.ConnectionStrings["cnnstrMasterMssql"].ConnectionString;     string cmdstrForColDescription=string.Format("with htt as({0}),gmm as ({1}) select htt.name,gmm.value from htt left join gmm on htt.column_id=gmm.minor_id",                              "select * from sys.columns where object_id=OBJECT_ID('"+nameClass+"')",                              "select * from sys.extended_properties where sys.extended_properties.major_id=OBJECT_ID('"+nameClass+"')");     this.WriteLine(string.Format("{1}public class {0}",nameClass,new String(' ',4)));     this.WriteLine(new String(' ',4)+"{");     using (SqlConnection cnn = new SqlConnection(cnnstr))             {                 using (SqlCommand cmd = cnn.CreateCommand())                 {                     cnn.Open();                     cmd.CommandText = "select * from "+nameClass;                     SqlDataReader rr=cmd.ExecuteReader();                     DataTable table = rr.GetSchemaTable();                     rr.Close();                     cmd.CommandText=cmdstrForColDescription;                     using(SqlDataAdapter adapater=new SqlDataAdapter(cmd))                     {                         DataTable tableDesp=new DataTable();                         adapater.Fill(tableDesp);                         foreach (DataRow row in table.Rows)                         {                             string colName = row["ColumnName"].ToString();                             string colType = row["DataType"].ToString().Substring(7);        bool allowDBNull=Convert.ToBoolean(row["AllowDBNull"]);                             if(allowDBNull && !colType.Equals("String"))                                     colType="Nullable<"+colType+">";                             this.WriteLine(string.Format("{3}/// <summary>",colType,colName,"{set;get;}",new String(' ',8)));                             this.WriteLine(string.Format("{3}///{4}",colType,colName,"{set;get;}",new String(' ',8),tableDesp.Select("name='"+colName+"'")[0]["value"].ToString().Replace("\r\n"," ").Replace("\n"," ").Replace("\n"," ")));                             this.WriteLine(string.Format("{3}/// </summary>",colType,colName,"{set;get;}",new String(' ',8)));                             this.WriteLine(string.Format("{3}public {0} {1} {2}",colType,colName,"{set;get;}",new String(' ',8)));                         }                     }                 }             }  #>     } }

sql的列的说明的更多相关文章

  1. SQL Server 列存储索引强化

    SQL Server 列存储索引强化 SQL Server 列存储索引强化 1. 概述 2.背景 2.1 索引存储 2.2 缓存和I/O 2.3 Batch处理方式 3 聚集索引 3.1 提高索引创建 ...

  2. SQL 计算列

    SQL计算列,可以解决一般标量计算(数学计算,如ColumnA*ColumnB)的问题,而子查询计算(如select sum(salary) from tableOther where id=’ABC ...

  3. SQL 一列数据整合为一条数据

    SQL 一列数据整合为一条数据: SELECT  STUFF(( SELECT distinct  ',' + 列名 FROM 表名 where  [条件] FOR XML PATH('') ), 1 ...

  4. jmeter奇淫妙计之遍历sql多列结果集

    foreach控制器加${__V()}函数和${__counter(TRUE,)}函数 处理sql多列结果的遍历真的是绝配啊,之前一直用循环控制器+count函数,或者while控制器加count函数 ...

  5. Sql 标识列 增长1000

    Sql 标识列 增长1000 的解决办法: 1. Open "SQL Server Configuration Manager" 2. Click "SQL Server ...

  6. MS SQL 标识列的查询

    摘自: http://www.2cto.com/database/201212/175000.html   SQL标识列的查询   1.判段一个表是否具有标识列    www.2cto.com   可 ...

  7. SQL 序号列ROW_NUMBER,RANK,DENSE_RANK、NTILE

    原文:SQL 序号列ROW_NUMBER,RANK,DENSE_RANK.NTILE SQL 2005新增加相关函数 : ROW_NUMBER,RANK,DENSE_RANK.NTILE 窗口函数 O ...

  8. 使用Spark加载数据到SQL Server列存储表

    原文地址https://devblogs.microsoft.com/azure-sql/partitioning-on-spark-fast-loading-clustered-columnstor ...

  9. SQL Server 列存储性能调优(翻译)

    原文地址:http://social.technet.microsoft.com/wiki/contents/articles/4995.sql-server-columnstore-performa ...

  10. SQL动态列查询

    数据库中为了实现表格数据的自由设置,我们经常设计纵表,或者列定义的表(如下KeyValue),定义一个列超级多的表中每个字段的意义. 但是在设计时简单的东西却很容易被人们忘记,如下一个简单但是很松散的 ...

随机推荐

  1. Apache Commons Chain

    http://commons.apache.org/proper/commons-chain/ http://commons.apache.org/proper/commons-chain/cookb ...

  2. mysql5.7下的timestampn Error : Invalid default value for 'timestamp'

    表格创建是爆了个错 Error : Invalid default value for 'timestamp' 参考:http://www.jb51.net/article/71107.htm 这版本 ...

  3. 移动端重构实战系列2——line list

    这个line list的名字是我自己起的(大概的意思是单行列表),要实现的东西为sheral的line list,对应的scss组件为_line-list.scss,下图为line-list的一个缩影 ...

  4. 基础算法之快速排序Quick Sort

    原理 快速排序(Quicksort)是对冒泡排序的一种改进. 从数列中挑出一个元素,称为"基准"(pivot); 排序数列,所有元素比基准值小的摆放在基准前面,所有元素比基准值大的 ...

  5. SWM格式稀疏权重矩阵转换为方阵形式全过程分享

    在进行空间统计实验过程中,经常涉及到空间权重矩阵的处理,有时候需要将ArcGIS生成的swm格式的权重矩阵转换为形如“0 1”的方阵格式.这里将我的办法整理出来. 1.用如下工具箱生成swm格式的权重 ...

  6. SQLSERVER和ORACLE系统表获取表名 列名以及列的注释

    在工作中从数据库取的数据要导出来,但是发现导出的EXCEL中列名都是字段名(英文),为此搜集资料怎么把字段名变为中文名称,而发现ORACLE和SQLSERVER(用的SQLSERVER2008R2)又 ...

  7. hibernate入门实例

    1. 环境配置 1.1 hiberante环境配置 hibernate可实现面向对象的数据存储.hibernate的官网:http://hibernate.org/ 官网上选择hibernate OR ...

  8. Java条件语句练习

    /*System.out.println("请输入三个数字:");//输入三个数字,返回最大的那个. int a,b,c,big; Scanner d = new Scanner( ...

  9. ios 重签名

    http://stackoverflow.com/questions/6569120/resigning-an-application-outside-xcode #!/bin/sh TEMPDIR= ...

  10. 三角形-css

    /*箭头向上*/ .arrow-up { width:; height:; border-left:30px solid transparent; border-right:30px solid tr ...