예제 #1
0
        static void Main(string[] args)
        {
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studetnsGroup =
                from student in students
                where student.Email.EndsWith("@abv.bg")
                select student;

            foreach (var student in studetnsGroup)
            {
                Console.WriteLine(student);
            }
        }
        static void Main(string[] args)
        {
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studetnsGroup =
                from student in students
                where student.FirstName.CompareTo(student.LastName) < 0
                select student;

            foreach (var student in studetnsGroup2)
            {
                Console.WriteLine(student);
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studetnsGroup =
                from student in students
                where student.Age >= 18 && student.Age <= 24
                select new { FirstName = student.FirstName, LastName = student.LastName, Age = student.Age };

            foreach (var student in studetnsGroup)
            {
                Console.WriteLine("first name: {0}\nlast name: {1}\nage: {2}\n===========\n",
                                  student.FirstName, student.LastName, student.Age);
            }
        }
예제 #4
0
        static void Main(string[] args)
        {
            List <Student> students       = SampleStudents.GetSampleStudents();
            var            studetnsGroup2 =
                from student in students
                where student.GroupNumber == 2
                orderby student.FirstName ascending
                select student;

            foreach (var student in studetnsGroup2)
            {
                Console.WriteLine(student);
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            string[]       phoneFilter   = new string[] { "02", "+3592", "+359 2" };
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studetnsGroup =
                from student in students
                where phoneFilter.Any(filter => student.Phone.StartsWith(filter))
                select student;

            foreach (var student in studetnsGroup)
            {
                Console.WriteLine(student);
            }
        }
        static void Main(string[] args)
        {
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studentsGroup =
                from student in students
                where student.FacultyNumber.ToString().EndsWith("14")
                select new { Marks = student.Marks };

            foreach (var student in studentsGroup)
            {
                foreach (var mark in student.Marks)
                {
                    Console.Write(mark + " ");
                }
                Console.WriteLine();
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studentsGroup =
                from student in students
                where student.Marks.Contains(6)
                select new { FullName = student.FirstName + " " + student.LastName, Marks = student.Marks };

            foreach (var student in studentsGroup)
            {
                Console.Write(student.FullName);
                foreach (var mark in student.Marks)
                {
                    Console.Write(" " + mark);
                }
                Console.WriteLine();
            }
        }
예제 #8
0
        static void Main(string[] args)
        {
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studentsGroup =
                from student in students
                group student by student.GroupName into newGroup
                select newGroup;

            foreach (var group in studentsGroup)
            {
                Console.WriteLine("**********************");
                Console.WriteLine(group.Key);
                Console.WriteLine("**********************");
                foreach (var student in group)
                {
                    Console.Write(student + "\n");
                }
            }
        }
예제 #9
0
        static void Main(string[] args)
        {
            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studetnsGroup =
                from student in students
                orderby student.FirstName descending, student.LastName descending
            select student;

            /*foreach (var student in studetnsGroup)
             * {
             *  Console.WriteLine(student);
             * } */

            var ordered = students.OrderByDescending(student => student.FirstName)
                          .ThenByDescending(student => student.LastName);

            foreach (var student in ordered)
            {
                Console.WriteLine(student);
            }
        }
예제 #10
0
        static void Main(string[] args)
        {
            List <StudentsSpecialties> specialties = new List <StudentsSpecialties> {
                new StudentsSpecialties("Web Developer", 123123),
                new StudentsSpecialties("Web Developer", 123114),
                new StudentsSpecialties("PHP Developer", 131214),
                new StudentsSpecialties("QA Developer", 123125),
                new StudentsSpecialties("PHP Developer", 123134)
            };

            List <Student> students      = SampleStudents.GetSampleStudents();
            var            studentsGroup =
                from specialty in specialties
                join student in students
                on specialty.FacNum equals student.FacultyNumber
                select new { Name = student.FirstName + " " + student.LastName, FacNum = specialty.FacNum, Specialty = specialty.SpecialtyName };

            foreach (var student in studentsGroup)
            {
                Console.WriteLine("name: {0}, f num: {1}, specialty: {2}", student.Name, student.FacNum, student.Specialty);
            }
        }
예제 #11
0
        static void Main(string[] args)
        {
            List <Student> students = SampleStudents.GetSampleStudents();

            students.GetWeak();
        }