diff --git a/EvitaDB.Client/EvitaClient.cs b/EvitaDB.Client/EvitaClient.cs index b32929e..d8eb420 100644 --- a/EvitaDB.Client/EvitaClient.cs +++ b/EvitaDB.Client/EvitaClient.cs @@ -279,6 +279,18 @@ public bool DeleteCatalogIfExists(string catalogName) { AssertActive(); + // first close and remove all active sessions to particular catalog + List activeCatalogSessions = _activeSessions.Values + .Where(x => x.CatalogName == catalogName) + .ToList(); + + foreach (var session in activeCatalogSessions) + { + session.Close(); + _activeSessions.Remove(session.SessionId, out _); + } + + // then delete it GrpcDeleteCatalogIfExistsRequest request = new GrpcDeleteCatalogIfExistsRequest { CatalogName = catalogName }; GrpcDeleteCatalogIfExistsResponse grpcResponse = ExecuteWithBlockingEvitaService(evitaService => evitaService.DeleteCatalogIfExists(request));