Esempio n. 1
0
        private static List <Employee> GetEmployeesWithProjectsIn2002()
        {
            var context   = new SoftUniEntities();
            var employees = context.Employees
                            .Where(e => e.Projects
                                   .Any(p => p.StartDate >= new DateTime(2002, 1, 1) &&
                                        p.StartDate <= new DateTime(2002, 12, 31)))
                            .OrderBy(e => e.FirstName + " " + e.LastName)
                            .ToList();

            return(employees);
        }
Esempio n. 2
0
        private static List <Employee> GetEmployeesNative()
        {
            var context   = new SoftUniEntities();
            var employees = context.Employees.SqlQuery(@"
                SELECT *
                FROM Employees e
                JOIN EmployeesProjects ep
                ON e.EmployeeID = ep.EmployeeID
                JOIN Projects p
                ON p.ProjectID = ep.ProjectID
                WHERE p.StartDate >= '2002-1-1' AND p.StartDate <= '2002-12-31'").ToList();

            return(employees);
        }