<?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 : OnFetching</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : OnFetching</description>
  <pubDate>Sat, 11 Apr 2026 22:51:25 -700</pubDate>
  <lastBuildDate>Mon, 01 Jun 2009 13:27:44 -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=1274</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>OnFetching : Upon further review of the code,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4687#4687</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=51" rel="nofollow">eileenv</a><br /><strong>Subject:</strong> 1274<br /><strong>Posted:</strong> 01-Jun-2009 at 1:27pm<br /><br />Upon further review of the code, there is actually a good reason why the Query object is not modifiable in the Fetching event on the client-side. The reason is that the original query you submitted on the client may not be the same query you get in the Fetching event, because the query in the latter may be a "reduced" version of the query.<DIV></DIV><DIV>&nbsp;</DIV><DIV>Say for example your original query was "Get me all the Customers who reside in the USA". And&nbsp;let's say there are a total of 100 customers that satisfy the query. If there are 20 customers already residing in the cache, then the query in the Fetching event will be <EM>reduced </EM>to fetch just the remaining 80 customers. In this case, the original query is not the same as the query in the Fetching event, and modifying this query would be a bad idea.</DIV><DIV>&nbsp;</DIV><DIV>In our upcoming release (v5.1.1), we will provide a new event for modifying the query: <strong>EntityManager.Querying</strong>. The Querying event will fire before the EntityManager queries data from an EntityServer. Note that cache-only queries or optimized queries that are handled by the client will not go thru this handler. </DIV><DIV>&nbsp;</DIV><DIV>Here's an example of how it might be used:</DIV><DIV>&nbsp;</DIV>&nbsp;&nbsp;&nbsp; public void QueryModifyQuery() {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _em1.Querying += (s, e) =&gt; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var query = e.Query as EntityQuery;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (query != null) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var newQuery = query.Filter((IQueryable&lt;Customer&gt; q) =&gt; q.Where(c =&gt; c.Country == "USA"));<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.Query = newQuery;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var custs = _em1.Customers.Take(7).ToList();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assert.IsTrue(custs.All(c =&gt; c.Country == "USA"));<BR>&nbsp;&nbsp;&nbsp; }<DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Mon, 01 Jun 2009 13:27:44 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4687#4687</guid>
  </item> 
  <item>
   <title>OnFetching : OK, coolThanks </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4674#4674</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=504" rel="nofollow">ouelletf</a><br /><strong>Subject:</strong> 1274<br /><strong>Posted:</strong> 28-May-2009 at 1:05pm<br /><br />OK, cool<br><br>Thanks<br>]]>
   </description>
   <pubDate>Thu, 28 May 2009 13:05:58 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4674#4674</guid>
  </item> 
  <item>
   <title>OnFetching : We will address theissue about...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4673#4673</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=51" rel="nofollow">eileenv</a><br /><strong>Subject:</strong> 1274<br /><strong>Posted:</strong> 28-May-2009 at 11:56am<br /><br /><DIV>We will address the&nbsp;issue about not being able to set the Query object involved in the EntityManager.Fetching event in our upcoming release (v5.1.1). This means you will be able to set the Query object&nbsp;in the client-side handler just as you would in the&nbsp;server-side handler.</DIV><span style="font-size:10px"><br /><br />Edited by eileenv - 29-May-2009 at 9:49am</span>]]>
   </description>
   <pubDate>Thu, 28 May 2009 11:56:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4673#4673</guid>
  </item> 
  <item>
   <title>OnFetching : Yes, no problem on this part.But...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4660#4660</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=504" rel="nofollow">ouelletf</a><br /><strong>Subject:</strong> 1274<br /><strong>Posted:</strong> 27-May-2009 at 10:57am<br /><br />Yes, no problem on this part.<br><br>But if you check the code executed by Filter()<br>You will see that if the Query isnt a ServerEntityQuery it return a Clone of it instead of modifying the "this" query and returning it.&nbsp; I find this behavior strange and "hard" to predict. I think it should alwasy return a clone, or always this, not sometimes one, and other times the other (my two cents).<br><br>And there is no way to change the args.Query for the new one returned by Filter()<br><br>Ive done it implementing IEntityServerFetching, but I prefer to override it in my manager.<br>The EventArgs provided by IEntityServerFetching.OnFetching allow write on the Query property.<br>Maybe I fail to see the purpose of doing in another class and being able to change it by configuration file.<br><br>]]>
   </description>
   <pubDate>Wed, 27 May 2009 10:57:40 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4660#4660</guid>
  </item> 
  <item>
   <title>OnFetching : You should be able to modify the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4656#4656</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=51" rel="nofollow">eileenv</a><br /><strong>Subject:</strong> 1274<br /><strong>Posted:</strong> 27-May-2009 at 10:11am<br /><br /><P>You should be able to modify the query passed into your Fetching handler as long as you cast it first to an EntityQuery. For example:</P><DIV>&nbsp;&nbsp;&nbsp; void OnFetching(object sender, EntityFetchingEventArgs e) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; EntityQuery q = e.Query as EntityQuery;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; q.Filter(...);<BR>&nbsp;&nbsp;&nbsp; }</DIV>]]>
   </description>
   <pubDate>Wed, 27 May 2009 10:11:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4656#4656</guid>
  </item> 
  <item>
   <title>OnFetching : I am trying to filter out some...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4597#4597</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=504" rel="nofollow">ouelletf</a><br /><strong>Subject:</strong> 1274<br /><strong>Posted:</strong> 21-May-2009 at 1:13pm<br /><br />I am trying to filter out some entities with OnFetching in the EntityManager<br><br>I use the Filter method on EntityQuery to add a filter.<br><br>But I can't set the new query.<br><br>args.Query is read-only.<br><br>Filter() return a new one if your query is a simple EntityQuery<br>And it modify the query, if it is a ServerQuery.<br><br>]]>
   </description>
   <pubDate>Thu, 21 May 2009 13:13:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1274&amp;PID=4597#4597</guid>
  </item> 
 </channel>
</rss>