コード例 #1
0
ファイル: MigrationTests.cs プロジェクト: vogong/SubSonic-2.0
        public void MigrationOnDispose()
        {
            //testing Rob's super-cool migration on dispose pattern
            using (Migration m = new Migration("Northwind"))
            {
                TableSchema.Table t = m.CreateTable("DisposeTable");
                t.AddPrimaryKeyColumn();
                t.AddColumn("Name", DbType.String);
                m.AddSubSonicStateColumns(t);
            }

            DataService.ClearSchemaCache("Northwind");
            TableSchema.Table table = DataService.GetSchema("DisposeTable", "Northwind");
            Assert.IsNotNull(table);
        }
コード例 #2
0
ファイル: MigrationTests.cs プロジェクト: vogong/SubSonic-2.0
        public void CreateTable_Should_Allow_Char3_As_PrimaryKey()
        {
            new InlineQuery("Northwind").Execute("IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTb]') AND type in (N'U')) \r\n DROP TABLE [dbo].[MyTb]");


            using (Migration m = new Migration("Northwind")) {
                TableSchema.Table       tb  = m.CreateTable("MyTb");
                TableSchema.TableColumn col = new TableSchema.TableColumn(tb);
                col.ColumnName   = "Id";
                col.DataType     = System.Data.DbType.AnsiStringFixedLength;
                col.MaxLength    = 3;
                col.IsPrimaryKey = true;
                tb.AddColumn(col);
            }


            //pull the table out
            DataService.ClearSchemaCache("Northwind");
            TableSchema.Table table = DataService.GetSchema("MyTb", "Northwind");

            Assert.IsNotNull(table);
            Assert.AreEqual(3, table.PrimaryKey.MaxLength);
        }
コード例 #3
0
        public void CreateTable_Should_Allow_Char3_As_PrimaryKey() {

            new InlineQuery("Northwind").Execute("IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[MyTb]') AND type in (N'U')) \r\n DROP TABLE [dbo].[MyTb]");


            using (Migration m = new Migration("Northwind")) {
                TableSchema.Table tb = m.CreateTable("MyTb");
                TableSchema.TableColumn col = new TableSchema.TableColumn(tb);
                col.ColumnName = "Id";
                col.DataType = System.Data.DbType.AnsiStringFixedLength;
                col.MaxLength = 3;
                col.IsPrimaryKey = true;
                tb.AddColumn(col);
            }


            //pull the table out
            DataService.ClearSchemaCache("Northwind");
            TableSchema.Table table = DataService.GetSchema("MyTb", "Northwind");

            Assert.IsNotNull(table);
            Assert.AreEqual(3, table.PrimaryKey.MaxLength);
        }
コード例 #4
0
        public void MigrationOnDispose()
        {
            //testing Rob's super-cool migration on dispose pattern
            using(Migration m = new Migration("Northwind"))
            {
                TableSchema.Table t = m.CreateTable("DisposeTable");
                t.AddPrimaryKeyColumn();
                t.AddColumn("Name", DbType.String);
                m.AddSubSonicStateColumns(t);
            }

            DataService.ClearSchemaCache("Northwind");
            TableSchema.Table table = DataService.GetSchema("DisposeTable", "Northwind");
            Assert.IsNotNull(table);
        }