Linq to sql left outer join?

Thanks for the answer, but I don't see how that helps... I only started using linq to sql last week and am still baffled by most of it. – user643192 Jul 28 at 1:42 There's an example in the 101 samples: msdn.microsoft. Com/en-us/vcsharp/ee908647#leftouterjoin.In your case if your just learning, I would recommend using the LINQ syntax over Lambda syntax.

IQueryable menuItems = from section in visibleSections join joindivision in visibleDivisions on section. SectionID equals joindivision. SectionID into joined from division in joined.DefaultIfEmpty() select new { section.

Section_ID, section. Section_Name, division. Division_ID, division.

Division_Name) }); (Of course, you could grab a copy of LINQ in Action and check chapter 6 as well) – Jim Wooley Jul 28 at 2:06 Thanks your two comments put me on the right track and I solved it. In linq syntax as you said. I'm posting my query for future reference, but marking this as answer since I wouldn't have got it otherwise.

Thanks! – user643192 Jul 28 at 2:39.

Ended up doing this in linq syntax as recommended by Jim Wooley. I got the query working with the following syntax: IQueryable visibleSections = from section in db. Teikoku_Sections where section.

Show_In_Menu select section; IQueryable visibleDivisions = from division in db. Teikoku_Divisions where division. Show_In_Menu select division; IQueryable menuItems = from section in visibleSections join division in visibleDivisions on section.

Section_ID equals division. Section_ID into joined_SectionDivision from menuItem in joined_SectionDivision.DefaultIfEmpty() select new { Section_ID = section. Section_ID, Section_Name = section.

Section_Name, Division_ID = (menuItem == null)? Null : (int? )menuItem.

Division_ID, Division_Name = menuItem. Division_Name? Null }; It took me hours to finally get to this result, so here are a couple of explanations for anybody who might be in the same situation.

I don't want a simple left outer join, but a join with conditions on the items of both tables, i.e. Show_In_Menu being true for items in both tables, but not necessarily simultaneously, so a section can be visible, but it's divisions might not, in which case I want only the section in the results without any divisions to appear once in the results. For that reason I am creating two temp tables with just the visible section and division items and then performing the left outer join using these two sets of results.

One thing that got me puzzled for a while was the .DefaultIfEmpty() part, which is needed to deal with null joined items. Hope this helps somebody who is trying to do a left outer join someday.

Group Join o In db. Orders On e Equals o. From o In ords.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions