Example #1
0
        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();
                }
            }
        }
Example #2
0
 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());
 }
Example #3
0
 static List <Student> StudentSelectOuderDanNegentien(StudentContext context)
 {
     return(context.Students.Where(s => s.Leeftijd > 19).ToList()); //Ouder dan 19 list
 }
Example #4
0
 static List <Student> StudentOrderByLeeftijd(StudentContext context)
 {
     return(context.Students.OrderBy(s => s.Leeftijd).ToList()); //Ordered op achternaam ascending
 }