fix Issue 9628 - Lambda in foreach loop Vs. lambda in static foreach loop