Ejemplo n.º 1
0
        public IEnumerable <StudentAndMajor> GetStudentWithMajor()
        {
            var majCtrl  = new MajorsController(Connection);
            var students = from s in GetAll()
                           join m in majCtrl.GetAll()
                           on s.MajorId equals m.Id into sm
                           from s2 in sm.DefaultIfEmpty()
                           select new StudentAndMajor {
                Id       = s.Id,
                Fullname = $"{s.Firstname} {s.Lastname}",
                Major    = s2?.Description ?? "Undeclared"
            };

            return(students);
        }
Ejemplo n.º 2
0
        public IEnumerable <StudentAndMajor> GetStudentWithMajor()
        {
            var students     = GetAll();
            var majorCtrl    = new MajorsController(Connection);
            var studentMajor = from s in students
                               join m in majorCtrl.GetAll()
                               on s.MajorId equals m.Id
                               select new StudentAndMajor
            {
                Id       = s.Id,
                Fullname = $"{s.Firstname} {s.Lastname}",
                Major    = m.Description
            };

            return(studentMajor);
        }