Ejemplo n.º 1
0
        /// <summary>
        /// Create a database
        /// </summary>
        /// <param name="dbInfo">DbDriverInfo</param>
        public void CreatePhysicalDatabase(DbDriverInfo dbInfo)
        {
            MongoDBConnectionStringBuilder masterBuilder = new MongoDBConnectionStringBuilder(dbInfo.DBCnnStringBuilder.ToString());
            MongoDBConnectionStringBuilder tempBuilder   = new MongoDBConnectionStringBuilder(dbInfo.DBCnnStringBuilder.ToString());

            //tempBuilder = dbInfo.DBCnnStringBuilder as MongoDBConnectionStringBuilder;
            //The "test" database is installed by default with MongoDB.  System needs to login to this database to create a new database.
            tempBuilder.Database = "information_schema";

            MongoDBConnection masterConnection = new MongoDBConnection(tempBuilder.ToString());

            try
            {
                MongoDBCommand command = masterConnection.CreateCommand() as MongoDBCommand;
                if (dbInfo.DBName != null)
                {
                    command.CommandText = "create database " + dbInfo.DBName + ";";
                }

                masterConnection.Open();
                //Logger.Log(command.CommandText);
                command.ExecuteNonQuery();

                //reset database to new database for correct storage of meta tables
                tempBuilder.Database = dbInfo.DBName;
            }
            catch (Exception ex)
            {
                throw new System.ApplicationException("Could not create new MongoDB Database", ex);//(Epi.SharedStrings.CAN_NOT_CREATE_NEW_MYSQL, ex);
            }
            finally
            {
                masterConnection.Close();
            }
        }
Ejemplo n.º 2
0
 public MongoDBCommand(MongoDBCommand cmd)
 {
 }
 public MongoDBDataAdapter(MongoDBCommand command)
 {
 }