Index: Riskeer/HydraRing/src/Riskeer.HydraRing.IO/HydraulicLocationConfigurationDatabase/HydraulicLocationConfigurationDatabaseReader.cs =================================================================== diff -u -r41690e60056ca81a2486fec8aa012ef9b7f902de -r9e62891148c85e439f8b91fa44fca14d9dd44059 --- Riskeer/HydraRing/src/Riskeer.HydraRing.IO/HydraulicLocationConfigurationDatabase/HydraulicLocationConfigurationDatabaseReader.cs (.../HydraulicLocationConfigurationDatabaseReader.cs) (revision 41690e60056ca81a2486fec8aa012ef9b7f902de) +++ Riskeer/HydraRing/src/Riskeer.HydraRing.IO/HydraulicLocationConfigurationDatabase/HydraulicLocationConfigurationDatabaseReader.cs (.../HydraulicLocationConfigurationDatabaseReader.cs) (revision 9e62891148c85e439f8b91fa44fca14d9dd44059) @@ -61,23 +61,23 @@ /// Thrown when the database returned incorrect values for required properties. public ReadHydraulicLocationConfigurationDatabase Read(long trackId) { - return new ReadHydraulicLocationConfigurationDatabase(GetFromDatabase(GetLocations).Where(rhl => rhl.TrackId == trackId), - IsScenarioInformationTablePresent() - ? GetFromDatabase(GetConfigurationSettings) + return new ReadHydraulicLocationConfigurationDatabase(GetFromDatabase(ReadLocations).Where(rhl => rhl.TrackId == trackId), + GetFromDatabase(IsScenarioInformationTablePresent) + ? GetFromDatabase(ReadConfigurationSettings) : null, GetUsePreprocessorClosureByTrackId(trackId)); } /// - /// Gets the hydraulic locations from the database. + /// Reads the hydraulic locations from the database. /// /// A collection of as found in the database. /// Thrown when the database query failed. /// Thrown when the database returned incorrect values for required properties. - private IEnumerable GetLocations() + private IEnumerable ReadLocations() { var readHydraulicLocations = new Collection(); - + using (IDataReader dataReader = CreateDataReader(HydraulicLocationConfigurationDatabaseQueryBuilder.GetLocationsQuery())) { while (MoveNext(dataReader)) @@ -95,41 +95,33 @@ /// Determines whether the table related to the scenario information is present in the database. /// /// true if the table is present; false otherwise. - /// Thrown when the information could not be read from the database file. + /// Thrown when the database query failed. + /// Thrown when the database returned incorrect values for required properties. + /// Thrown when the information could not be read from the database. private bool IsScenarioInformationTablePresent() { - string query = HydraulicLocationConfigurationDatabaseQueryBuilder.GetIsScenarioInformationPresentQuery(); - - try + using (IDataReader dataReader = CreateDataReader(HydraulicLocationConfigurationDatabaseQueryBuilder.GetIsScenarioInformationPresentQuery())) { - using (IDataReader dataReader = CreateDataReader(query)) + if (dataReader.Read()) { - if (dataReader.Read()) - { - return Convert.ToBoolean(dataReader[ScenarioInformationTableDefinitions.IsScenarioInformationPresent]); - } - - string message = new FileReaderErrorMessageBuilder(Path).Build(Resources.HydraulicBoundaryDatabaseReader_Critical_Unexpected_value_on_column); - throw new CriticalFileReadException(message); + return dataReader.Read(ScenarioInformationTableDefinitions.IsScenarioInformationPresent); } + + string message = new FileReaderErrorMessageBuilder(Path).Build(Resources.HydraulicBoundaryDatabaseReader_Critical_Unexpected_value_on_column); + throw new CriticalFileReadException(message); } - catch (SQLiteException exception) - { - string message = new FileReaderErrorMessageBuilder(Path).Build(Resources.HydraulicLocationConfigurationDatabaseReader_Critical_Unexpected_Exception); - throw new CriticalFileReadException(message, exception); - } } /// - /// Gets the hydraulic location configuration settings from the database. + /// Reads the hydraulic location configuration settings from the database. /// /// A collection of the read hydraulic location configuration database settings. /// Thrown when the database query failed. /// Thrown when the database returned incorrect values for required properties. - private IEnumerable GetConfigurationSettings() + private IEnumerable ReadConfigurationSettings() { var readSettings = new Collection(); - + using (IDataReader dataReader = CreateDataReader(HydraulicLocationConfigurationDatabaseQueryBuilder.GetScenarioInformationQuery())) { while (MoveNext(dataReader)) @@ -216,7 +208,7 @@ /// The for reading data from the database. /// The type of data to read from the database. /// The read data of type . - /// Thrown when the database query failed. + /// Thrown when the database query failed or the data could not be read. /// Thrown when the database returned incorrect values for required properties. private T GetFromDatabase(Func readFromDatabaseFunc) {