我想组合这两个查询的输出,combo1 和 combo2。按照现在,我可以编写如下代码:
var combo1 = from c in db.comments
join p in db.picture on c.targetpictureid equals p.idpictures
join u in db.users on c.iduser equals u.iduser
select new TCommentDTO
{
idcomments=c.idcomments,
comment1 = c.comment1,
targetpictureid = c.targetpictureid,
ctime = c.ctime,
iduofpic=p.iduser,
iduofcommentor=c.iduser,
profilepicofcommentor=u.profilepic,
usernameofcommentor=u.username,
picFilename=p.picFilename,
picTitle=p.picTitle
};
var combo2 = from f in db.followers
join u in db.users on f.iduser equals u.iduser
select new TfollowerDTO
{
idfollowers = f.idfollowers,
iduser = f.iduser,
targetiduser = f.targetiduser,
startedfollowing = f.startedfollowing,
unoffollower = u.username,
ppoffollower = u.profilepic,
status = u.status
};
var resultantcombo =combo1.Union(combo2);
return resultantcombo;
但是在我执行联合的倒数第二行,我收到了这些错误:
错误 1 无法将类型“System.Collections.Generic.IEnumerable”隐式转换为“System.Linq.IQueryable”。存在显式转换(您是否缺少演员表?)
错误 2 实例参数:无法从 >'System.Linq.IQueryable' 转换为 >'System.Linq.ParallelQuery'
错误 3 'System.Linq.IQueryable' 不包含 'Union' 的定义,并且最佳扩展方法重载 'System.Linq.ParallelEnumerable.Union(System.Linq.ParallelQuery, System.Collections.Generic.IEnumerable)' 有一些无效参数
我错了,我应该怎么做才能成功地结合这两个查询?