public string SqlForConstraint(ForeignKeyConstraintType constraintType) { switch (constraintType) { case ForeignKeyConstraintType.Cascade: return "CASCADE"; case ForeignKeyConstraintType.Restrict: return "RESTRICT"; case ForeignKeyConstraintType.SetDefault: return "SET DEFAULT"; case ForeignKeyConstraintType.SetNull: return "SET NULL"; default: return "NO ACTION"; } }
public override void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable, string[] refColumns, ForeignKeyConstraintType constraint) { GuardAgainstMaximumIdentifierLengthForOracle(name); if (ConstraintExists(primaryTable, name)) { Logger.Warn("Constraint {0} already exists", name); return; } primaryTable = QuoteTableNameIfRequired(primaryTable); refTable = QuoteTableNameIfRequired(refTable); string primaryColumnsSql = String.Join(",", primaryColumns.Select(col => QuoteColumnNameIfRequired(col)).ToArray()); string refColumnsSql = String.Join(",", refColumns.Select(col => QuoteColumnNameIfRequired(col)).ToArray()); ExecuteNonQuery(String.Format("ALTER TABLE {0} ADD CONSTRAINT {1} FOREIGN KEY ({2}) REFERENCES {3} ({4})", primaryTable, name, primaryColumnsSql, refTable, refColumnsSql)); }
public string SqlForConstraint(ForeignKeyConstraintType constraint) { switch (constraint) { case ForeignKeyConstraintType.Cascade: return("CASCADE"); case ForeignKeyConstraintType.Restrict: return("RESTRICT"); case ForeignKeyConstraintType.SetDefault: return("SET DEFAULT"); case ForeignKeyConstraintType.SetNull: return("SET NULL"); default: return("NO ACTION"); } }
public SchemaBuilder WithConstraint(ForeignKeyConstraintType action) { _currentColumn.Constraint = action; return this; }
public override void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable, string[] refColumns, ForeignKeyConstraintType constraint) { // NOOP Because SQLite doesn't support foreign keys }
public void GenerateForeignKey(string primaryTable, string refTable, ForeignKeyConstraintType constraint) { // No Op }
public void AddForeignKey(string name, string primaryTable, string[] primaryColumns, string refTable, string[] refColumns, ForeignKeyConstraintType constraint) { // No Op }
public SchemaBuilder WithConstraint(ForeignKeyConstraintType action) { _currentColumn.Constraint = action; return(this); }