<?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 : IEnumerable named query with includes not working</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : IEnumerable named query with includes not working</description>
  <pubDate>Wed, 13 May 2026 06:27:03 -700</pubDate>
  <lastBuildDate>Mon, 16 Apr 2012 17:21:09 -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=3387</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>IEnumerable named query with includes not working :   Hi Roland,It turns out that...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13317#13317</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3387<br /><strong>Posted:</strong> 16-Apr-2012 at 5:21pm<br /><br />Hi Roland,<div><br></div><div>It turns out that this is not a bug. This is something that we just don't support. An Include can only work with an EntityQuery. We can, however, add this as a feature if we have more requests for this type of scenario in the future.</div><span style="font-size:10px"><br /><br />Edited by DenisK - 16-Apr-2012 at 5:46pm</span>]]>
   </description>
   <pubDate>Mon, 16 Apr 2012 17:21:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13317#13317</guid>
  </item> 
  <item>
   <title>IEnumerable named query with includes not working :  Yes, you&amp;#039;re correct. Of...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13304#13304</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3387<br /><strong>Posted:</strong> 13-Apr-2012 at 11:36am<br /><br />Yes, you're correct. Of course we want to check if base.ExecuteQuery succeeds or not.&nbsp;<div><br></div><div>Your suggestion of using EntityQuery.Tag is certainly another option. And yes, you can assign it a custom string and check the value on the server. I didn't suggest it since I was thinking you want to keep the named query call structure the same so you can easily remove the interceptor part if it turns out to be a bug and it's fixed.</div><span style="font-size:10px"><br /><br />Edited by DenisK - 13-Apr-2012 at 11:37am</span>]]>
   </description>
   <pubDate>Fri, 13 Apr 2012 11:36:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13304#13304</guid>
  </item> 
  <item>
   <title>IEnumerable named query with includes not working :  Hi Denis!Thanks for your help!I...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13297#13297</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1095" rel="nofollow">AuerRo</a><br /><strong>Subject:</strong> 3387<br /><strong>Posted:</strong> 13-Apr-2012 at 1:05am<br /><br />Hi Denis!<br><br>Thanks for your help!<br><br>I implemented the solution "Named queryable and using the EntityServerQueryInterceptor" and it works. I assume that your ExecuteQuery-mehtod should rather look like this:<br><pre ="bbcode"=""><div>&nbsp; <table width="99%"><tr><td><pre class="BBcode">protected override bool ExecuteQuery() {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //calls base.ExecuteQuery to execute and returns results</div><div>&nbsp; &nbsp; &nbsp; var baseQueryResult = base.ExecuteQuery();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //Do special calculations for your particular named query here<br>      if(baseQueryResult)<br></div><div>&nbsp; &nbsp; &nbsp;     PerformAdditionalCalculationsToCustomerResults();<br><br>      return baseQueryResult;<br></div><div>&nbsp; }</pre></td></tr></table></div></pre>Anyway, I'm not fully satisfied with this solution, as I'm force to tear one query into two parts. As the pattern of these queries is always the same (defaultquery + includes + where-constraint + entity-calculations) I was wondering, if I need the named query at all.<br><br>There is a Tag-property in every EntityQuery. Can I add a custom string value (eg: "ApplyCustomerCalculations") on the client as EntityQuery.Tag, check this Tag value on the server in the EntityServerQueryInterceptor.ExecuteQuery and start the same calculations? So I wouldn't need the named query, and everything stays in two places, not in three (means Client-Repository - ESQInterceptor and not Client-Repository - NamedQuery - ESQInterceptor).<br><br>Of course, overall, I'd prefer to be able to solve this in a named query only, so I'd rather hope this is a bug than a feature. ;)<br><br>Have a nice weekend<br>Roland<br><span style="font-size:10px"><br /><br />Edited by AuerRo - 13-Apr-2012 at 1:06am</span>]]>
   </description>
   <pubDate>Fri, 13 Apr 2012 01:05:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13297#13297</guid>
  </item> 
  <item>
   <title>IEnumerable named query with includes not working :  Hi Roland,I&amp;#039;m able to see...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13295#13295</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=912" rel="nofollow">DenisK</a><br /><strong>Subject:</strong> 3387<br /><strong>Posted:</strong> 12-Apr-2012 at 3:51pm<br /><br />Hi Roland,<div><br></div><div>I'm able to see the issue here. I'm going to check with a senior engineer to find out whether this is a bug or just a known limitation when returning an IEnumerable.&nbsp;</div><div><br></div><div>FYI, the Include works on the server, i.e. inside the named query, you can actually see that the included entities are being returned from the db to the server. They're just not being returned/serialized from the server to the client as well.</div><div><br></div><div>Since you must execute the calculations on the server, one suggestion is to return IQueryable, intercept the query results on the server and execute the calculations. This way you can keep the client side query call the same and not have to change anything there.</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div>public class MyQueryInterceptor : EntityServerQueryInterceptor {</div><div>&nbsp;&nbsp;protected override bool ExecuteQuery() {</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //calls base.ExecuteQuery to execute and returns results</div><div>&nbsp; &nbsp; &nbsp; base.ExecuteQuery();</div><div><br></div><div>&nbsp; &nbsp; &nbsp; //Do special calculations for your particular named query here</div><div>&nbsp; &nbsp; &nbsp; PerformAdditionalCalculationsToCustomerResults();</div><div>&nbsp; }</div><div>&nbsp;&nbsp;</div><div>&nbsp; private void PerformAdditionalCalculationsToCustomerResults() {</div><div>&nbsp; &nbsp; &nbsp; var entityQuery = this.Query as EntityQuery;</div><div><br></div><div>&nbsp; &nbsp; &nbsp; if (entityQuery != null &amp;&amp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; entityQuery.IsNamedQuery &amp;&amp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; entityQuery.NamedQueryMethod.Name.Contains("CustomerWithCalculations")) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (this.QueriedEntities.Any()) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; this.QueriedEntities.OfType&lt;Customer&gt;().ForEach(c =&gt; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;c.CalculateRevenue();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;c.CalculateOpenAmount();</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; });</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp;}</div><div>}</div><div></pre></td></tr></table></div><div><br></div><div>Another suggestion that does require you to change client side code is to use Remote Server Method. See&nbsp;<a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/rsmc-query" target="_blank">http://drc.ideablade.com/xwiki/bin/view/Documentation/rsmc-query</a>. This is just another option.</div><div><br></div><div>I'll keep you updated as to whether this is a bug or not.</div><span style="font-size:10px"><br /><br />Edited by DenisK - 12-Apr-2012 at 4:09pm</span>]]>
   </description>
   <pubDate>Thu, 12 Apr 2012 15:51:35 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13295#13295</guid>
  </item> 
  <item>
   <title>IEnumerable named query with includes not working : Hi,I have a named query returning...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13281#13281</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1095" rel="nofollow">AuerRo</a><br /><strong>Subject:</strong> 3387<br /><strong>Posted:</strong> 11-Apr-2012 at 7:55am<br /><br />Hi,<br>I have a named query returning IEnumerable&lt;T&gt; like this:<br><br><table width="99%"><tr><td><pre class="BBcode"><br><font face="Courier New, Courier, mono">public IEnumerable&lt;Customer&gt; GetCustomerWithCalculations()<br>{<br>&nbsp;&nbsp;&nbsp; var entities = new EntityQuery&lt;Customer&gt;()<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Include(Customer.PathFor(x =&gt; x.City.Region.Nation.Continent))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Where(x =&gt; x.Name.StartsWith("A"))<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; .Execute();<br><br>&nbsp;&nbsp;&nbsp; entities.ForEach(x =&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;{<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x.CalculateRevenue();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;x.CalculateOpenAmount();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;});<br><br>&nbsp;&nbsp;&nbsp; return entities;<br>}</font><br></pre></td></tr></table><br><br>Everything  except the include works as expected. If I change the named query to return IQueryable&lt;T&gt;, the include works as expected, but of course the ForEach has no effect. The calculations have to be on the server side, so in the end IQueryable&lt;T&gt; is no option.<br><br>I did not find anything like this mentioned in the docs, so I assume this is an error on my side. But I have no idea what to change that the include takes affect!<br><br>Thanks for any hint to solve this in advance!<br><br>Best regards, Roland<br>]]>
   </description>
   <pubDate>Wed, 11 Apr 2012 07:55:18 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3387&amp;PID=13281#13281</guid>
  </item> 
 </channel>
</rss>