This method ensures the system components and the data are ready to allow any connection to be established.
After this method successfully exists, the state of IsOpen is changed to true.
true
protected virtual IDatabase CreateDatabase(IDatabaseContext context) { var database = new Database(context); database.Create(AdminUserName, AdminPassword); database.Open(); return database; }
public void TestSetup() { testSequenceName = ObjectName.Parse("APP.test_sequence"); var dbConfig = Configuration.Configuration.Empty; dbConfig.SetValue(DatabaseConfigKeys.DatabaseName, "testdb"); var systemContext = new SystemContext(Configuration.Configuration.SystemDefault); var dbContext = new DatabaseContext(systemContext, dbConfig); var database = new Database(dbContext); database.Create("SA", "12345"); database.Open(); transaction = database.CreateTransaction(TransactionIsolation.Serializable); if (TestContext.CurrentContext.Test.Name != "CreateNormalSequence") { var seqInfo = new SequenceInfo(testSequenceName, new SqlNumber(0), new SqlNumber(1), new SqlNumber(0), new SqlNumber(Int64.MaxValue), 126); transaction.CreateSequence(seqInfo); } }
public IDatabase CreateDatabase(IConfiguration configuration, string adminUser, string identification, string token) { lock (this) { if (configuration == null) throw new ArgumentNullException("configuration"); var databaseName = configuration.GetString("database.name"); if (String.IsNullOrEmpty(databaseName)) throw new ArgumentException("The configuration must specify a database name."); if (DatabaseExists(databaseName)) throw new InvalidOperationException(String.Format("Database '{0}' already exists in the system.", databaseName)); var dbContext = Context.CreateDatabaseContext(configuration); var database = new Database(this, dbContext); if (database.Exists) throw new InvalidOperationException(String.Format("The database '{0}' was already created.", databaseName)); database.Create(adminUser, identification, token); database.Open(); if (databases == null) databases = new Dictionary<string, Database>(); databases[databaseName] = database; return database; } }