<?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 : Changing query before execution</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : Changing query before execution</description>
  <pubDate>Sat, 11 Apr 2026 09:51:08 -700</pubDate>
  <lastBuildDate>Thu, 02 Apr 2009 07:12:52 -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=1137</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>Changing query before execution :   Originally posted by smi-mark ...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4243#4243</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=485" rel="nofollow">jsobell</a><br /><strong>Subject:</strong> 1137<br /><strong>Posted:</strong> 02-Apr-2009 at 7:12am<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by smi-mark</strong></em><br /><br /><div>    <div>        &nbsp;&nbsp;&nbsp;&nbsp; public class BOSFetch : IEntityServerFetching<br>&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void OnFetching(IdeaBlade.EntityModel.v4.EntityServerFetchingEventArgs args)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (args.Query.QueryableType is ActiveEntity) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //In here you can cast the args.Query to an EntityQuery&lt;ActiveEntity&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //and then you are able to do .Where and all your other query functions.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>    </div></div></td></tr></table><br><br>Brilliant!&nbsp; Now where on earth do I put this?<br>I assume it's added to my Thingy.Web project, but it appears to have no effect there. How would it every get picked up? Does it go in an entity's partial class?<br><br>I'm interested in intercepting all client requests and filtering them based on our own per-entity permission set.<br>In Linq to SQL or Ria we would simply add a '.Where' to the .GetClients, but what would be the correct manner in DF?<br>I only installed this yesterday, so please explain in simple terms, and assume that I have not read the manual (which I have scanned through several times but not found a solution).<br>Also, how on earth does the Login feature work? How do I verify the login info?<br>If you could point me to any relevant doco that would be great, but the videos on the site are all covering pretty fundamental stuff, so the more technical customers could probably use a few more advanced ones :)<br>I'm using the SL version, just in case that makes a difference, and it looks excellent. <br><br>Cheers,<br>&nbsp;Jason<br>]]>
   </description>
   <pubDate>Thu, 02 Apr 2009 07:12:52 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4243#4243</guid>
  </item> 
  <item>
   <title>Changing query before execution : Thanks for the excellent response,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4069#4069</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1137<br /><strong>Posted:</strong> 13-Mar-2009 at 10:23am<br /><br />Thanks for the excellent response, Mark.<DIV>&nbsp;</DIV><DIV>Daniel, the documentation you reference is in fact outdated and we're getting it fixed.&nbsp; The EntityManager is not a partial class, and there's no&nbsp;reason you should have to override OnFetching here.&nbsp; As Mark stated, implementing IEntityServerFetching is the best way to go.&nbsp;&nbsp; There's also an EntityManager.Fetching event you can handle, but that would place your security logic within your client application.</DIV>]]>
   </description>
   <pubDate>Fri, 13 Mar 2009 10:23:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4069#4069</guid>
  </item> 
  <item>
   <title>Changing query before execution : I took &amp;#039;ActiveEntity&amp;#039;...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4066#4066</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=449" rel="nofollow">smi-mark</a><br /><strong>Subject:</strong> 1137<br /><strong>Posted:</strong> 13-Mar-2009 at 9:37am<br /><br />I took 'ActiveEntity' from your code snippet. It is any class you have, be it a single class, or a base class for multiple other entity objects. IdeaBlade looks for any classes implement IEntityServerFetching and calls that method.<br><br>This is what you could do,<br><br>1. Create an injected base type called 'MyBaseEntity' (Or a more meaningful name) using the object mapper and assign the tables that have that column to inherit from that base entity<br>2. In the onfetching instead of 'ActiveEntity' you can use 'MyBaseEntity' and do whatever processing logic you need<br>]]>
   </description>
   <pubDate>Fri, 13 Mar 2009 09:37:58 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4066#4066</guid>
  </item> 
  <item>
   <title>Changing query before execution : Thanks for the reply. But I was...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4065#4065</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=460" rel="nofollow">mrdaniel76</a><br /><strong>Subject:</strong> 1137<br /><strong>Posted:</strong> 13-Mar-2009 at 9:21am<br /><br />Thanks for the reply. But I was not able to follow it completely. What is ActiveEntity? It does not seem to resolve to anything.<DIV>&nbsp;</DIV><DIV>I tried adding a new .Where but it didn't work. Would you mind posting a more complete example? </DIV><DIV>&nbsp;</DIV><DIV>Also, how do I know if the entity being searched has a certain column so I can add the extra criteria? Not all entities in my solution will have the column in question.</DIV><DIV>&nbsp;</DIV><DIV>You seem to be creating a new class and implementing IEntityServerFetching, but I don't see anywhere in the developer's guide that references it. Is that a better way to my way of creating a partial class for the EntityManager and overriding the OnFetching method?</DIV><DIV>&nbsp;</DIV><DIV>Sorry for the newbie questions but I just started evaluating DevForce and this is one of the first requirements that I need to verify.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>Thanks a lot!</DIV><DIV>&nbsp;</DIV><DIV>Daniel</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Fri, 13 Mar 2009 09:21:50 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4065#4065</guid>
  </item> 
  <item>
   <title>Changing query before execution :                public class...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4064#4064</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=449" rel="nofollow">smi-mark</a><br /><strong>Subject:</strong> 1137<br /><strong>Posted:</strong> 13-Mar-2009 at 8:47am<br /><br /><div ="code-view">    <div ="c&#111;ntainer">        &nbsp;&nbsp;&nbsp;&nbsp; public class BOSFetch : IEntityServerFetching<br>&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public void OnFetching(IdeaBlade.EntityModel.v4.EntityServerFetchingEventArgs args)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (args.Query.QueryableType is ActiveEntity) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //In here you can cast the args.Query to an EntityQuery&lt;ActiveEntity&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //and then you are able to do .Where and all your other query functions.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp; }<br>    </div></div>]]>
   </description>
   <pubDate>Fri, 13 Mar 2009 08:47:30 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4064#4064</guid>
  </item> 
  <item>
   <title>Changing query before execution : We are currently evaluating DevForce...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4058#4058</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=460" rel="nofollow">mrdaniel76</a><br /><strong>Subject:</strong> 1137<br /><strong>Posted:</strong> 13-Mar-2009 at 6:42am<br /><br />We are currently evaluating DevForce EF and we have a need to append an extra condition to most queries before it runs in order to filter the data, so the user will only see the rows they are authorized to see.<DIV>&nbsp;</DIV><DIV>So we need the following before any query runs:</DIV><DIV>* Determine if the table has a certain column on it (for example userid column)</DIV><DIV>* If it does, add an extra criteria to the query so the result is filtered based on that query (for example userid=current user)</DIV><DIV>&nbsp;</DIV><DIV>I found something on the Developer's guide but that information seems to be outdated and for the classic version of devforce because it does not work:</DIV><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><DIV><FONT face="Courier New, Courier, mono" size=1>static void mManager_Fetching(object sender, EntityFetchingEventArgs e) <BR>{ <BR>&nbsp;&nbsp;&nbsp;&nbsp; IdeaBlade.Persistence.Rdb.RdbQuery q = e.Query; <BR>&nbsp;&nbsp;&nbsp;&nbsp; if ( q.EntityType is ActiveEntity ) <BR>&nbsp;&nbsp;&nbsp;&nbsp; { </FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;q.AddClause("ActiveFlag", EntityQueryOp.EQ, true); // '1' == true&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;} <BR>}</FONT></DIV></BLOCKQUOTE><DIV>&nbsp;</DIV><DIV>What's the equivalent of this code so I can fulfill my requirement?</DIV><DIV>&nbsp;</DIV><DIV>I know I can create a partial class for the EntityManager and override the OnFetching method but do not know what to do from there.</DIV><BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px"><DIV><FONT face="Courier New, Courier, mono" size=1>public partial class DomainModelEntityManager <BR>{<BR>&nbsp;&nbsp;&nbsp;&nbsp; protected override bool OnFetching(IdeaBlade.EntityModel.v4.EntityFetchingEventArgs args)</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>&nbsp;&nbsp;&nbsp;&nbsp; {</FONT></DIV><DIV><FONT face="Courier New, Courier, mono" size=1>&nbsp;&nbsp;&nbsp;&nbsp; }<BR>}</FONT></DIV></BLOCKQUOTE><DIV>&nbsp;</DIV><DIV>Thanks a lot!</DIV><DIV>&nbsp;</DIV><DIV>Daniel</DIV>]]>
   </description>
   <pubDate>Fri, 13 Mar 2009 06:42:28 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1137&amp;PID=4058#4058</guid>
  </item> 
 </channel>
</rss>