예제 #1
0
        public void Test2()
        {
            var ab = new AlterTableStatementBuilder(new FromClause("User"), false)
            {
                AddColumn = new ColumnInfo("Nick", typeof(string), false, false, true, true, 50, 0, null),
            };
            var sql = ab.ToSqlStatement(new SqlServer2005(), null);

            Assert.AreEqual("ALTER TABLE [User] ADD [Nick] NVARCHAR (50) NULL;", sql.SqlCommandText);
        }
예제 #2
0
        public void Test1()
        {
            var ab = new AlterTableStatementBuilder(new FromClause("User"), false)
            {
                AddColumn    = new ColumnInfo("Age", typeof(int), false, false, false, false, 0, 0, null),
                DefaultValue = 0,
            };
            var sql = ab.ToSqlStatement(new SqlServer2005(), null);

            Assert.AreEqual("ALTER TABLE [User] ADD [Age] INT NOT NULL DEFAULT(0);", sql.SqlCommandText);
        }
예제 #3
0
        protected static void InnerGetValue(ModelContext ctx, string columnName, object o, bool defaultFirst)
        {
            var builder = new AlterTableStatementBuilder(ctx.Info.From, defaultFirst);
            var mem     = ctx.Info.Members.FirstOrDefault(p => p.Name == columnName);

            builder.AddColumn = new ColumnInfo(mem);
            if (o != null)
            {
                builder.DefaultValue = o;
            }
            var sql = builder.ToSqlStatement(ctx);

            ctx.Provider.ExecuteNonQuery(sql);
        }