コード例 #1
0
        private static void DropAndCreateDb()
        {
            var master = new SqlDbApi(ConnStringMaster);

            master.ExecuteNonQuery(
                "if exists (select * from sys.databases where name='" + DbName + "') " +
                "drop database " + DbName + "; " +
                "create database " + DbName + ";");
        }
コード例 #2
0
        public void OneTimeSetup()
        {
            _testData = new DataTable();
            _testData.Columns.Add(new DataColumn {
                ColumnName = "id", AutoIncrement = true, AllowDBNull = false, DataType = typeof(int), Unique = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "otherId", DataType = typeof(Guid), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "myBit", DataType = typeof(bool), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "myBigInt", DataType = typeof(long), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "myTinyInt", DataType = typeof(byte), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "mySmallInt", DataType = typeof(short), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "myNullableInt", DataType = typeof(short), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "myFloat", DataType = typeof(float), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "myNvarchar", DataType = typeof(string), AllowDBNull = true
            });
            _testData.Columns.Add(new DataColumn {
                ColumnName = "myDateTime", DataType = typeof(DateTime), AllowDBNull = true, DefaultValue = DateTime.Now
            });

            for (var i = 0; i < 1; i++)
            {
                var row = _testData.NewRow();
                row["otherId"]       = Guid.NewGuid();
                row["myBit"]         = i % 2 == 0;
                row["myBigInt"]      = (long)i;
                row["myTinyInt"]     = (byte)i;
                row["mySmallInt"]    = (short)i;
                row["myNullableInt"] = DBNull.Value;
                row["myFloat"]       = (float)i;
                row["myNvarchar"]    = i.ToString();
                _testData.Rows.Add(row);
            }

            TestDb.ExecuteNonQuery(Config.CreateTestTablesCmd);
        }