error CS1061: 'ICollection<>' does not contain a definition for 'SelectMany' and no extension method 'SelectMany' accepting a first argument of type 'ICollection<>' could be found (are you missing a using directive or an assembly reference?)
Visual Studio 2015 supports evaluating linq lambda expressions in debug mode, in immediate window. I have tested it with a console application wherein i fetch Process.GetProcesses()
, go to immediate window and start writing .Select
or .Where
on it. It works fine.
However, I am not able to do the same in my Project.
My Breakpoint is at this line:
return Dimensions.Values.SelectMany(dimension => dimension.Attributes)
.FirstOrDefault(dimensionAttribute => key.Equals(dimensionAttribute.Key));
Doing a F10 works. However when I try to run this same expression in parts, in immediate window i.e. Dimensions.Values.SelectMany(dimension => dimension.Attributes)
, I get the above mentioned error.
Am I trying to evaluate this in an incorrect manner? What am I missing?
I can't give you the reason why that happens (I have similar issues with the Immediate Window), but I found that you can call extension methods via static class access. In your case that would be:
Enumerable.FirstOrDefault(Enumerable.SelectMany(Dimensions.Values, dimension => dimension.Attributes),dimensionAttribute => key.Equals(dimensionAttribute.Key));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With