我正要建立一個DTO的數據列表。不能隱式轉換類型LINQ
return from p in db.Students.Find(Id).Courses
select new CourseDTO
{
Id = p.Id,
CourseName = p.CourseName
};
然而,當我用這個,我得到以下錯誤:
Cannot implicitly convert type
'System.Collections.Generic.IEnumerable<Storage.Models.CourseDTO>' to
'System.Collections.Generic.ICollection<Storage.Models.CourseDTO>'.
An explicit conversion exists (are you missing a cast?)
任何人都可以解釋,爲什麼?
顯示函數簽名.. –