Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stepping through Linq statement tips

Tags:

c#

debugging

linq

When I step through code and get to a linq statement, the stepping through process and the lines which are evaluated (and their order) are not the same as the code is written. I know this is to do with commands like yield etc.

My questions are:

  1. What do I need to learn to understand why the code is debugged in the way it is (with Linq statements)?
  2. What stepping through techniques are there for Linq statements?

Oh, and I use Visual Studio 2010 Ultimate.

like image 454
GurdeepS Avatar asked Jan 04 '12 15:01

GurdeepS


1 Answers

According to MSDN

Any query that compiles to an expression tree produces code that is beyond the control of the debugger.

So you won't be able to fully debug the Linq query through Visual Studio Debugger.

But

there are few tool which can help for example Linq Pad

This page also describes some techniques that can be used for debugging Linq statements

This is another detailed article about debugging Linq

like image 74
Haris Hasan Avatar answered Sep 30 '22 14:09

Haris Hasan