public static void PrintEmployeInfoFast() { using (TelerikAcademyEntities dbContext = new TelerikAcademyEntities()) { foreach (var employe in dbContext.Employees.Include("Department").Include("Address").Include("Address.Town")) { Console.WriteLine("Employe name: {0}", employe.FirstName); Console.WriteLine("Employe department name: {0}", employe.Department.Name); Console.WriteLine("Employe town name: {0}", employe.Address.Town.Name); } } }
public static void FastSelect() { using (TelerikAcademyEntities dbContext = new TelerikAcademyEntities()) { List<Employee> sofiaEmployes = (from town in dbContext.Employees where town.Address.Town.Name == "Sofia" select town).ToList(); foreach (var item in sofiaEmployes) { Console.WriteLine(item.FirstName); } } }
public static void SlowSelect() { using (TelerikAcademyEntities dbContext = new TelerikAcademyEntities()) { List<Employee> allEmplpyes = (from emp in dbContext.Employees select emp).ToList(); List<Address> allAddreses = (from address in allEmplpyes select address.Address).ToList(); List<Town> sofiaTowns = (from town in allAddreses select town.Town).ToList().Where(x => x.Name == "Sofia").ToList(); foreach (var town in sofiaTowns) { Console.WriteLine(town.Name); } } }