如何调试LINQ语句 [英] How to debug a LINQ Statement
问题描述
我有一个Linq对象语句
I have a Linq to objects statement
var confirm = from l in lines.Lines
where (l.LineNumber == startline.LineNumber) || (l.LineNumber == endline.LineNumber)
select l;
确认对象在System.Linq.Enumerable处返回Object Null or Not A Reference .WhereListIterator`1.MoveNext()
The confirm object is returning an 'Object Null or Not A Reference' at at System.Linq.Enumerable.WhereListIterator`1.MoveNext()
如果查询的结果为空,它将返回一个空的枚举器。我知道一个事实,语句中没有空对象。可以通过LINQ语句来查看它在哪里下降吗?
If the result of the query was empty, it would just return an empty enumerator. I know for a fact that there are no null objects in the statement. Is it possible to step through the LINQ statement to see where it is falling over?
编辑当我说,我知道一个事实上没有空对象,原来我在说谎:[但是问题依然存在,尽管如此,尽管如此,答案将是你不能真的
EDIT When I said I know for a fact that there are no null objects it turns out I was lying :[, but the question remains, though I am asuming the answer will be 'you can't really'
LINQPad是一个好主意,我用它来教自己LINQ,但是我可以再次看看它是一个调试/斜线和刻录风格的工具
LINQPad is a good idea, I used it to teach myself LINQ, but I may start looking at it again as a debug / slash and burn style tool
推荐答案
我不知道是否可以从VS进行调试,但是我发现 LINQPad 非常有用。它将让您转储LINQ查询的每个部分的结果。
I'm not sure if it's possible to debug from VS, but I find LINQPad to be quite useful. It'll let you dump the results of each part of the LINQ query.
这篇关于如何调试LINQ语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!