Beispiel #1
0
        public static List <TableColumn> BuildTableColumns(List <Column> columns, string tableName)
        {
            var list = new List <TableColumn>();

            foreach (var item in columns)
            {
                var col = new TableColumn
                {
                    AllowNull    = item.IsNullable == YesNoOption.YES,
                    DataType     = item.DataType,
                    DefaultValue = item.ColumnDefault,
                    Identity     = item.AutoIncrementBy > 1,
                    Name         = item.ColumnName,
                    Precision    = byte.Parse(item.NumericPrecision.ToString()),
                    //TODO Detect!
                    PrimaryKey = false,
                    Scale      = byte.Parse(item.NumericScale.ToString())
                };
                short colLength;
                if (short.TryParse(item.CharacterMaxLength.ToString(), out colLength))
                {
                    col.Length = colLength;
                }
                if (TableDataType.IsLengthFixed(item.DataType))
                {
                    col.Length = TableDataType.GetDefaultLength(item.DataType);
                }
                list.Add(col);
            }
            return(list);
        }