Ejemplo n.º 1
0
        public static void SearchStudentWithEntry(string firstmidname, EducationalContext context)
        {
            if (context.Students.Where(s => s.FirstMidName == firstmidname).FirstOrDefault() == null)
            {
                Console.WriteLine("No student found");
            }
            else
            {
                Student student = context.Students
                                  .Where(s => s.FirstMidName == firstmidname)
                                  .FirstOrDefault();

                context.Entry(student).Collection(e => e.Enrollments).Load();
                PrintStudent(student);
            }
        }
Ejemplo n.º 2
0
        public static void PrintAllStudentsWithEntry(EducationalContext context)
        {
            try
            {
                List <Student> students = context.Students.ToList();

                foreach (Student s in students)
                {
                    context.Entry(s).Collection(e => e.Enrollments).Load();
                    PrintStudent(s);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("message: " + e.Message);
                Console.WriteLine("inner exception messag: " + e.InnerException.Message);
            }
        }