static void Main() { StudentDirectory database = new StudentDirectory(); var studentsEnrolled = from student in database.Students where ((student.FacultyNumber / 1000) % 100) == 14 select student; Print.PrintStudentsInfo(studentsEnrolled); }
static void Main() { StudentDirectory database = new StudentDirectory(); var sortWeakStudents = database.Students.SortWeakStudents(); foreach (var student in sortWeakStudents) { Console.WriteLine(student.FirstName + " "+ string.Join(" ", student.Marks)); } }
static void Main() { StudentDirectory database = new StudentDirectory(); var exellentStudents = from student in database.Students where student.Marks.Contains(6) select new { fullName = string.Join(" ", student.FirstName, student.LastName), marks = string.Join(" ", student.Marks) }; foreach (var student in exellentStudents) { Console.WriteLine("Name: {0} , Grades: {{{1}}}", student.fullName, student.marks); } }
public static void Main() { StudentDirectory studentDB = new StudentDirectory(); SpecialtyDirectory specialtyDB = new SpecialtyDirectory(); var specialtyQ = from student in studentDB.Students orderby student.FirstName ascending, student.LastName ascending join specialty in specialtyDB.specialies on student.FacultyNumber equals specialty.FacultyNumber select new { student.FirstName, student.LastName, student.FacultyNumber, specialty.SpecialtyName }; foreach (var student in specialtyQ) { Console.WriteLine("{0} {1} {2} {3}", student.FirstName, student.LastName, student.FacultyNumber, student.SpecialtyName); } }
static void Main() { StudentDirectory database = new StudentDirectory(); var studentByGroupsQuery = from student in database.Students group student by student.GroupName into specialties select specialties; foreach (var group in studentByGroupsQuery) { Console.WriteLine("{0}",group.Key); foreach (var student in group) { Console.WriteLine("{0} {1} {2}",student.FirstName, student.LastName, student.FacultyNumber); } } }
static void Main(string[] args) { StudentDirectory dB = new StudentDirectory(); string pattern = @"(?<=\w\@)abv\.bg?()"; Regex rgx = new Regex(pattern); var abv = dB.Students.Where(email => rgx.IsMatch(email.Email)); var abvEmails = from student in dB.Students where rgx.IsMatch(student.Email) select student; Console.WriteLine("Lambda"); foreach (var student in abv) { Console.WriteLine("{0} {1} {2}",student.FirstName, student.LastName, student.Email); } Console.WriteLine(); Console.WriteLine("LINQ""); foreach (var student in abvEmails) { Console.WriteLine("{0} {1} {2}", student.FirstName, student.LastName, student.Email); } }
public static void Main() { StudentDirectory database = new StudentDirectory(); database.Students.PrintStudentsInfo(); }
static void Main() { StudentDirectory database = new StudentDirectory(); var sortByPhone = database.Students.SortByPhone(); Print.PrintStudentsInfo(sortByPhone); }
public static void Main() { StudentDirectory database = new StudentDirectory(); var studentsByNames = database.Students.StudentsByNames(); PrintStudentsByNames(studentsByNames); }
public static void Main() { StudentDirectory database = new StudentDirectory(); var studentsByAge = database.Students.StudentsByAge(); PrintStudentsByAge(studentsByAge); }