How to debug a LINQ Statement

后端 未结 9 1224
自闭症患者
自闭症患者 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:31

    It is possible to step inside the LINQ expression without setting any temporary breakpoints. You need to step into the function which evaluates the LINQ expression, e.g.:

    var confirm = from l in lines.Lines 
                  where (l.LineNumber == startline.LineNumber)
                        || (l.LineNumber == endline.LineNumber) 
                  select l;
    
     confirm.ToArray(); // Press F11 ("Step into") when you reach this statement
    
     foreach(var o in q) // Press F11 when "in" keyword is highlighted as "next statement"
        // ...
    

提交回复
热议问题