Linq Extension Methods Not Available in Visual Studio 2015 Immediate Window
error CS1061: "ICollection <>" does not contain a definition for "SelectMany", and the extension method "SelectMany" cannot be found that takes the first argument of the type "ICollection <>" (do you miss the using directive or the assembly?)
Visual Studio 2015 supports evaluating lambda linq expressions in debug mode in the direct window. I tested it using a console application in which I selected Process.GetProcesses() , go to the nearest window and start writing .Select or .Where on it. It works great.
However, I cannot do the same in my project.
My breakpoint is on this line:
return Dimensions.Values.SelectMany(dimension => dimension.Attributes) .FirstOrDefault(dimensionAttribute => key.Equals(dimensionAttribute.Key)); Execution of work F10 . However, when I try to run the same expression in parts, in the direct window ie Dimensions.Values.SelectMany(dimension => dimension.Attributes) , I get the above error.
Am I trying to evaluate it wrong? What am I missing?
I canβt give you a reason why this is happening (I have similar problems with Immediate Window), but I found that you can call extension methods through access to the static class. In your case, it will be:
Enumerable.FirstOrDefault(Enumerable.SelectMany(Dimensions.Values, dimension => dimension.Attributes),dimensionAttribute => key.Equals(dimensionAttribute.Key));