public void CreateSimpleTableAsAdmin() { var tableName = ObjectName.Parse("APP.test_table"); var tableInfo = new TableInfo(tableName); tableInfo.AddColumn("a", PrimitiveTypes.Integer(), true); tableInfo.AddColumn("b", PrimitiveTypes.String()); using (var session = Database.CreateUserSession(AdminUserName, AdminPassword)) { using (var context = new SessionQueryContext(session)) { Assert.DoesNotThrow(() => { context.CreateTable(tableInfo); }); } Assert.DoesNotThrow(() => session.Commit()); } using (var session = Database.CreateUserSession(AdminUserName, AdminPassword)) { using (var context = new SessionQueryContext(session)) { bool exists = false; Assert.DoesNotThrow(() => exists = context.TableExists(tableName)); Assert.IsTrue(exists); } } }
protected override IQueryContext CreateQueryContext(IDatabase database) { // We first create the table in another context... using (var session = database.CreateUserSession(AdminUserName, AdminPassword)) { using (var context = new SessionQueryContext(session)) { var tableInfo = new TableInfo(ObjectName.Parse("APP.test_table")); tableInfo.AddColumn("a", PrimitiveTypes.Integer()); tableInfo.AddColumn("b", PrimitiveTypes.String(), false); context.CreateTable(tableInfo, false, false); } session.Commit(); } return base.CreateQueryContext(database); }