0

I am new in LINQ queries and I need help to convert my sample SQL query to LINQ lambda query

select * from GRecommendations 
inner join GSections
on GRecommendations.GSectionId = GSections.Id
where GSections.GaId = 646
2
  • We're not here to convert code for you. If you tried and you got stuck somewhere you're more than welcome to tell where specifically you need help. One obvious advice: don't join in LINQ, use navigation properties. Commented Sep 27, 2017 at 13:11
  • YES SIR YOU 'R RIGHT Commented Oct 16, 2017 at 4:31

1 Answer 1

2

There are two different methods you can use when GRecommendations is a collection.

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*/ }
   );  //

or

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*/}
);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.