Tôi có lớp sau:Không thể thực hiện kiểu XYZ với một initializer bộ sưu tập vì nó không thực hiện 'System.Collections.Ienumerable'
public class CommentList
{
string ItemType;
string Comment1;
string Status1;
string DiscussionBoardId;
Guid CourseId;
Guid CommentID;
}
Tôi đang cố gắng để làm báo cáo kết quả LINQ sau:
List<CommentList> query=
from c in db.Comments
join s in db.Status on c.StatusId equals s.StatusId
join d in db.DiscussionBoards
on c.DiscussionBoardId equals d.DiscussionBoardId
where d.CourseId=="CourseID"
orderby d.ItemType, d.DiscussionBoardId
select new CommentList {
d.ItemType,
c.Comment1,
s.Status1,
c.DiscussionBoardId,
d.CourseId,
c.CommentID
};
Vấn đề là, trình chỉnh sửa đang khiếu nại trên dấu ngoặc đơn đầu tiên của câu lệnh chọn. Nó nói rằng:
Không thể triển khai loại 'CommentList' bằng trình khởi tạo bộ sưu tập vì nó không triển khai 'System.Collections.IEnumerable'.
Ai đó có thể giúp tôi và cho tôi biết tôi đang làm gì sai?
Bắt tốt, Jeffery! Cho đến khi tôi đặt các thuộc tính thành Công khai, nó sẽ không hoạt động. Cảm ơn! – Kevin
Đặt các thuộc tính rõ ràng là những gì đã giúp tôi, cảm ơn. –