Script() public method

Translates this list of columns into SQL script.
public Script ( ) : string
return string
示例#1
0
        /// <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());
        }
示例#2
0
 public void Script()
 {
     var test = new Columns();
     test.Add(new Column("testing", ColumnTypes.Bigint, true, null));
     Assert.Contains("testing", test.Script());
 }