0
두 테이블이 있습니다. EndToEnd 및 PartPort. EndToEnd에서 같은 행의 PartPortA와 PartportB 데이터를 가져오고 Partport를 쿼리하여 Partport 테이블의 모든 행에있을 수있는 Partport에서 해당 PartGid를 가져오고 싶습니다. 지금까지이 작업을 수행 할 수 있었지만 두 가지 다른 LINQ 호출을 수행해야하지만 한 가지로 줄이고 싶습니다.두 테이블과 여러 열을 결합하는 C# Linq 문
이 var part_portGid_a_results = (from icp in entities.EndToEnd
where icp.IntertPortGidA != null &&
icp.IntertPortGidB != null
join ica in entities.PartPort
on icp.PartPortA && icp.PartPortB equals ica.PortGid
select new { icp.PartPortA, ica.PartGid, }).ToList();
내가 오류는 다음과 같습니다 :
Guid? EndToEnd.PartPortB
Error:
Operator '&&' cannot be applied to operands of type 'System.Guid' and 'System.Guid?'
내가하고 싶은, 내가 이미 시도했지만 오류를 가지고 무엇
// this demonstrates how to join two tables, however only works for one AssetportGid at a time
var part_portGid_a_results = (from icp in entities.EndToEnd
where icp.IntertPortGidA != null &&
icp.IntertPortGidB != null
join ica in entities.PartPort
on icp.PartPortA equals ica.PortGid
select new { icp.PartPortA, ica.PartGid, }).ToList();
var part_portGid_b_results = (from icp in entities.EndToEnd
where icp.IntertPortGidA != null &&
icp.IntertPortGidB != null
join ica in entities.PartPort
on icp.PartPortB equals ica.PortGid
select new { icp.PartPortA, ica.PartGid, }).ToList();
return Json(part_portGid_a_results, JsonRequestBehavior.AllowGet);
이 있습니다 : 여기 내 코드입니다
하여 행을 연결 올바른지, 유효한 부울식이 아닙니다. icp.PartPortA는 부울이 아니기 때문에 Guid입니다. 두 컬럼에 합류하려고하십니까? 그런 다음이 대신 시도하십시오 : "on icp.PartPortA ica.PortGid 같음 && icp.PartPortB 같음 ica.PortGid" – HaukurHaf
Intellisense doesnt는 그 것처럼 보입니다 – DeeTee
아마도 하나는 nullable guid이고 다른 하나는 그렇지 않습니다 ... (.Value 사용 nullable guid) – HaukurHaf