我在一个类中创建了一个类,因此它可以替代编写调用数据库的 3 个不同方法 - 所以我创建了一个包含相关项目的类,现在当我尝试构建时,我得到错误
Cannot implicity convert type System.collections.generic.list<anonymousType#1> to class that i created StudentDocuments
,当我点击错误时将我引向return subs
声明。
public class StudentDocuments
{
public Guid DocID {get; set;}
public string Assignment {get; set;}
public DateTime Submitted {get; set;}
public string Student {get;set;}
}
public StudentDocuments GetStudentSubmissionGrid(Guid usr, Guid lib)
{
using (var dc = new DocMgmtDataContext())
{
var subs = (from doc in dc.Documents
join u in dc.Users on doc.OwnedByUserID equals u.ID
where doc.OwnedByUserID == usr && doc.LibraryID == lib
select new {
DocID = doc.ID,
Assignment = doc.Library.Name,
Submitted = doc.UploadDT,
Student = u.FullName
})
.OrderByDescending(c => c.Submitted).ToList();
return subs;
}
}