I want to clarify my doubts about LINQ. I have code like:
val collection = this.Employees.Where(emp => emp.IsActive) foreach (var emp in collection) {
Now, if I write the code as follows:
foreach (var emp in this.Employees.Where(emp => emp.IsActive)) {
will this.Employees.Where(emp => emp.IsActive) be executed at each iteration, or is it executed only once?
Ahmed source share