I have observable collection called m_Tree. It contains objects of Planet type which has property Name. The collection could have hundreds of items in it. How do I quickly find a Planet.Name="Jupiter" in QuickWatch window in VS?
Currently, I have to manually expand each car in the collection and look for its Name but that can be troubling. Lambda expressions or LINQ do not work in QuickWatch as far as I can see.
Here is what I tried with LINQ
from item in m_Tree where item.Name == "Jupiter" select item
but QuickWatch shows error
from item in m_Tree where item.Name == "Jupiter" select item
Expression cannot contain query expressions
I created a commercial extension for Visual Studio that solves exactly this problem. OzCode replaces the normal QuickWatch and DataTip (hover over variable) windows. If you're just looking for the property value as text, you can use the Search feature:
But if you want to "Jupiter" only when its the value in the "Name" property, not in any other property, you can use OzCode's Filter:
And type in [obj].Name == "Jupiter"
as your predicate.
Though my answer is not about doing it in QuickWatch, it may help you get the job done.
While in debug mode, you can use the Immediate Window to do that. If not already open, open Immediate Window, and execute your query.
var jupiters = (from item in m_Tree where item.Name == "Jupiter" select item).ToList();
jupiters // prints the objects in the Immediate Window
I use Immediate Window a lot, and find it very helpful. Hope that helps you too.
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