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
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*/}
);
joinin LINQ, use navigation properties.