Recently, I introduce myself to LinqToSQL through a poorly executed project at work. I am curious why this works:
var territories = db.Territories.Where(t => t.PendingUserCount > 0);
But this leads to a compilation error:
var territories = db.Territories; if (someCondition) territories = territories.Where(t => t.PendingUserCount > 0);
I also tried calling db.Territories.ToList() , but to no avail.
I'm sure this is just a misunderstanding of how Linq works, but I would appreciate it if someone would help me.
source share