2

I'm debugging in VS2010, and I want to inspect a string value but all I can get the debugger to show me (through watches, hovering, locals, etc.) is:

"System.Linq.Enumerable+<TakeIterator>d__3a`1[System.Char]"

I don't care if there are side effects from premature evaluation or whatever, I just want to see what the expression would evaluate to if I evaluate it right now at the current breakpoint.

How is this done? Also can I change my code in such a way that it evaluates earlier? Not that I care when I'm not debugging... but just wondering.

In case it is relevant... (I doubt it.) I'm stuffing a new entity object before saving it to the database... some fields are assigned with LINQ statements, I'm not sure when they get evaluated under the covers of EF. The DB update fails with 'string or binary data would be truncated... So I'm trying to find the too-long field.

hlovdal
  • 26,565
  • 10
  • 94
  • 165
DanO
  • 2,526
  • 2
  • 32
  • 38

2 Answers2

5

Screenshot


Are you accidentally doing something like this perhaps?

Screenshot

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
dtb
  • 213,145
  • 36
  • 401
  • 431
  • Yes acutally. There is something like that going on. Why would that be an accident? – DanO Apr 23 '10 at 22:48
  • 1
    Ah, duh, I get it! I'm turning the epression tree (or whatever that is) into a string... – DanO Apr 23 '10 at 22:50
  • I have been doing this "accident" but its on purpose. How can I get the string back after I `Take()`? – rtpHarry May 21 '11 at 18:13
2

This is late and may or may not apply to what was asked originally, but I found this article by Bart De Smet some time ago about coding techniques to help with Linq to Objects debugging:

http://community.bartdesmet.net/blogs/bart/archive/2009/04/23/linq-to-objects-debugging.aspx

I haven't tried it yet, but I thought it looked interesting.

wageoghe
  • 27,390
  • 13
  • 88
  • 116