I have LINQ statement that causes a timeout when I called the FirstOrDefault();
method. But if I cast the results to a List
first, the call the FirstOrDefault();
method, it works just fine.
Why would this LINQ statement cause an SQL timeout:
var n = next.Where(w => w.Status == 1).FirstOrDefault();
But this one work just fine?
var n = next.Where(w => w.Status == 1).ToList().FirstOrDefault();