<?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 : Include() and FirstOrNullEntity()</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Include() and FirstOrNullEntity()</description>
  <pubDate>Sun, 12 Apr 2026 16:15:18 -700</pubDate>
  <lastBuildDate>Mon, 31 Jan 2011 17:08:23 -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=2475</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>Include() and FirstOrNullEntity() : Glad you found the issue. Thanks...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9851#9851</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> 2475<br /><strong>Posted:</strong> 31-Jan-2011 at 5:08pm<br /><br /><P>Glad you found the issue.</P><DIV>Thanks for the update.</DIV><DIV>&nbsp;</DIV><DIV>Silvio.</DIV>]]>
   </description>
   <pubDate>Mon, 31 Jan 2011 17:08:23 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9851#9851</guid>
  </item> 
  <item>
   <title>Include() and FirstOrNullEntity() : Figured it out; types were not...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9850#9850</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=101" rel="nofollow">JulianBenjamin</a><br /><strong>Subject:</strong> 2475<br /><strong>Posted:</strong> 31-Jan-2011 at 4:53pm<br /><br />Figured it out; types were not the same (char15 vs varchar15); after setting the types to be the same, it worked correctly.]]>
   </description>
   <pubDate>Mon, 31 Jan 2011 16:53:19 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9850#9850</guid>
  </item> 
  <item>
   <title>Include() and FirstOrNullEntity() : I&amp;#039;m unable to reproduce with...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9847#9847</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=101" rel="nofollow">JulianBenjamin</a><br /><strong>Subject:</strong> 2475<br /><strong>Posted:</strong> 31-Jan-2011 at 1:37pm<br /><br />I'm unable to reproduce with the NorthwindIB database.&nbsp; I selected an InternationalOrder with an Include("Order") and got the first entity and pulling the Order record was fine.&nbsp; My model had a similar association key (as400_itemex01 always has a record, but there may not be a b2b_product record for it).<DIV></DIV><DIV></DIV><DIV>&nbsp;</DIV><DIV>I'm going to check more and try to narrow it down.</DIV>]]>
   </description>
   <pubDate>Mon, 31 Jan 2011 13:37:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9847#9847</guid>
  </item> 
  <item>
   <title>Include() and FirstOrNullEntity() : Hi JulianBenjamin,  I was not...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9846#9846</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> 2475<br /><strong>Posted:</strong> 31-Jan-2011 at 12:42pm<br /><br />Hi JulianBenjamin,<DIV>&nbsp;</DIV><DIV>I was not able to reproduce your issue.</DIV><DIV>Here's a simple test I ran against NorthwindIB:</DIV><DIV>&nbsp;</DIV><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>public</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </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>void</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> TestInclude() {</DIV><DIV><DIV></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> mgr = </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> </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>IdeaBladeTest1Entities</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>();</DIV><DIV></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> query = mgr.Employees.Where(e =&gt; e.EmployeeID == 1).Include(</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>"Orders"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>);</DIV><DIV></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> employee = query.FirstOrNullEntity();</FONT></FONT></DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas></FONT></FONT></FONT></FONT></FONT>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas>// all orders belonging to employee are loaded into cache</DIV><DIV><DIV></FONT></FONT></FONT></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> orders = mgr.Orders.With(</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>QueryStrategy</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.CacheOnly).Where(e =&gt; e.EmployeeID == 1).ToList();</DIV></DIV><DIV>}</FONT></FONT></DIV></DIV><DIV>&nbsp;</DIV><DIV>Can you provide a simple solution (against NorthwindIB)&nbsp;reproducing your issue?</DIV><DIV>&nbsp;</DIV><DIV>Regards,</DIV><DIV>Silvio.</DIV>]]>
   </description>
   <pubDate>Mon, 31 Jan 2011 12:42:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9846#9846</guid>
  </item> 
  <item>
   <title>Include() and FirstOrNullEntity() : When using the Include function,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9840#9840</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=101" rel="nofollow">JulianBenjamin</a><br /><strong>Subject:</strong> 2475<br /><strong>Posted:</strong> 30-Jan-2011 at 12:25pm<br /><br />When using the Include function, the FirstOrNullEntity doesn't fetch the included items; additionally, it seems it thinks it has queried for the related items, and so returns a nullentity for related entities even though removing the Include and then navigating the references triggers a query and returns the correct data.<DIV>&nbsp;</DIV><DIV>Is this a bug?&nbsp; my code is as follows:</DIV><DIV>&nbsp;</DIV><DIV><strong><DIV>EntityQuery</strong>&lt;<strong>b2b_product</strong>&gt;<strong> query </strong>=</DIV><strong><DIV>(EntityQuery</strong>&lt;<strong>b2b_product</strong>&gt;<strong>)</DIV><DIV>BusinessGlobals</strong>.<strong>b2bEntityManager</strong>.<strong>b2b_product</strong>.<strong>Where(p </strong>=&gt;<strong> p</strong>.<strong>item_number </strong>==<strong> ItemNumber)</strong>.<strong>Include("as400_itemex01");</DIV><DIV></DIV><DIV>return query</strong>.<strong>FirstOrNullEntity();</DIV></strong></DIV><DIV>&nbsp;</DIV><DIV>I've also tried the suggestion from this thread (<a href="http://www.ideablade.com/forum/forum_posts.asp?TID=2430" target="_blank">http://www.ideablade.com/forum/forum_posts.asp?TID=2430</A>) and it's still not returning items.</DIV>]]>
   </description>
   <pubDate>Sun, 30 Jan 2011 12:25:07 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2475&amp;PID=9840#9840</guid>
  </item> 
 </channel>
</rss>