在手表/调试LINQ查询查看结果手表、结果、LINQ

2023-09-03 17:05:18 作者:曲子丶是喜是悲

有没有一种方法可以查看在Visual Studio 2010中的LINQ查询的结果呢?如果添加了查询作为手表的前pression它会说前pression不能包含拉姆达EX pressions。

Is there a way you can view the result of a LINQ query in Visual Studio 2010? If you add the query as a watch expression it will say "Expression cannot contain lambda expressions".

在一些测试code,我聚集了一堆指标的总数为孩子的一些数量和比较的和他们的父母值相同的度量(深嵌套的if-else)。我所有的查询是if语句研究。我怎样才能查看,而不只是结果赋给一个局部变量这些价值?分配双打我行计数和除了调试这里不提供好处。有没有人有一个变通,他们用它来查看调试LINQ查询的结果?

In some test code I'm aggregating the totals of a bunch of metrics for some number of children and comparing the sum to their parents value for the same metric (deep nested if-else). All my queries are in the if statements. How can I view these values without just assigning the result to a local variable? Assignment doubles my line count and aside from debugging here provides no benefit. Does anyone have a work around they use to view the results of LINQ queries in the debugger?

推荐答案

您目前不能使用在观察名单在Visual Studio中的lambda EX pressions。

You cannot currently use lambda expressions in the watch list in Visual Studio.

有几件事情可以做:

创建调用所需的lambda的方法,然后把这个方法 拨打你的表的语句。

Create a method that calls the desired lambda, then put that method call in your watch statement.

设置所需的λEX pression一个变量,再看看 该变量的内容。请注意,这将枚举 通过前pression,并可能引起副作用。

Set the desired lambda expression to a variable, then look at the contents of that variable. Be aware that this will enumerate through the expression, and may cause side effects.

我猜想这是VS功能要求的名单上,但MSFT还没有这么做过。希望这有助于在其间。

I would imagine this is on the list of feature requests for VS, but MSFT has not done it yet. Hopefully this helps in the meantime.

 
精彩推荐
图片推荐