Create() 공개 메소드

Creates the database in the context given, granting the administrative control to the user identified by the given name and token.

The properties used to create the database are extracted from the underlying context (DatabaseContext).

This method does not automatically open the database: to make it accessible a call to Open is required.

/// If the database context is configured to be in read-only model, if it was not possible /// to commit the initial information or if another unhanded error occurred while /// creating the database. /// /// If either one of or /// are null or empty. ///
public Create ( string adminName, string identification, string token ) : void
adminName string The name of the administrator.
identification string The name of the mechanism used to identify the user by the /// given token.
token string The toke used to identify the administrator, using the /// mechanism given.
리턴 void
예제 #1
0
        protected virtual IDatabase CreateDatabase(IDatabaseContext context)
        {
            var database = new Database(context);
            database.Create(AdminUserName, AdminPassword);
            database.Open();

            return database;
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
        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;
            }
        }