调试时如何评估延迟的 Linq 语句?

发布于 2024-08-30 05:57:08 字数 454 浏览 3 评论 0原文

我正在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

作死小能手 2024-09-06 05:57:08

屏幕截图


您是否不小心做了这样的事情?

屏幕截图

Screenshot


Are you accidentally doing something like this perhaps?

Screenshot

时光暖心i 2024-09-06 05:57:08

这已经晚了,可能适用也可能不适用于最初提出的问题,但我不久前发现了 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文