Allright, so there’s the “Break” activity for when you want to break out of a loop. But what about the times you just want to skip to the next element in the loop? Sure, a switch or if-statement would do the trick, but it’s messy and unnecessary.
The same thing i had asked them right at the first time while my training was on.
There was no way that time.
What I have done is that all the loop body is placed in a Try-Catch(With Custom Message)
In the loop body(which is in the Try Block), where ever you need to have a continue, simply put a throw exception activity with your custom error message.
In the Catch block, trap all exceptions and get the exception message.
If the exception message is same as your custom message then consume the exception so that the execution will continue to next iteration. If not then put a ReThrow.
But nonetheles…we definitely need a Continue activity.
You can branch within a loop using If/Else statements. If the branching is too complicated you can use a flowchart within the loop (instead of sequence).
I would not recommend the use of “continue” in the middle of a large loop block for readability purposes.
If the element needs to be completely skipped, which usually is the first thing that’s checked in the loop, one could use a .Where clause: foreach (item in collection.Where(Function(x) x > 17)) { ... }
Due to iterative nature of LINQ queries it’s functionally equivalent to (and perfomarnce wise negligibly different than): foreach (item in collection) { if (x > 17) { ... } }
It needs some getting used to, but (un)fortunately structuring workflows needs to be a little different from “standard” code. Nesting activities is way more exhausting to read than nesting scopes with proper indentation.
This is one more case where we could make use of the System.Data.DataSetExtensions which is not currently available. I have also mentioned this in some other post in this forum.