Because you have to check
whether
PingtreeNode
contains any nodes with aResult == 2
I would use Any
method:
IGrouping<TierRequest,PingtreeNode> source;
bool anyResultIs2 = source.SelectMany(x => x)
.Any(x => x.Response.Result == 2);
It can also be done without SelectMany
:
bool anyResultId2 = source.Any(g => g.Any(x => x.Response.Result == 2));
And because both SelectMany
and Any
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.