Ejemplo n.º 1
0
        private static void WriteColumnDDL(ColumnInfo column, TextWriter writer)
        {
            writer.Write("\t[{0}] ", column.Name);

            if (column.Calculation == null)
            {
                writer.Write(column.Type.ToString().ToLower());
                if (column.Size > -1)
                    writer.Write("({0})", column.Size);
                if (column.IsMaxSize)
                    writer.Write("(MAX)");
                else if (column.Precision > -1 && column.Scale > -1)
                    writer.Write("({0},{1})", column.Precision, column.Scale);
                if (column.Collation != null)
                    writer.Write(" COLLATE {0}", column.Collation);
                writer.Write(column.IsNullable ? " NULL" : " NOT NULL");
                if (column.IsIdentity)
                    writer.Write(" IDENTITY({0},{1})", column.IdentitySeed, column.IdentityIncrement);
            }
            else
            {
                writer.Write(" AS {0}", column.Calculation);
            }
        }
Ejemplo n.º 2
0
 private static void LoadColumnInfo(SqlDataReader dr, IDictionary<TableName, TableInfo> tables)
 {
     while (dr.Read())
     {
         TableName tablename = new TableName((string)dr["SchemaName"], (string)dr["TableName"]);
         TableInfo table = LoadTableInfo(tables, tablename);
         ColumnInfo column = new ColumnInfo(dr["ColumnName"], dr["Type"], dr["Size"], dr["Precision"], dr["Scale"], dr["IsNullable"], dr["IsIdentity"], dr["IdentitySeed"], dr["IdentityIncrement"], dr["Calculation"], dr["Position"], dr["Collation"]);
         table.Columns.Add(column);
         table.HasIdentity |= column.IsIdentity;
     }
 }