I am using LINQ in my project and my code is:
var SE = from c in Shop.Sections
join c1 in obj.SectionObjects on c.SectionId equals c1.Sec
This should work and be done on the database side (using IN
), rather than in memory:
var SE = from c in Shop.Sections
where obj.SectionObjects.Select(z => z.SectionId).Contains(c.SectionId)
select c;
L2S Profiler is very helpful for these kinds of things - you can compare the different SQL being generated by my solution and other solutions.