이 두 쿼리의 출력 인 combo1과 combo2를 결합하려고합니다. 이 두 linq 쿼리의 출력을 결합하는 방법?
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.ParallelQuery'
오류 3 '시스템>에>'System.Linq.IQueryable '에서 변환 할 수 없습니다 .Linq.IQueryable 'Union'에 대한 정의 및 최상의 확장 메서드 오버로드가 없습니다. 'System.Linq.ParallelEnumerable.Union (System.Linq.ParallelQuery, System.Collections.Generic.IEnumerable)'에 잘못된 인수가 있습니다.
내가 틀린데이 두 쿼리를 성공적으로 결합하려면 어떻게해야합니까?
무엇 출력의 종류는 당신이 기대하는 - 당신은 두 가지 유형의 컬렉션을 결합하고 있습니까? – Paddy
내가 막 말하고 싶었지만 어쩌면 나는 무식하지만 Union의 두 가지 유형의 콜렉션을 할 수 없습니까? – dgarbacz
그래, 네가 노조를 할 수 없다는 걸 알기 때문에 다른 길은 어떨까? – Obvious