I have an Entity Class called Session and it containts two attributes: LecturerOne and LectureTwo. I want to create a union of all the distinct names in LecturerOne and LecturerTwo:
I got just LecturerOne working.
public List<string> ListLecturer()
{
var lecturerNames = (from s in db.Sessions
select s.LecturerOne).Distinct();
List<string> lecturerList = lecturerNames.ToList();
return lecturerList;
}
One option:
I don’t know offhand how EF will treat that, but it’s worth a try…
Alternatively, similar to Jamiec’s answer but IMO simpler:
(
Unionalready returns distinct results, so there’s no need to do it explicitly.)