-1

For example say I am using a WHERE clause and I would like to see the iteration happen without changing it to an iterated loop. In Visual Studio 2012 or higher for checking lambda function iterations.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Kdoor
  • 45
  • 6
  • 1
    No. And if you find you need to, maybe your LINQ expression is too complicated. – Mitch Wheat Mar 14 '15 at 01:30
  • 1
    You can put a break point on it. Just put your cursor on the content of the where clause and hit F9. It should highlight just the where clause. Then start debugging and you should hit the break point. – Mike Zboray Mar 14 '15 at 01:46
  • Made the question a bit more specific. Was able to solve this as a null pointer see comment below on Cyrals answer. @Mitch any recommendations for refactor by chance considering the answers? Yeah it's a bit of inherited code... – Kdoor Mar 17 '15 at 02:40

1 Answers1

0

VS 2015 Preview supports LINQ and Lambda expressions inside the immediate window. This can help you modify the query and possibly debug it easier, but there is no way to debug it as if it was a standard loop.

LINQPad is also a very helpful tool for developing LINQ queries and dumping their results.

Another option would be to use different lambda expression syntax that allows you to write multiple statements, and therefor step through the code.

.Select(i => {
    return i; //Add a breakpoint on this line.
});
Cyral
  • 13,999
  • 6
  • 50
  • 90
  • Thanks Cyral! I used to use LINQPad a bit, but I wasn't using LINQ as much back then. Your multiple lines idea is clever I'll give that a go in the future. Turns out there was a null pointer in a parent prop in the lambda. If it's of use I can add the snippet. Going to try to short circuit it in the where. – Kdoor Mar 17 '15 at 02:10