public string GetGradesBySubject(string jsonString) { var subject_id = JsonConvert.DeserializeObject <GetID>(jsonString); var sub = db.GetSubject(subject_id.ID); var model = sub.Class.Person.Select(p => new GradesBySubject(p.Grade.Where(d => d.Subject.ID_Subject == sub.ID_Subject).ToList()) { StudentName = p.FirstName + " " + p.LastName }); return(JsonConvert.SerializeObject(model)); }