public void Setup() { t = new Table("items"); t.AddColumn("id", "integer", true, true, true); t.AddColumn("name"); t.AddColumn("description"); t.AddColumn("price", "double"); }
public void Setup() { t = new Table("users"); t.AddColumn("id", "integer", true, true, true); t.AddColumn("name"); t.AddColumn("password"); f = new MySQLMigrationFormatter(""); }
public string GetCreateTable(Table table) { string cols = ""; int i = 0; foreach (var c in table.Columns) { string notNull = c.NotNull ? " not null" : ""; string primaryKey = c.PrimaryKey ? " primary key" : ""; cols += string.Format(" {0} {1}{2}{3}", c.Name, c.Type, notNull, primaryKey); cols += i++ < table.Columns.Count - 1 ? "," : ""; cols += Environment.NewLine; } return string.Format(@"create table {0}({1});", table.Name, cols); }
public string GetCreateTable(Table table) { string cols = ""; int i = 0; foreach (var c in table.Columns) { cols += c.Name + " " + c.Type; cols += c.PrimaryKey ? " primary key" : ""; cols += c.NotNull ? " not null" : ""; cols += c.AutoIncrement ? " identity" : ""; cols += i++ < table.Columns.Count - 1 ? ", " : ""; } return string.Format("create table {0}({1})", table.Name, cols); }
public TableEventArgs(Table table, ICollection<KeyValuePair<string, object>> values, ICollection<KeyValuePair<string, object>> @where) { this.Table = table; this.Values = values; this.Where = @where; }
public TableEventArgs(Table table, ICollection<KeyValuePair<string, object>> values) { this.Table = table; this.Values = values; }
public TableEventArgs(Table table) { this.Table = table; }
public void CreateTable(Table table) { ExecuteNonQuery(f.GetCreateTable(table)); }
public void RemoveColumn(string tableName, params string[] columns) { string cols = ""; int i = 1; foreach (var c in columns) { cols += c; if (i++ < columns.Length) { cols += ", "; } } OnMigrating(new MigrationEventArgs(string.Format("Removing {0} from {1}...", cols, tableName))); var t = new Table(tableName); foreach (var c in columns) { t.AddColumn(c); } OnColumnRemove(new TableEventArgs(t)); }
protected void CreateTable(Table table) { OnMigrating(new MigrationEventArgs(string.Format("Creating table {0}...", table.Name))); OnTableCreate(new TableEventArgs(table)); }