Exemplo n.º 1
0
        public void Model_GenerateCreateTableSql_temp_table()
        {
            var temp = new TempModel();

            temp.AddTempTableIdentity();
            var sqlBuilder = new IndentedStringBuilder();

            temp.GenerateCreateTableSql("#Temp", null, sqlBuilder, SqlVersion.Sql13, true);
            var expectedSql =
                @"CREATE TABLE [#Temp] (
    [Id] INT NOT NULL,
    [Name] NVARCHAR(4000) NULL DEFAULT(N'DEFAULT NAME'),
    [Unique1] INT NULL,
    [Unique2] INT NULL,
    [sys_row_id] INT NOT NULL IDENTITY(1, 1)

    CONSTRAINT [PK_Temp_] PRIMARY KEY NONCLUSTERED ([Id]),
    CONSTRAINT [UQ_Temp_] UNIQUE NONCLUSTERED ([Unique1], [Unique2] DESC),
    CONSTRAINT [CK_Temp_] CHECK ([Name] IS NOT NULL),
    UNIQUE CLUSTERED ([sys_row_id] ASC)
);
";

            Assert.AreEqual(expectedSql, sqlBuilder.ToString().RemoveGuids());
        }