// GET api/Students public IEnumerable <StudentModel> GetStudents() { DbStudentsRepository studentRepository = this.allRepositories.GetStudentsRepository(); var studentEntities = studentRepository.All(); var studentModels = from studEntity in studentEntities select new StudentModel() { Id = studEntity.Id, FirstName = studEntity.FirstName, LastName = studEntity.LastName, Age = studEntity.Age, Grade = studEntity.Grade, SchoolId = studEntity.School.Id }; return(studentModels.ToList()); }
// GET api/Students public IEnumerable <StudentModel> GetStudents(string subject, decimal value) { DbStudentsRepository studentRepository = this.allRepositories.GetStudentsRepository(); var studentEntities = studentRepository.All().Where(s => s.Marks.Any(m => (m.Subject == subject && m.Value > value))); var studentModels = from studEntity in studentEntities select new StudentModel() { Id = studEntity.Id, FirstName = studEntity.FirstName, LastName = studEntity.LastName, Age = studEntity.Age, Grade = studEntity.Grade, SchoolId = studEntity.School.Id }; return(studentModels.ToList()); }