private void ConfigureForeignKeyWithCascadingDeletes(CascadeAction onDelete) { StoreOptions(options => { options.Schema.For <Issue>().ForeignKey <User>(x => x.AssigneeId, fkd => fkd.OnDelete = onDelete); }); }
public ColumnExpression ForeignKeyTo(string referencedTableName, string referencedColumnName, string fkName = null, CascadeAction onDelete = CascadeAction.NoAction, CascadeAction onUpdate = CascadeAction.NoAction) { return(ForeignKeyTo(DbObjectName.Parse(SqlServerProvider.Instance, referencedTableName), referencedColumnName, fkName, onDelete, onUpdate)); }
private void ConfigureForeignKeyWithCascadingDeletes(CascadeAction onDelete) { StoreOptions(options => { options.Schema.For <Issue>().ForeignKey <User>(x => x.AssigneeId, fkd => fkd.OnDelete = onDelete); }); theStore.Tenancy.Default.EnsureStorageExists(typeof(User)); }
public void read_on_delete_and_on_update(string definition, CascadeAction onDelete, CascadeAction onUpdate) { var fk = new ForeignKey("fk_people_state_id") { }; fk.Parse(definition); fk.OnDelete.ShouldBe(onDelete); fk.OnUpdate.ShouldBe(onUpdate); }
public ColumnExpression ForeignKeyTo(DbObjectName referencedIdentifier, string referencedColumnName, string fkName = null, CascadeAction onDelete = CascadeAction.NoAction, CascadeAction onUpdate = CascadeAction.NoAction) { var fk = new ForeignKey(fkName ?? _parent.Identifier.ToIndexName("fkey", Column.Name)) { LinkedTable = referencedIdentifier, ColumnNames = new[] { Column.Name }, LinkedNames = new[] { referencedColumnName }, OnDelete = onDelete, OnUpdate = onUpdate }; _parent.ForeignKeys.Add(fk); return(this); }
public static void WriteCascadeAction(this TextWriter writer, string prefix, CascadeAction action) { switch (action) { case CascadeAction.Cascade: writer.WriteLine($"{prefix} CASCADE"); break; case CascadeAction.NoAction: return; case CascadeAction.SetDefault: writer.WriteLine($"{prefix} SET DEFAULT"); break; case CascadeAction.SetNull: writer.WriteLine($"{prefix} SET NULL"); break; } }
public static string DropStatementFor(string schemaName, CascadeAction option = CascadeAction.Cascade) { return($"drop schema if exists {schemaName} {option.ToString().ToUpperInvariant()};"); }
public ColumnExpression ForeignKeyTo(Table referencedTable, string referencedColumnName, string fkName = null, CascadeAction onDelete = CascadeAction.NoAction, CascadeAction onUpdate = CascadeAction.NoAction) { return(ForeignKeyTo(referencedTable.Identifier, referencedColumnName, fkName, onDelete, onUpdate)); }