Exemple #1
0
        public void Task1()
        {
            var emp = (from Employee in employeeList
                       join Salary in salaryList on Employee.EmployeeID equals Salary.EmployeeID
                       group new { Salary, Employee } by Employee.EmployeeFirstName into SalaryGroup
                       orderby SalaryGroup.Sum(x => x.Salary.Amount)
                       select new { Name = SalaryGroup.Key, s = SalaryGroup.Sum(x => x.Salary.Amount) }
                       );

            foreach (var sal in emp)
            {
                Console.WriteLine($"{sal.Name}:{sal.s}");
            }
        }
        public void Task1()
        {
            var result = (from Employee in employeeList
                          join Salary in salaryList
                          on Employee.EmployeeID equals Salary.EmployeeID
                          group new { Salary, Employee } by Employee.EmployeeFirstName into SalaryGroup
                          orderby SalaryGroup.Sum(i => i.Salary.Amount)
                          select new { Name = SalaryGroup.Key, sal = SalaryGroup.Sum(i => i.Salary.Amount) }
                          );

            Console.WriteLine("Total salary of all the employees with their names in ascending order \n");
            foreach (var i in result)
            {
                Console.WriteLine($"{i.Name}:{i.sal}");
            }
        }