Ejemplo n.º 1
0
 public static ConstraintForeignKey MockConstraintForeignKey() => ConstraintForeignKey.CreateNew(
     Schema,
     NameConstraint,
     NameTable,
     NameTableColumn,
     ReferencedSchemaName,
     ReferencedTableName,
     ReferencedColumnName,
     null);
Ejemplo n.º 2
0
        private Column TabToModelColumn()
        {
            columnDataLengthTextBox.Text.ParseNullable(out var dataLength);

            ConstraintForeignKey foreignKey = null;

            if (columnIsFkCheckBox.Checked)
            {
                var index = Constraint.CreateNew(columnsSchemaTextBox.Text, columnIndexNameTextBox.Text, columnsTableNameTextBox.Text, columnColumnTextBox.Text, null);

                foreignKey = ConstraintForeignKey.CreateNew(columnsSchemaTextBox.Text, columnFkNameTextBox.Text, columnsTableNameTextBox.Text,
                                                            columnColumnTextBox.Text, columnRefSchemaNameTextBox.Text, columnRefTableNameTextBox.Text, columnRefColumnNameTextBox.Text, index);
            }

            tabColumn = Column.CreateNew(columnsSchemaTextBox.Text, columnsTableNameTextBox.Text, columnColumnTextBox.Text,
                                         (DataType)columnTypeComboBox.SelectedValue, dataLength, columnDefaultTextBox.Text, columnIsNullableCheckBox.Checked,
                                         columnCommentTextBox.Text, false, null, false, null, columnIsFkCheckBox.Checked, foreignKey);

            return(tabColumn);
        }
Ejemplo n.º 3
0
        private Table TabToModelTable()
        {
            var columns = new HashSet <Column>();

            //Loop through each row and form column, comment, foreign key script values.
            foreach (DataGridViewRow row in tableColumnsGrid.Rows)
            {
                ConstraintForeignKey foreignKey = null;

                var hasForeignKeyConstraint = GetCellValueBool(row, tableCellKeyIsForeignKey);
                if (hasForeignKeyConstraint)
                {
                    var index = Constraint.CreateNew(
                        tableSchemaTextBox.Text,
                        GetCellValue <string>(row, tableCellKeyIndexName),
                        tableTableNameTextBox.Text,
                        GetCellValue <string>(row, tableCellKeyName),
                        null);

                    foreignKey = ConstraintForeignKey.CreateNew(
                        tableSchemaTextBox.Text,
                        GetCellValue <string>(row, tableCellKeyForeignKeyName),
                        tableTableNameTextBox.Text,
                        GetCellValue <string>(row, tableCellKeyName),
                        GetCellValue <string>(row, tableCellKeyForeignKeyReferencedSchema),
                        GetCellValue <string>(row, tableCellKeyForeignKeyReferencedTable),
                        GetCellValue <string>(row, tableCellKeyForeignKeyReferencedTableColumn),
                        index);
                }

                var        hasPrimaryKey = GetCellValueBool(row, tableCellKeyIsPrimaryKey);
                Constraint primaryKey    = null;
                if (hasPrimaryKey)
                {
                    primaryKey = Constraint.CreateNew(
                        tableSchemaTextBox.Text,
                        tablePKTextBox.Text,
                        tableTableNameTextBox.Text,
                        GetCellValue <string>(row, tableCellKeyName),
                        null);
                }

                var        hasUniqueConstraint = GetCellValueBool(row, tableCellKeyIsUnique);
                Constraint uniqueConstraint    = null;
                if (hasUniqueConstraint)
                {
                    uniqueConstraint = Constraint.CreateNew(
                        tableSchemaTextBox.Text,
                        GetCellValue <string>(row, tableCellKeyUniqueConstraintName),
                        tableTableNameTextBox.Text,
                        GetCellValue <string>(row, tableCellKeyName),
                        null);
                }

                GetCellValue <string>(row, tableCellKeyDataLength).ParseNullable(out var dataLength);
                var isNullable = GetCellValueBool(row, tableCellKeyIsNullable);

                var column = Column.CreateNew(
                    tableSchemaTextBox.Text,
                    tableTableNameTextBox.Text,
                    GetCellValue <string>(row, tableCellKeyName),
                    GetCellValue <DataType>(row, tableCellKeyType),
                    dataLength,
                    GetCellValue <string>(row, tableCellKeyDefault),
                    isNullable,
                    GetCellValue <string>(row, tableCellKeyComment),
                    hasPrimaryKey,
                    primaryKey,
                    hasUniqueConstraint,
                    uniqueConstraint,
                    hasForeignKeyConstraint,
                    foreignKey);

                columns.Add(column);
            }

            tabTable = Table.CreateNew(
                tableTableNameTextBox.Text,
                tableSchemaTextBox.Text,
                tableTableCommentTextBox.Text,
                tableTablespaceTextBox.Text,
                columns);

            return(tabTable);
        }