Selecting a left join default key with Linq (to SQL)?

Var restult = ( from p in Posts let localizedPost = ( from pl in LocalisedPosts where p. PostID == pl. PostID && (pl.

Culture == lang || pl. Culture == "en") let culturePriority = pl. Culture == lang?

0 : 1 orderby culturePriority select pl) .First() select new { p. PostID, p. PostDateTime, localizedPost.

LocalisedTitle, localizedPost. LocalisedBody } Assumed that for each post at least one localized post exists either en or lang.

Var restult = ( from p in Posts let localizedPost = ( from pl in LocalisedPosts where p. PostID == pl. PostID && (pl.

Culture == lang || pl. Culture == "en") let culturePriority = pl. Culture == lang?

0 : 1 orderby culturePriority select pl) .First() select new { p. PostID, p. PostDateTime, localizedPost.

LocalisedTitle, localizedPost. LocalisedBody }; Assumed that for each post at least one localized post exists either en or lang.

Well it certainly works, including the query translation. The generated SQL doesn't look too bad. Many thanks.

– Christopher Edwards Jun 21 at 3:57.

String lang = "fr" var LocalisedPosts = from p in Posts let anyWithCurrentLang = (Posts. Any(ps=>ps.LocalisedPost. Culture == lang)) join pl in LocalisedPosts on p.

PostID == pl. PostID where pl. Culture == lang || (pl.

Culture == "en" &&! AnyWithCurrentLang ) select new {p. PostID, p.

PostDateTime, pl. LocalisedTitle, pl. LocalisedBody}; Edited: I think I understand you now, edited the query to check if you have any post with current lang, if not then it'll search for english ones.

You might need to write a full blown query with from where join in the let statement, I assumed you have proper relationships set up already.

– Christopher Edwards Jun 21 at 3:06 I updated the question to try and make it clearer. – Christopher Edwards Jun 21 at 3:08.

Join pl in LocalisedPosts on p. PostID == pl. Culture == lang || (pl.

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