Need to debug LINQ simple queries in Visual Studio 2010

please delete me picture please delete me · Mar 16, 2010 · Viewed 7.9k times · Source

I often get in a position when I need to know why my LINQ doesnt work as intended... I use object collections and extensions.

I dont want spend more than couple of minutes on it. LINQ supposed to make developer's life easier not harder.

I hoped VS 2010 will have it fixed but I now use RC and it still doesnt let me type LINQ and check what is going on... Says as before "Expression cannot contain lambda expressions"...

Is there some add-on for Visual Studio so I can quickly and effectively run ad-hoc queries and find out what is going on and where I am wrong?

Answer

Leniel Maccaferri picture Leniel Maccaferri · Mar 16, 2010

Have you tried this?

Debugging LINQ Queries

Debugging LINQ queries can be problematic. One of the reasons is that quite often, you write a large query as a single expression, and you can’t set a breakpoint mid-expression. Writing large queries in expression context is particularly powerful when using functional construction to form XML (or using the strongly typed DOM in Open XML SDK V2). This post presents a little trick that makes it easier to use the debugger with LINQ queries that are written using ‘method syntax’.