Beispiel #1
0
        public override string ColumnToSql(DBConnection db, DBColumn column, bool includeDefault)
        {
            DBForeignKey foreignKey = (column.Tabloid as DBTable).ForeignKeys.SingleOrDefault(fk => fk.SourceColumn == column.Name);

            return
                ($"{AddQuote(column.Name)} " +
                 $"{DataType.FullDefinition(column.Type, Type, column.MaxLength)} " +
                 $"{(column.IsPrimary ? AutoIncrement : "")}" +
                 $"{(column.IsNullable ? " NULL" : " NOT NULL")}" +
                 $"{(includeDefault && !string.IsNullOrEmpty(column.DefaultValue) ? $" CONSTRAINT {DefaultName(db.Application, column.Tabloid.Name, column.Name)} DEFAULT {column.DefaultValue}" : "")}");
        }
Beispiel #2
0
 public virtual string ForeignKeyToSql(DBConnection db, DBForeignKey fk)
 {
     return($"CONSTRAINT {ForeignKeyName(db.Application, fk.SourceTable.Name, fk.SourceColumn, fk.TargetTable.Name, fk.TargetColumn)} " +
            $"FOREIGN KEY ({AddQuote(fk.SourceColumn)}) " +
            $"REFERENCES {ToRealTableName(db.Application, fk.TargetTable.Name)}({AddQuote(fk.TargetColumn)})");
 }