Ejemplo n.º 1
0
        // Calculate average salary of employees having the specified supervisor
        static decimal AverageSalary(Context context, string supervisor)
        {
            var avg = context.Employees
                .Where(m => m.Supervisor.Name.Equals(supervisor));

            return avg.Average(m => m.Position.Salary);
        }
Ejemplo n.º 2
0
 // Remove all employees occupying the specified position and the position itself
 static void RemovePosition(Context context, string position)
 {
     var s = context.Positions
         .Where(m => m.Name.Equals(position));
     foreach (var item in s)
     {
         context.Positions.Remove(item);
     }
 }
Ejemplo n.º 3
0
        // Change salary of all employees holding the specified position by delta
        static void ChangeSalary(Context context, string position, decimal delta)
        {
            var selectedEmployees = context.Employees
                .Where(m => m.Position.Equals(position));

            foreach (var pos in selectedEmployees)
	        {
                pos.Position.Salary += delta;
	        }
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            using (var c = new Context())
            {
                ChangeSalary(c, "Engineer", 3000);
                c.Employees.ToList();
                c.SaveChanges();
            }

            //ShowEmployees(data);
        }
Ejemplo n.º 5
0
 static IQueryable<EmployeeRecord> LoadEmployeesFromDB(Context context)
 {
     throw new NotImplementedException();
 }