コード例 #1
0
        protected override string GetSql()
        {
            var table = new TableDefinition {
                Name = TableName, SchemaName = SchemaName, Columns = Columns
            };

            return(string.Format(SqlSyntax.Format(table)));
        }
コード例 #2
0
        public override string ToString()
        {
            var table = new TableDefinition {
                Name = TableName, SchemaName = SchemaName, Columns = Columns
            };

            return(string.Format(SqlSyntax.Format(table)));
        }
コード例 #3
0
        public override string ToString()
        {
            if (IsExpressionSupported() == false)
            {
                return(string.Empty);
            }

            return(SqlSyntax.Format(ForeignKey));
        }
コード例 #4
0
        protected void AlterColumn <T>(string tableName, string columnName)
        {
            var table  = DefinitionFactory.GetTableDefinition(typeof(T), SqlSyntax);
            var column = table.Columns.First(x => x.Name == columnName);

            SqlSyntax.Format(column, SqlSyntax.GetQuotedTableName(tableName), out var sqls);
            foreach (var sql in sqls)
            {
                Execute.Sql(sql).Do();
            }
        }
コード例 #5
0
        protected override string GetSql()
        {
            if (string.IsNullOrEmpty(Column.TableName))
            {
                Column.TableName = TableName;
            }

            return(string.Format(SqlSyntax.AddColumn,
                                 SqlSyntax.GetQuotedTableName(Column.TableName),
                                 SqlSyntax.Format(Column)));
        }
コード例 #6
0
        private void AddColumn(TableDefinition table, string tableName, string columnName)
        {
            if (ColumnExists(tableName, columnName))
            {
                return;
            }

            var column    = table.Columns.First(x => x.Name == columnName);
            var createSql = SqlSyntax.Format(column);

            Execute.Sql(string.Format(SqlSyntax.AddColumn, SqlSyntax.GetQuotedTableName(tableName), createSql)).Do();
        }
コード例 #7
0
        private void AddColumn(TableDefinition table, string tableName, string columnName, out IEnumerable <string> sqls)
        {
            if (ColumnExists(tableName, columnName))
            {
                sqls = Enumerable.Empty <string>();
                return;
            }

            var column    = table.Columns.First(x => x.Name == columnName);
            var createSql = SqlSyntax.Format(column, SqlSyntax.GetQuotedTableName(tableName), out sqls);

            Execute.Sql(string.Format(SqlSyntax.AddColumn, SqlSyntax.GetQuotedTableName(tableName), createSql)).Do();
        }
コード例 #8
0
            public override void Migrate()
            {
                // cannot delete the column without this, of course
                Delete.KeysAndIndexes().Do();

                Delete.Column("id").FromTable("umbracoUser").Do();

                var table  = DefinitionFactory.GetTableDefinition(typeof(UserDto), SqlSyntax);
                var column = table.Columns.First(x => x.Name == "id");
                var create = SqlSyntax.Format(column); // returns [id] INTEGER NOT NULL IDENTITY(1060,1)

                Database.Execute($"ALTER TABLE {SqlSyntax.GetQuotedTableName("umbracoUser")} ADD " + create);
            }
コード例 #9
0
        public override string ToString()
        {
            //string columnNameFormat = string.Format("{0} {1}",
            //    SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(Column.Name),
            //    SqlSyntaxContext.SqlSyntaxProvider.Format(Column));

            return(string.Format(SqlSyntax.AlterColumn,
                                 SqlSyntax.GetQuotedTableName(TableName),
                                 SqlSyntax.Format(Column)));

            //return string.Format(SqlSyntaxContext.SqlSyntaxProvider.AlterColumn,
            //                     SqlSyntaxContext.SqlSyntaxProvider.GetQuotedTableName(TableName),
            //                     SqlSyntaxContext.SqlSyntaxProvider.GetQuotedColumnName(Column.Name));
        }
コード例 #10
0
        public override string ToString()
        {
            if (IsExpressionSupported() == false)
            {
                return(string.Empty);
            }

            if (string.IsNullOrEmpty(Column.TableName))
            {
                Column.TableName = TableName;
            }

            return(string.Format(SqlSyntax.AddColumn,
                                 SqlSyntax.GetQuotedTableName(Column.TableName),
                                 SqlSyntax.Format(Column)));
        }
コード例 #11
0
 protected override string GetSql()
 {
     return(SqlSyntax.Format(Index));
 }
コード例 #12
0
 protected override string GetSql()
 {
     return(string.Format(SqlSyntax.AlterColumn,
                          SqlSyntax.GetQuotedTableName(TableName),
                          SqlSyntax.Format(Column)));
 }
コード例 #13
0
 public override string ToString()
 {
     return(SqlSyntax.Format(Index));
 }
コード例 #14
0
 protected override string GetSql()
 {
     return(SqlSyntax.Format(ForeignKey));
 }