How to debug a LINQ Statement

后端 未结 9 1206
自闭症患者
自闭症患者 2020-12-04 23:47

I have a Linq to objects statement

 var confirm = from l in lines.Lines 
 where (l.LineNumber == startline.LineNumber) || (l.LineNumber == endline.LineNumber         


        
9条回答
  •  渐次进展
    2020-12-05 00:22

    You should be able to set a breakpoint on the expression in the where clause of your LINQ statement.

    In this example, put the cursor anywhere in the following section of code:

    (l.LineNumber == startline.LineNumber) || (l.LineNumber == endline.LineNumber)
    

    Then press F9 or use the menu or context menu to add the breakpoint.

    When set correctly, only the above code should have the breakpoint formatting in the editor rather than the entire LINQ statement. You can also look in the breakpoints window to see.

    If you've set it correctly, you will stop each time at the function that implements the above part of the query.

提交回复
热议问题