I have an IGrouping structure
IGrouping<TierRequest,PingtreeNode>
PingtreeNode contains a property of Response which in turn has a property Result.
public class PingtreeNode
{
public ResponseAdapter Response { get; set;}
// ... more properties
}
public class ResponseAdapter
{
public int Result { get; set; }
// ... more properties
}
What I want to do is check whether PingtreeNode contains any nodes with a Result == 2. I know the answer includes a SelectMany but I'm struggling to get the correct syntax.
Anyone help?
Because you have to check
I would use
Any
method:It can also be done without
SelectMany
:And because both
SelectMany
andAny
are lazy (return only one element at the time and end execution as soon as result is determined), performance of both approaches should be similar.