public override void Connect(string connectionString) { if (State != DatabaseConnectionState.Disconnected) { throw new InvalidOperationException($"Cannot connect when in state {State}"); } try { State = DatabaseConnectionState.Connecting; SqlConnection = new SqlConnection(connectionString); SqlConnection.Open(); ConnectionString = connectionString; State = DatabaseConnectionState.Connected; SqlServerDatabaseSystem = new SqlServerDatabaseSystem(this); } catch /*(Exception ex)*/ { State = DatabaseConnectionState.Disconnected; throw; // TODO: Throw library-specific exception and set the InnerException to ex } }
public override void Disconnect() { if (State == DatabaseConnectionState.Disconnected) { throw new InvalidOperationException($"Cannot disconnect when in state {State}"); } SqlConnection.Close(); State = DatabaseConnectionState.Disconnected; SqlServerDatabaseSystem = null; }
public SqlServerDatabase(SqlServerDatabaseSystem databaseSystem, string name) { DatabaseSystem = databaseSystem; Name = name; }