I have the following query expecting to retrieve only unique values from the entity according the selected School:
var semesters = (from cou in db.Courses
join sem in db.Semesters on cou.SemesterID equals sem.ID
where cou.FacultyID == id
select new SemestersModel {
SemesterID = sem.ID,
SemesterText = sem.Semester })
.Distinct()
.ToList();
However it returns all semesters contained in the entity Courses
- Semester 1, Semester 1, Semester 1, Semester 2, Semester 2 ...etc. etc.
Please help me to grab only distinct semester names e.g.
- Semester 1, Semester 2, etc.
P.S. my issue is different than this one Distinct in Linq based on only one field of the table