Exemple #1
0
 public static void SelectallEmployeesWithInclude(TelerikAcademyEntities context)
 {
     using (context)
     {
         foreach (var item in context.Employees.Include("Departments").Include("Adressess.Town"))
         {
             Console.WriteLine("Name {0}, Department {1}, Town {2}",
                 item.FirstName, item.Department.Name, item.Address.Town.Name);
         }
     }
 }
Exemple #2
0
 public static void SelectAllEmployeesWithoutInclude(TelerikAcademyEntities context)
 {
     using (context)
     {
        foreach (var entity in context.Employees)
         {
             Console.WriteLine("Name {0}, Department {1}, Town {2}",
                 entity.FirstName, entity.Department.Name, entity.Address.Town.Name);
         }
     }
 }
Exemple #3
0
        public static void SelectEmpInTown(TelerikAcademyEntities context, string town)
        {
            using (context)
            {
               // var employees = context.Employees.Where(x => x.Address.Town.Name == town);

                var employees = context.Employees
                                         .Select(e => e.Address)
                                         .Select(a => a.Town)
                                         .Where(t => t.Name == "Sofia")
                                         .ToList();

                foreach (var employee in employees)
                {
                    Console.WriteLine(employee.FirstName+" "+employee.LastName);
                }
            }
        }