public override void Write(ForeignKeyConstraint key)
 {
     if (key.OnDelete != ForeignKeyRelationCascade.Cascade && key.OnDelete != ForeignKeyRelationCascade.NoAction)
         return;
     if (key.OnUpdate != ForeignKeyRelationCascade.Cascade && key.OnUpdate != ForeignKeyRelationCascade.NoAction)
         return;
     base.Write(key);
 }
Exemple #2
0
        public ConstraintDefinition AddForeignKey(string columnNames, string parentTable, string parentColumns,
                                                  ForeignKeyRelationCascade onUpdate =
                                                  ForeignKeyRelationCascade.NoAction,
                                                  ForeignKeyRelationCascade onDelete =
                                                  ForeignKeyRelationCascade.NoAction, string keyName = null)
        {
            columnNames.MustNotBeEmpty();
            parentTable.MustNotBeEmpty();
            parentColumns.MustNotBeEmpty();
            var fk = new ForeignKeyConstraint
            {
                Columns      = columnNames,
                ParentTable  = parentTable,
                Name         = keyName ?? GenerateForeignKeyName(columnNames, parentTable, parentColumns),
                ParentColumn = parentColumns,
                OnUpdate     = onUpdate,
                OnDelete     = onDelete
            };

            ForeignKeys.Add(fk);
            return(fk);
        }
 public virtual void Write(ForeignKeyConstraint key)
 {
     base.Write(key);
     WriteParentReference();
     WriteRestrictions();
 }
 public ConstraintDefinition AddForeignKey(string columnNames, string parentTable, string parentColumns,
                                           ForeignKeyRelationCascade onUpdate =
                                               ForeignKeyRelationCascade.NoAction,
                                           ForeignKeyRelationCascade onDelete =
                                               ForeignKeyRelationCascade.NoAction, string keyName = null)
 {
     columnNames.MustNotBeEmpty();
     parentTable.MustNotBeEmpty();
     parentColumns.MustNotBeEmpty();
     var fk = new ForeignKeyConstraint
         {
             Columns = columnNames,
             ParentTable = parentTable,
             Name = keyName ?? GenerateForeignKeyName(columnNames, parentTable, parentColumns),
             ParentColumn = parentColumns,
             OnUpdate = onUpdate,
             OnDelete = onDelete
         };
     ForeignKeys.Add(fk);
     return fk;
 }