private string GenerateSqlStatementConcrete(AlterColumnOperation migrationOperation)
        {
            JetDdlBuilder ddlBuilder = new JetDdlBuilder();

            ddlBuilder.AppendSql("ALTER TABLE ");
            ddlBuilder.AppendIdentifier(migrationOperation.Table);
            ddlBuilder.AppendSql(" ALTER COLUMN ");

            ColumnModel column = migrationOperation.Column;

            ddlBuilder.AppendIdentifier(column.Name);
            ddlBuilder.AppendSql(" ");
            TypeUsage storeType = JetProviderManifest.Instance.GetStoreType(column.TypeUsage);

            ddlBuilder.AppendType(storeType, column.IsNullable ?? true, column.IsIdentity, column.DefaultValueSql);
            ddlBuilder.AppendNewLine();


            return(ddlBuilder.GetCommandText());
        }
Esempio n. 2
0
        private string GenerateSqlStatementConcrete(CreateTableOperation migrationOperation)
        {
            JetDdlBuilder ddlBuilder = new JetDdlBuilder();

            ddlBuilder.AppendSql("CREATE TABLE ");
            ddlBuilder.AppendIdentifier(migrationOperation.Name);
            ddlBuilder.AppendSql(" (");
            ddlBuilder.AppendNewLine();

            bool first = true;

            foreach (ColumnModel column in migrationOperation.Columns)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    ddlBuilder.AppendSql(",");
                }

                ddlBuilder.AppendSql(" ");
                ddlBuilder.AppendIdentifier(column.Name);
                ddlBuilder.AppendSql(" ");
                TypeUsage storeTypeUsage = ProviderManifest.GetStoreType(column.TypeUsage);
                ddlBuilder.AppendType(storeTypeUsage, column.IsNullable ?? true, column.IsIdentity);
                ddlBuilder.AppendNewLine();
            }

            ddlBuilder.AppendSql(")");

            if (migrationOperation.PrimaryKey != null)
            {
                ddlBuilder.AppendSql(BATCHTERMINATOR);
                ddlBuilder.AppendSql(GenerateSqlStatementConcrete(migrationOperation.PrimaryKey));
            }

            return(ddlBuilder.GetCommandText());
        }