<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : Need help with Join in Lambda expression.</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Need help with Join in Lambda expression.</description>
  <pubDate>Wed, 29 Jul 2026 12:18:50 -700</pubDate>
  <lastBuildDate>Wed, 12 Jan 2011 12:06:25 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2424</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>Need help with Join in Lambda expression. : Hi Bill,  try:  var records...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9631#9631</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2424<br /><strong>Posted:</strong> 12-Jan-2011 at 12:06pm<br /><br /><DIV>Hi Bill,</DIV><DIV>&nbsp;</DIV><DIV>try:</DIV><DIV>&nbsp;</DIV><DIV>var records = from m in Mgr.Members </DIV><DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from jH in Mgr.JobHistories</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where m.SocSecNo == jH.SocSecNo</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; jH.TSFinish == null</DIV><DIV>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select m;</DIV><DIV>&nbsp;</DIV><DIV>or</DIV><DIV>&nbsp;</DIV><DIV>var records = mgr.Members<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .SelectMany(jH =&gt; mgr.Jobhistories, (m, jH) =&gt; new {&nbsp;m = m,&nbsp;jH =&nbsp;jH })<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Where((w) =&gt; (w.m.SocSecNo == w.jH.SocSecNo &amp;&amp; w.jH.TSFinish== null))<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Select(m =&gt; m.m);</DIV><DIV>&nbsp;</DIV><DIV>note that in the latter you will want to have only Distinct results.</DIV><DIV>&nbsp;</DIV><DIV>Silvio.</DIV></DIV>]]>
   </description>
   <pubDate>Wed, 12 Jan 2011 12:06:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9631#9631</guid>
  </item> 
  <item>
   <title>Need help with Join in Lambda expression. :  var records = Mgr.Members .Where(m...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9594#9594</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2424<br /><strong>Posted:</strong> 07-Jan-2011 at 4:53pm<br /><br /><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><P></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> records = Mgr.Members</P><P>.Where(m =&gt; m.Status == </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"A"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> &amp;&amp; m.DuesRate &gt; 0 &amp;&amp; m.DuesDeduction == </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"Y"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>)</P><P>.Join(Mgr.JobHistories, m =&gt; m.SocSecNo, jh =&gt; jh.SocSecNo, (m, jh) =&gt; </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>new</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> { members = m })</P><P>.Select(m =&gt; m)</P><P>.ExecuteAsync();</P><DIV></DIV><DIV></DIV>so how can I add the Jobhistory to the where clause. I need to search for jh.TSFinish is null in addition to the above where criteria.<DIV></DIV></FONT></FONT>]]>
   </description>
   <pubDate>Fri, 07 Jan 2011 16:53:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9594#9594</guid>
  </item> 
  <item>
   <title>Need help with Join in Lambda expression. : Hi Bill,   What&amp;#039;s the result...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9593#9593</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2424<br /><strong>Posted:</strong> 07-Jan-2011 at 1:45pm<br /><br /><P>Hi Bill, </P><DIV>&nbsp;</DIV><DIV>What's the result you are trying to retrieve from the query? (Members?, JobHistories?, JobSites?, a projection with more than one entity type?)</DIV><DIV>&nbsp;</DIV><DIV>Below is a simple&nbsp;example returning Members</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><DIV>&nbsp;</DIV><DIV>.var records = Mgr.Members</DIV><DIV>.Where(m =&gt; m.Status == </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"A"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> &amp;&amp; m.DuesRate &gt; 0 &amp;&amp; m.DuesDeduction == </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"Y"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>)</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><strong>//.Select(m =&gt; m)</strong></FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><strong></strong></FONT></FONT>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><strong>.Join(Mgr.JobHistories</strong></FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><strong>&nbsp; , m =&gt; m.SocSecNo, jH =&gt; SocSecNo</strong></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><strong>&nbsp; ,(m, jH) =&gt; new {members = m})</strong></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><strong>.Select(m = m.members)</strong></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas></FONT>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.ExecuteAsync();</FONT></FONT></DIV><DIV>&nbsp;</DIV><DIV>You mentioned that you need to do a Join Member and JobHistory (the example above describes it) and a Join on JobHistory and JobSite. </DIV><DIV>Do you want all this joins in one query? Or are they separate queries? </DIV><DIV>Also, note that for your Join between JobHistory and JobSite,where you have 2 conditions, (EmployerNo and JobSiteNo) using query comprehension syntax might actually be simpler:</DIV><DIV>&nbsp;</DIV><DIV>var query = from&nbsp;jH in mgr.JobHistories<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; from&nbsp;jS in mgr.JobSites<BR>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; where jH.EmployerNo == jS.EmployerNo<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;&amp; jH.JobSiteNo == jS.JobSiteNo<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select new {&nbsp;JobHistory = jH,&nbsp;JobSite =&nbsp;jS };</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV></DIV>]]>
   </description>
   <pubDate>Fri, 07 Jan 2011 13:45:56 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9593#9593</guid>
  </item> 
  <item>
   <title>Need help with Join in Lambda expression. : Here is my linq statement so far.  var...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9584#9584</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2424<br /><strong>Posted:</strong> 06-Jan-2011 at 10:45pm<br /><br />Here is my linq statement so far.<DIV>&nbsp;</DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><P>var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> records = Mgr.Members</P><P>.Where(m =&gt; m.Status == </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"A"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> &amp;&amp; m.DuesRate &gt; 0 &amp;&amp; m.DuesDeduction == </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"Y"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>)</P><DIV>.Select(m =&gt; m)</DIV><P>.ExecuteAsync();</P><DIV>&nbsp;</DIV><DIV><DIV></DIV>Now I need to add a .Join() statement. I need to join Member&nbsp; on SocSecNo to JobHistory on SocSecNo</DIV><DIV></DIV>and (JobHistory&nbsp;to JobSite on both EmployerNo and JobSiteNo)<DIV></DIV><DIV>&nbsp;</DIV><DIV>Thanks</DIV><DIV>Bill</DIV><DIV>&nbsp;</DIV></FONT></FONT>]]>
   </description>
   <pubDate>Thu, 06 Jan 2011 22:45:10 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2424&amp;PID=9584#9584</guid>
  </item> 
 </channel>
</rss>