public void DropDatabase( string name, CancellationToken cancellationToken = default) { if (TryGetSession(out IClientSessionHandle? session)) { _client.DropDatabase(session, name, cancellationToken); return; } _client.DropDatabase(name, cancellationToken); }
public void DropDB(string dbName) { if (mClient != null) { mClient.DropDatabase(dbName); } }
/// <summary> /// Drops a given database from the server. /// </summary> /// <param name="client">The Mongo connection client.</param> /// <param name="databaseName">The name of the database to drop.</param> public static void DropDatabase(IMongoClient client, string databaseName) { Log.DebugFormat("Dropping database '{0}'..", databaseName); client.DropDatabase(databaseName); if (DatabaseExists(client, databaseName)) { throw new MongoException(String.Format("Failed to drop database '{0}'! Issued drop database command but data still exists.", databaseName)); } }
public DbEngine() { _client = new MongoClient(); _client.DropDatabase(DB_NAME); _database = _client.GetDatabase(DB_NAME); tankMeasuresCollection = _database.GetCollection <BsonDocument>(TANK_MEASURES_NAME); nozzleMeasuresCollection = _database.GetCollection <BsonDocument>(NOZZLE_MEASURES_NAME); refuelsCollection = _database.GetCollection <BsonDocument>(REFUELS_NAME); }
public bool DeleteDatabase(string dbName) { try { _client.DropDatabase(dbName); } catch (Exception) { return(false); } return(true); }
protected virtual void Dispose(bool disposing) { if (disposed) { return; } if (disposing) { client.DropDatabase(databaseName); } disposed = true; }
public static bool DeleteDatabase() { try { client.DropDatabase("BsonDemo"); } catch (Exception) { return(false); } return(true); }
public RepositoryTests() { _runner = MongoDbRunner.StartForDebugging(); _client = new MongoClient(_runner.ConnectionString); _client.DropDatabase(_dbname); _database = _client.GetDatabase(_dbname); _repo = new Repository <Person>(_database); _persons = new Faker <Person>() .CustomInstantiator(f => { return(new Person { Name = f.Person.FullName, Email = f.Person.Email, Points = f.Random.Int(0, 10000) }); }); }
public static void EnsureReplicationSetReady(this IMongoClient mongoClient) { var delay = InitialDelay; var database = mongoClient.GetDatabase("__dummy-db"); try { while (true) { try { _ = database.GetCollection <DummyEntry>("__dummy"); database.DropCollection("__dummy"); var session = mongoClient.StartSession(); try { session.StartTransaction(); session.AbortTransaction(); } finally { session.Dispose(); } break; } catch (NotSupportedException) { } Thread.Sleep(delay); delay = Min(Double(delay), MaxDelay); } } finally { mongoClient.DropDatabase("__dummy-db"); } }
/// <summary> /// Permanently deletes (drops) the database with all records /// in it without the possibility to recover them later. /// /// This method should only be used to free storage. For /// all other purposes, methods that preserve history should /// be used. /// /// ATTENTION - THIS METHOD WILL DELETE ALL DATA WITHOUT /// THE POSSIBILITY OF RECOVERY. USE WITH CAUTION. /// </summary> public override void DeleteDb() { if (ReadOnly != null && ReadOnly.Value) { throw new Exception( $"Attempting to drop (delete) database for the data source {DataSourceName} where ReadOnly flag is set."); } // Do not delete (drop) the database this class did not create if (client_ != null && Db != null) { // As an extra safety measure, this method will delete // the database only if the first token of its name is // TEST or DEV. // // Use other tokens such as UAT or PROD to protect the // database from accidental deletion if (envType_ == EnvType.Dev || envType_ == EnvType.User || envType_ == EnvType.Test) { // The name is the database key in the standard // semicolon delimited format. However this method // performs additional validation for restricted // characters and database name length. client_.DropDatabase(dbName_); } else { throw new Exception( $"As an extra safety measure, database {dbName_} cannot be " + $"dropped because this operation is not permitted for database " + $"environment type {envType_.ToString().ToUpper()}."); } } }
public void GlobalCleanup() { _client.DropDatabase(_databaseName); }
public void Dispose() { _mongoClient.DropDatabase(_databaseName); }
public void RunCleanup() { mongoClient.DropDatabase(mongoDatabase.DatabaseNamespace.DatabaseName); }
public void Initialize() { _client.DropDatabase(DbName); }
/// <summary> /// Drop the existing database /// </summary> /// <param name="name"></param> protected void DropDatabase(string name) { _client.DropDatabase(name); }
public void DropDatabase(string databaseName) { _client.DropDatabase(databaseName); }
public void RunCleanup() { mongoClient.DropDatabase(mongoDatabase.DatabaseNamespace.DatabaseName); eventConsumerActor.Dispose(); }
public void Cleanup() { mongoClient.DropDatabase("EventStoreTest"); }
public void Dispose() { client.DropDatabase(testDBName); }
public void Dispose() { mongoClient.DropDatabase("EventStoreTest"); }
public void DropDatabase() { _mongoClient.DropDatabase(_mongoDbConfigurations.Database); }
public void FixtureTeardown() { _client.DropDatabase("workflows"); }
/// <inheritdoc /> public virtual void DropDatabase() => _mongoClient.DropDatabase(new MongoDbModelAnnotations(_model).Database);
private void Disconnect() { Client?.DropDatabase(ConnectionSettings.MongoDBName); }
public void DropDatabase(string name, CancellationToken cancellationToken = default(CancellationToken)) { wrapped.DropDatabase(name, cancellationToken); }
public void TearDown() { _client.DropDatabase(DatabaseName); }
public void RunCleanup() { mongoClient.DropDatabase(mongoDatabase.DatabaseNamespace.DatabaseName); eventReceiver.Dispose(); }
public void SetUp() { _client.DropDatabase(database); }
public void AfterTest() { Database.DropCollection("users"); Database.DropCollection("roles"); Client.DropDatabase("identity-testing"); }
public void Dispose() { mongoClient.DropDatabase("GridFSTest"); }