Stopwatch st1 = new Stopwatch(); Stopwatch st2 = new Stopwatch(); int counter = 10000; IEnumerable<Employee> iEmp = null; IQueryable<Employee> qEmp = null; BindingList<Employee> bList = new BindingList<Employee>(); for (int i = 1; i <= counter; ++i) { bList.Add(new Employee { Department = $"Dept - {i}", EmployeeID = i, EmployeeName = $"Employee - {i}", Salary = i + 10000 }); } iEmp = bList.AsEnumerable<Employee>(); qEmp = bList.AsQueryable<Employee>(); st1.Start(); var t = qEmp.Where(x => x.EmployeeID % 2 == 0).ToList(); st1.Stop(); Console.WriteLine($"Queryable-Where-ToList: {st1.ElapsedTicks}"); st2.Start(); var t1 = qEmp.ToList().Where(x => x.EmployeeID % 2 == 0); st2.Stop(); Console.WriteLine($"Queryable-ToList-Where: {st2.ElapsedTicks}"); Console.ReadKey();
ToList
ICollection<T>
BindingList<T>
.Where(...).ToList()
.ToList().Where(...)
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)