我正在尝试这个查询:
public ActionResult Index()
{
var topics = from t in db.Topics
join subs in db.Subjects on t.SubID equals subs.SubID
join mems in db.Members on t.MemberID equals mems.MemberID
select new ViewModel
{
TopicID = t.TopicID,
TDate = t.TDate,
Title = t.Title,
FileName = t.FileName,
Displays = t.Displays,
Description = t.Description,
SubName = subs.SubName,
FLName = mems.FLName
};
return View(topics);
}
但它会导致以下错误:
无法在 LINQ to Entities 查询中构造实体或复杂类型“MySiteModel.ViewModel”。
我有一个具有上述字段的实体类。问题是什么????