public void Task2() { var query1 = from employees in employeeList join salary in salaryList.Where(s => s.Type == SalaryType.Monthly) on employees.EmployeeID equals salary.EmployeeID into EmpGrp select new { EmployeeId = employees.EmployeeID, FirstName = employees.EmployeeFirstName, LastName = employees.EmployeeLastName, EmployeeAge = employees.Age, Sum = EmpGrp.Sum(s => s.Amount) }; Console.WriteLine("Employee details of 2nd oldest employee including his/her total monthly salary : "); Console.WriteLine(); foreach (var emps in query1.OrderByDescending(a => a.EmployeeAge).Skip(1).Take(1)) { Console.WriteLine($"Employee Id : {emps.EmployeeId} " + $"Employee Name : " + $"{emps.FirstName} " + $"{emps.LastName} " + $"Employee Age : {emps.EmployeeAge} " + $"Employee Total Monthly Salary : {emps.Sum}"); } Console.WriteLine(); }
public void Task3() { var query1 = from employees in employeeList.Where(e => e.Age > 30) join salary in salaryList on employees.EmployeeID equals salary.EmployeeID into EmpGrp select new { Id = employees.EmployeeID, Name = employees.EmployeeFirstName, EmployeeAge = employees.Age, Avg = EmpGrp.Average(s => s.Amount) } into results select results; Console.WriteLine("Mean of Monthly, Performance, Bonus salary of employees with age greater than 30 : "); Console.WriteLine(); foreach (var emps in query1) { Console.WriteLine($"Employee Id : {emps.Id} Employee Name : {emps.Name} Employee Age : {emps.EmployeeAge} Employee Salary Average : {emps.Avg}"); } }
public void Task1() { var query1 = from employees in employeeList join salary in salaryList on employees.EmployeeID equals salary.EmployeeID into EmpGrp select new { FirstName = employees.EmployeeFirstName, LastName = employees.EmployeeLastName, Sum = EmpGrp.Sum(s => s.Amount) }; Console.WriteLine("Total salary Of All The Employee in ascending order of their salary : "); Console.WriteLine(); foreach (var emps in query1.OrderBy(s => s.Sum)) { Console.WriteLine($"Employee Name : " + $"{emps.FirstName} " + $"{emps.LastName} " + $" Employee Salary : {emps.Sum}"); } Console.WriteLine(); }