static void AddInputStudenten(StudentContext context) { Console.Write("Wilt u records aanmaken?\n" + "Typ Ja of Nee: "); string input = Console.ReadLine().ToLower(); if (input == "ja") { Console.Write("Hoeveel records wilt u invullen?: "); int count = Int32.Parse(Console.ReadLine()); for (int i = 0; i < count; i++) { Console.Write("Student voornaam: "); string voornaam = Console.ReadLine(); Console.Write("Student achternaam: "); string achternaam = Console.ReadLine(); Console.Write("Student leeftijd: "); int leeftijd = Int32.Parse(Console.ReadLine()); Console.Write("Student geslacht (1 character): "); char geslacht = Console.ReadLine().ToCharArray()[0]; var student = new Student { Voornaam = voornaam, Achternaam = achternaam, Leeftijd = leeftijd, Geslacht = geslacht }; context.Add(student); context.SaveChanges(); Console.WriteLine(); } } }
static Object StudentOuderOfGelijkAanTwintigMetGeslacht(StudentContext context, char geslacht) { return(context.Students .Where(s => s.Geslacht == geslacht && s.Leeftijd >= 20) .Select(s => new { s.Voornaam, s.Achternaam }).ToList()); }
static List <Student> StudentSelectOuderDanNegentien(StudentContext context) { return(context.Students.Where(s => s.Leeftijd > 19).ToList()); //Ouder dan 19 list }
static List <Student> StudentOrderByLeeftijd(StudentContext context) { return(context.Students.OrderBy(s => s.Leeftijd).ToList()); //Ordered op achternaam ascending }