/// <summary> /// Translates this table into a SQL script /// </summary> /// <returns></returns> public string Script() { var text = new StringBuilder(); text.AppendFormat("CREATE TABLE [{0}].[{1}](\r\n", Owner, Name); text.Append(Columns.Script()); if (Constraints.Count > 0) { text.AppendLine(); } //add anything that is not an index foreach (var c in Constraints.Where(c => c.Type != ConstraintType.Index)) { text.AppendLine(" ," + c.Script()); } text.AppendLine(")"); text.AppendLine(); //add indexes foreach (var c in Constraints.Where(c => c.Type == ConstraintType.Index)) { text.AppendLine(c.Script()); } return(text.ToString()); }
public void Script() { var test = new Columns(); test.Add(new Column("testing", ColumnTypes.Bigint, true, null)); Assert.Contains("testing", test.Script()); }