How to debug a LINQ Statement

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

    While it isn't a way of debugging, I'd suggest using the following:

    using (var db = new AppContext())
            {
                db.Database.Log = s => System.Diagnostics.Debug.WriteLine(s);
                // Rest of code
            }
    

    You can then check the output window when debugging to see the SQL generated from your LINQ query.

提交回复
热议问题