Пример #1
0
        private void AddColumnTo(CreateTableSQLCommand table, string columnName, DbType type, int size, byte precision, byte scale, bool isNotNull, object defaultValue)
        {
            SqlObjectModel.LDD.ColumnConstraint constraint = null;
            if (defaultValue != null)
                constraint = new SqlObjectModel.LDD.DefaultConstraint(new Constant(defaultValue, type), !isNotNull);
            else
                constraint = new SqlObjectModel.LDD.ColumnConstraint(!isNotNull);

            if (!table.ColumnDefinitions.Contains(columnName))
            {

                ColumnDefinition column = new ColumnDefinition(columnName, type, size, precision, scale, constraint);
                table.ColumnDefinitions.Add(columnName, column);
            }
            else
            {
                ColumnDefinition column = table.ColumnDefinitions[columnName] as ColumnDefinition;
                column.ColumnConstraint = constraint;
            }
        }
Пример #2
0
        private void AddForeignKeysTo(CreateTableSQLCommand table, string columnName, string ref_column_name, string ref_table_name, GeneratorMapping map_generator, object defaultValue)
        {
            if (!table.ColumnDefinitions.Contains(columnName))
            {
                DbType type = _Dialect.GetDbTypeToPrimaryKey(map_generator);

                SqlObjectModel.LDD.ColumnConstraint constraint = null;
                if (defaultValue != null)
                    constraint = new SqlObjectModel.LDD.DefaultConstraint(new Constant(defaultValue, type), false);
                else
                    constraint = new SqlObjectModel.LDD.ColumnConstraint(true);

                int size = _Dialect.GetSizeToPrimaryKey(map_generator);
                ColumnDefinition column = new ColumnDefinition(columnName, type, size, constraint);
                table.ColumnDefinitions.Add(columnName, column);

                // Add foreign keys here

            }
        }
Пример #3
0
		/// <summary>
		/// Creates a new <see cref="ColumnDefinition"/> instance.
		/// </summary>
		/// <param name="column_name">Column_name.</param>
		/// <param name="type">Type.</param>
        /// <param name="size">Size.</param>
        /// <param name="precision">Precision.</param>
        /// <param name="scale">Scale.</param>
		/// <param name="column_constraint">Column_constraint.</param>
		public ColumnDefinition(string column_name, DbType type, int size, byte precision, byte scale, ColumnConstraint column_constraint) 
		{
			this._ColumnName = column_name;
			this._Type = type;
			this._ColumnConstraints = column_constraint;
            this._Size = size;
            this._Precision = precision;
            this._Scale = scale;
		}
Пример #4
0
 /// <summary>
 /// Creates a new <see cref="ColumnDefinition"/> instance.
 /// </summary>
 /// <param name="column_name">Column_name.</param>
 /// <param name="type">Type.</param>
 /// <param name="size">Size.</param>
 /// <param name="column_constraint">Column_constraint.</param>
 public ColumnDefinition(string column_name, DbType type, int size, ColumnConstraint column_constraint)
     : this(column_name, type, size, 0, 0, column_constraint)
 {
 }
Пример #5
0
		public abstract void Visit(ColumnConstraint constraint);
Пример #6
0
		public virtual void Visit(ColumnConstraint constraint)
		{
			if (!constraint.IsNull)
				_Query.Append(NOT).Append(NULL);
		}