public void TODO10()
        {
            using (var context = new AcademyContext())
                    {

                        context.Testses.Load();

                        var query = from testwork in context.TestWorks

                                    group testwork.result by testwork.TestsId.category;

                        var List = query.ToList();

                        var colection = new List<TODO9_sort>();

                        foreach (var category in List)
                        {
                            int count = 0;
                            double sum = 0;

                            foreach (var item in category)
                            {

                                sum += item;
                                count++;

                            }

                            colection.Add(new TODO9_sort() { category = category.Key, rating = sum });

                        }

                        var query1 = from item in colection
                                     orderby item.rating descending
                                     select new
                                     {
                                         category = item.category,
                                         rating = item.rating,
                                     };

                        foreach (var item in query1)
                        {
                            Console.WriteLine("Category: {0}\n Point: {1}", item.category, item.rating);
                        }

                    }
        }
        public void TODO1()
        {
            using (var context = new AcademyContext())
            {

                context.TestWorks.Load();

                var query = from user in context.Users
                            select user;

                var userList = query.ToList();

                foreach (var user in userList.Where(user => user.TestWorks != null).Where(user => user.TestWorks.result >= 20))
                {
                    Console.WriteLine("\nName: " + user.name + "\n Age: " + user.age + "\nCity: " + user.city);
                }
            }
        }
        public void TODO8()
        {
            using (var context = new AcademyContext())
                    {
                        context.Lectures.Load();

                        var query = from teacher in context.Teachers
                                    orderby teacher.readLectures descending
                            select teacher;

                        var teacherList = query.ToList();

                        foreach (var teacher in query)
                        {

                            Console.WriteLine("\nName: {0} \nRead lecture {1}:",teacher.name,teacher.readLectures);
                        }
                    }
        }
        public void TODO7()
        {
            using (var context = new AcademyContext())
                    {

                        var query = from question in context.Questions
                                    orderby question.usedQuestion descending
                                    select question;

                        var questionList = query.ToList();

                        foreach (var question in questionList)
                        {

                            Console.WriteLine("\nCategory:{0}\nText question:{1}\n Used quesion:{2}",question.category,question.textQuestion,question.usedQuestion);

                        }
                    }
        }
        public void TODO6()
        {
            using (var context = new AcademyContext())
                    {

                        context.TestWorks.Load();

                        var query = from user in context.Users
                                    select user;

                        var userList = query.ToList();

                        foreach (var item in userList.Where(item => item.TestWorks != null))
                        {
                            Console.WriteLine("\nName: " + item.name + "\n Age: " + item.age + "\nCity: " + item.city +
                                              "\n Result: " + item.TestWorks.result + "\n Lead time: " + item.TestWorks.leadTime);
                        }
                    }
        }
        public void TODO5()
        {
            using (var context = new AcademyContext())
                    {

                        context.TestWorks.Load();

                        var query = from user in context.Users
                            select user;
                        var query1 = from user in query
                                     where user.TestWorks.result >= 20 && user.TestWorks.leadTime<=30
                            group user.name by user.city;

                        var userList = query1.ToList();

                        foreach (var city in userList)
                        {

                            int count = 0;
                            Console.WriteLine("Students from {0} :", city.Key);
                            foreach (var item in city)
                            {

                                count++;

                                Console.WriteLine("{0}", item);

                            }
                            Console.WriteLine("Students from {0} = {1}\n", city.Key, count);
                        }
                    }
        }
 public LogicsMethod()
 {
     var context = new AcademyContext();
     context.Configuration.LazyLoadingEnabled = false;
 }
        public void TODO4()
        {
            using (var context = new AcademyContext())
                    {

                        var query = from user in context.Users
                            group user.name by user.city;

                        var userList = query.ToList();

                        foreach (var city in userList)
                        {
                            int count = 0;
                            Console.WriteLine("Students from {0} :", city.Key);
                            foreach (var item in city)
                            {

                                count++;

                                Console.WriteLine("{0}", item);

                            }
                            Console.WriteLine("Students from {0} = {1}\n", city.Key, count);
                        }
                    }
        }