调试时如何评估延迟的 Linq 语句?
我正在 VS2010 中进行调试,我想检查一个字符串值,但我可以让调试器向我展示(通过监视、悬停、局部变量等)是:
"System.Linq.Enumerable+<TakeIterator>d__3a`1[System.Char]"
我不关心是否存在过早的副作用评估或其他什么,我只是想看看如果我现在在当前断点评估表达式会评估什么。
这是怎么做到的?我还可以更改我的代码以使其更早评估吗?并不是说我不关心什么时候不调试......而是只是想知道。
万一它是相关的......(我对此表示怀疑。)我正在填充一个新的 保存之前的实体对象 到数据库...某些字段是用 LINQ 语句分配的,我不确定它们何时在 EF 的掩护下进行评估。数据库更新失败,并显示“字符串或二进制数据将被截断...所以我试图找到太长的字段。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否不小心做了这样的事情?
Are you accidentally doing something like this perhaps?
这已经晚了,可能适用也可能不适用于最初提出的问题,但我不久前发现了 Bart De Smet 撰写的这篇文章,内容涉及帮助 Linq to Objects 调试的编码技术:
http://community.bartdesmet.net/blogs/bart/archive/2009/04 /23/linq-to-objects-debugging.aspx
我还没有尝试过,但我认为它看起来很有趣。
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.