Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs =================================================================== diff -u -rcdc41931db8cd6fbebe910c08d315d1b7066a6d2 -r86e6bb44ba1ccbec534f3fcf379481ea8d45d67f --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision cdc41931db8cd6fbebe910c08d315d1b7066a6d2) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilModelReader.cs (.../StochasticSoilModelReader.cs) (revision 86e6bb44ba1ccbec534f3fcf379481ea8d45d67f) @@ -38,7 +38,6 @@ public class StochasticSoilModelReader : SqLiteDatabaseReaderBase { private const string pipingMechanismName = "Piping"; - private SQLiteDataReader dataReader; /// @@ -65,6 +64,11 @@ public bool HasNext { get; private set; } /// + /// Gets the amount of that can be read from the database. + /// + public int PipingStochasticSoilModelCount { get; private set; } + + /// /// Reads the information for the next stochastic soil model from the database and creates a /// instance of the information. /// @@ -96,6 +100,11 @@ base.Dispose(); } + private int ReadStochasticSoilModelCount() + { + return !dataReader.Read() ? 0 : Convert.ToInt32(dataReader[StochasticSoilModelDatabaseColumns.Count]); + } + private StochasticSoilModel ReadPipingStochasticSoilModel() { if (!HasNext) @@ -107,7 +116,7 @@ do { // Read Points - var point2D = ReadSegmentPoint(dataReader); + var point2D = ReadSegmentPoint(); if (point2D != null) { stochasticSoilModelSegment.Geometry.Add(point2D); @@ -139,6 +148,7 @@ private void CreateDataReader() { + string locationCountQuery = SoilDatabaseQueryBuilder.GetStochasticSoilModelOfMechanismCountQuery(); var stochasticSoilModelSegmentsQuery = SoilDatabaseQueryBuilder.GetStochasticSoilModelOfMechanismQuery(); var sqliteParameter = new SQLiteParameter { @@ -148,14 +158,16 @@ }; try { - dataReader = CreateDataReader(stochasticSoilModelSegmentsQuery, sqliteParameter); + dataReader = CreateDataReader(locationCountQuery + stochasticSoilModelSegmentsQuery, sqliteParameter); } catch (SQLiteException exception) { CloseConnection(); var message = new FileReaderErrorMessageBuilder(Path).Build(Resources.StochasticSoilModelDatabaseReader_Failed_to_read_database); throw new CriticalFileReadException(message, exception); } + PipingStochasticSoilModelCount = ReadStochasticSoilModelCount(); + dataReader.NextResult(); } private void VerifyVersion(string databaseFilePath) @@ -182,7 +194,7 @@ return new StochasticSoilModel(stochasticSoilModelId, stochasticSoilModelName, segmentName); } - private static Point2D ReadSegmentPoint(SQLiteDataReader dataReader) + private Point2D ReadSegmentPoint() { double coordinateX = Convert.ToDouble(dataReader[SegmentPointsDatabaseColumns.CoordinateX]); double coordinateY = Convert.ToDouble(dataReader[SegmentPointsDatabaseColumns.CoordinateY]);