Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs
===================================================================
diff -u -rcdc41931db8cd6fbebe910c08d315d1b7066a6d2 -r64c21c2c91a3cef9df279e58efda8e45a9d598f7
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision cdc41931db8cd6fbebe910c08d315d1b7066a6d2)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/StochasticSoilProfileReader.cs (.../StochasticSoilProfileReader.cs) (revision 64c21c2c91a3cef9df279e58efda8e45a9d598f7)
@@ -66,16 +66,19 @@
/// instance of the information.
///
/// Identifier of the next to look for.
- /// The next from the database, or null if no more soil profiles can be read.
+ /// The next from the database, or null if no more stochastic soil profiles can be read.
/// Thrown when the database returned incorrect values for required properties.
public StochasticSoilProfile ReadStochasticSoilProfile(long stochasticSoilModelId)
{
if (!HasNext)
{
return null;
}
- MoveToStochasticSoilModelId(stochasticSoilModelId);
+ if (!MoveToStochasticSoilModelId(stochasticSoilModelId))
+ {
+ return null;
+ }
try
{
StochasticSoilProfile stochasticSoilProfile = ReadStochasticSoilProfileProbability();
@@ -136,19 +139,26 @@
}
}
- private void MoveToStochasticSoilModelId(long stochasticSoilModelId)
+ private bool MoveToStochasticSoilModelId(long stochasticSoilModelId)
{
while (HasNext && ReadStochasticSoilModelId() < stochasticSoilModelId)
{
MoveNext();
}
+ if (ReadStochasticSoilModelId() == stochasticSoilModelId)
+ {
+ return true;
+ }
+ MoveToNextStochasticSoilModelId(stochasticSoilModelId);
+ return false;
}
private void MoveToNextStochasticSoilModelId(long stochasticSoilModelId)
{
- while (HasNext && ReadStochasticSoilModelId() == stochasticSoilModelId)
+ MoveNext();
+ if (HasNext)
{
- MoveNext();
+ HasNext = ReadStochasticSoilModelId() == stochasticSoilModelId;
}
}