2017-09-27 4 views
0

람다 LINQ 쿼리에 가입 변환하는 방법 조회하고 난 당신이 때 사용할 수있는 두 가지 방법이 있습니다SQL 내부 내가 LINQ에 새로운 오전

select * from GRecommendations 
inner join GSections 
on GRecommendations.GSectionId = GSections.Id 
where GSections.GaId = 646 
+0

우리는 당신을 위해 코드를 변환 여기 아니에요. 당신이 시도하고 어딘가에 갇혀 있다면 당신은 도움이 필요한 곳을 구체적으로 말할 수있는 것 이상입니다. 한 가지 분명한 조언 : 탐색 속성을 사용하여 LINQ에 '가입'하지 마십시오. –

+0

예. 당신 오른쪽예요. –

답변

2

LINQ 람다 쿼리에 내 샘플 SQL 쿼리를 변환하는 데 도움이 필요 GRecommendations는 컬렉션입니다.

var arrResult = //UNTESTED 
    GRecommendations 
    .Join(GSections.Where(sec => sec.GaId.Equals(646)), 
    rec => rec.GeSectionId, 
    sec => sec.Id, 
    (REC, SEC) => new { /*put here what you want selected*/ } 
    ); // 

또는

var arrResult = 
(
    from rec in GRecommendations 
    join rec in GSections.Where(s => s.GaId.Equals(646)) on rec.GSectionId equals sec.GaId 
    select new {/*rec.something*/, /*sec.something*/} 
);