コード例 #1
0
        public override void AppendTo(StringBuilder sb, ISqlDialect dialect)
        {
            sb.Append("CREATE");
            if (Temp)
            {
                sb.Append(" TEMP");
            }
            sb.Append(" TABLE ");
            if (IfNotExists)
            {
                sb.Append("IF NOT EXISTS ");
            }
            if (!string.IsNullOrEmpty(SchemaName))
            {
                sb.Append(SchemaName).Append(".");
            }
            sb.Append(TableName);

            if (SelectStatment != null)
            {
                sb.Append(" AS ");
                SelectStatment.AppendTo(sb, dialect);
            }
            else
            {
                sb.Append(" (");
                bool first = true;
                foreach (var col in Columns)
                {
                    if (!first)
                    {
                        sb.Append(", ");
                    }
                    else
                    {
                        first = false;
                    }
                    sb.Append(dialect.GetColumnDefinition(col));
                }

                if (TableConstraints != null)
                {
                    foreach (var constr in TableConstraints)
                    {
                        if (!first)
                        {
                            sb.Append(", ");
                        }
                        else
                        {
                            first = false;
                        }
                        constr.AppendTo(sb, dialect);
                    }
                }

                sb.Append(")");

                if (WithoutRowid)
                {
                    sb.Append(" WITHOUT ROWID");
                }
            }
        }