public IList <SubjectVM> GetSubjectList() { List <SubjectVM> SubList = new List <SubjectVM>(); using (StudentsEntities context = new StudentsEntities()) { var result = context.SubjectList().ToList(); foreach (var item in result.ToList()) { SubList.Add(new SubjectVM { SubjectId = item.SubjectId, SubjectName = item.SubjectName }); } return(SubList); } }