<?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 : Sql Where Clause</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce Classic : Sql Where Clause</description>
  <pubDate>Thu, 11 Jun 2026 15:04:11 -700</pubDate>
  <lastBuildDate>Mon, 12 Nov 2007 10:05:03 -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=518</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>Sql Where Clause : You could eitheradd an &amp;#034;if&amp;#034;...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1909#1909</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> 518<br /><strong>Posted:</strong> 12-Nov-2007 at 10:05am<br /><br />You could either&nbsp;add an "if" clause in the event handler for every applicable entity or create a base class in which every applicable entity derives from and check for the base class in the handler.]]>
   </description>
   <pubDate>Mon, 12 Nov 2007 10:05:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1909#1909</guid>
  </item> 
  <item>
   <title>Sql Where Clause : Would I put this with each entity...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1908#1908</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=136" rel="nofollow">orcities</a><br /><strong>Subject:</strong> 518<br /><strong>Posted:</strong> 12-Nov-2007 at 7:16am<br /><br />Would I put this with each entity class that is needed?]]>
   </description>
   <pubDate>Mon, 12 Nov 2007 07:16:44 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1908#1908</guid>
  </item> 
  <item>
   <title>Sql Where Clause : The &amp;#034;SQL Where Clause&amp;#034;...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1892#1892</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> 518<br /><strong>Posted:</strong> 07-Nov-2007 at 12:40pm<br /><br />The "SQL Where Clause" works great if the value of the filter column is invariant. It is not good if the value of the filter column can change -- as in the case with an "InActive" or "Deleted" column. <DIV></DIV><DIV>&nbsp;</DIV><DIV>The more dynamic approach would be to add a "Fetching" handler to the PersistenceManager and add the clause if necessary. The Fetching event is raised just before the PersistenceManager sends a query to the server; the query is included in the event args for the Fetching handler, and you can modify it before DevForce applies it. </DIV><DIV>&nbsp;</DIV><DIV>You might initialize your PersistenceManager as follows:</DIV><DIV>&nbsp;</DIV><DIV><DIV style="BORDER-RIGHT: #666699 1pt solid; PADDING-RIGHT: 4pt; BORDER-TOP: #666699 1pt solid; PADDING-LEFT: 4pt; PADDING-BOTTOM: 4pt; MARGIN-LEFT: 0.25in; BORDER-LEFT: #666699 1pt solid; MARGIN-RIGHT: 0.25in; PADDING-TOP: 4pt; BORDER-BOTTOM: #666699 1pt solid; mso-element: para-border-div; mso-border-alt: solid #666699 .5pt; e0e0e0: "><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole">private void InitializePm() {<?:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>mManager = PersistenceManager.DefaultManager;<O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>// other stuff<O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>mManager.Fetching += new EventHandler&lt;EntityFetchingEventArgs&gt;(mManager_Fetching);<O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole">}<O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><O:P><FONT face="Lucida C&#111;nsole">&nbsp;</FONT></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><O:P><FONT face="Lucida C&#111;nsole">&nbsp;</FONT></O:P></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole">static void mManager_Fetching(object sender, EntityFetchingEventArgs e) {<O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>IdeaBlade.Persistence.EntityQuery q = e.Query as EntityQuery;<O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>if ( q.EntityType&nbsp;== typeof(Contact) )&nbsp;{<O:P></O:P></FONT></SPAN></P><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN>q.AddClause("InActive", EntityQueryOp.EQ, 0);&nbsp;</P><DIV></FONT></SPAN><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN>}<O:P></O:P></FONT></SPAN></DIV><P style="MARGIN: 0in 0in 0pt; e0e0e0: " ="syntax"><SPAN style="FONT-SIZE: 8pt"><FONT face="Lucida C&#111;nsole">}<O:P></O:P></FONT></SPAN></P></DIV></DIV><DIV>&nbsp;</DIV><DIV>Hope this helps.</DIV><span style="font-size:10px"><br /><br />Edited by eileenv - 07-Nov-2007 at 3:27pm</span>]]>
   </description>
   <pubDate>Wed, 07 Nov 2007 12:40:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1892#1892</guid>
  </item> 
  <item>
   <title>Sql Where Clause : Have you tried changing your query...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1857#1857</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=24" rel="nofollow">Linguinut</a><br /><strong>Subject:</strong> 518<br /><strong>Posted:</strong> 01-Nov-2007 at 12:40pm<br /><br /><P>Have you tried changing your query strategy to CacheOnly?</P>]]>
   </description>
   <pubDate>Thu, 01 Nov 2007 12:40:49 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1857#1857</guid>
  </item> 
  <item>
   <title>Sql Where Clause :  Originally posted by eileenv Can...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1852#1852</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=136" rel="nofollow">orcities</a><br /><strong>Subject:</strong> 518<br /><strong>Posted:</strong> 01-Nov-2007 at 7:17am<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by eileenv</strong></em><br /><br /><P>Can you provide a code snippet of the SQLWhereClause and the query you are trying to execute?</P></td></tr></table> <DIV><strong>SQL Where Clause in Object Mapper</strong>: InActive = 0</DIV><DIV><strong>Snippet:</strong></DIV><DIV>RdbQuery query = new RdbQuery(typeof(Contact), ContactIdEntityColumn, EntityQueryOp.EQ, CurrentContact.ContactId);</DIV><DIV>query.AddClause(Contact.InActiveEnitityColumn, EntityQueryOp.EQ, 1);</DIV><DIV>Contact aContact = MainPm.EntityManager.GetEntity&lt;Contact&gt;(query);</DIV><DIV>&nbsp;</DIV><DIV>not copied and pasted. just an example</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Thu, 01 Nov 2007 07:17:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1852#1852</guid>
  </item> 
  <item>
   <title>Sql Where Clause : Is this for a lot of tables or...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1851#1851</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=63" rel="nofollow">TrevLeyb</a><br /><strong>Subject:</strong> 518<br /><strong>Posted:</strong> 31-Oct-2007 at 5:32pm<br /><br /><P>Is this for a lot of tables or a single table? </P><DIV>I have managed this in two ways in the past. (based on the fact that the SQL where clause is defined in the definition of the table, and like you, not seeing how I could override that at runtime). </DIV><DIV>&nbsp;</DIV><DIV>1. Create a second instance of the table in the Object Mapper which is identical but without the where clause. So, if it was for Customers, my main class would be 'Customers' whcih would include the where clause, and then have 'CustomersInclDeleted' as a object which did not. In that very special case where I need the deleted customers as well, I can use the second object. </DIV><DIV>&nbsp;</DIV><DIV>2. The&nbsp;main way I manage this is to&nbsp;separate out the code that returns entities and entity sets behind a Facade layer. So I never directly call something like pm.GetEntities&lt;Customer&gt;() in my code. I will always call a separate method in a Facade layer to do this, such as GetCustomers();</DIV><DIV>&nbsp;</DIV><DIV>So in this case, I will have possibly either GetCustomers() and GetCustomersInclDeleted() methods in my Facade layer, or I will have a GetCustomers() and GetCustomers(bool inclDeleted) method. </DIV><DIV>&nbsp;</DIV><DIV>Hope this helps. </DIV>]]>
   </description>
   <pubDate>Wed, 31 Oct 2007 17:32:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1851#1851</guid>
  </item> 
  <item>
   <title>Sql Where Clause : Can you provide a code snippet...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1850#1850</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> 518<br /><strong>Posted:</strong> 31-Oct-2007 at 3:51pm<br /><br /><P>Can you provide a code snippet of the SQLWhereClause and the query you are trying to execute?</P>]]>
   </description>
   <pubDate>Wed, 31 Oct 2007 15:51:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1850#1850</guid>
  </item> 
  <item>
   <title>Sql Where Clause : After setting the Entity Where...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1744#1744</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=136" rel="nofollow">orcities</a><br /><strong>Subject:</strong> 518<br /><strong>Posted:</strong> 23-Oct-2007 at 10:01am<br /><br />After setting the Entity Where clause is there a way to override it? <DIV>&nbsp;</DIV><DIV>99% of the time I only need an entity with a specific flag set, not deleted. But, when someone tries to add a new entity I want to verify that it's not one that has been marked deleted. </DIV><DIV>&nbsp;</DIV><DIV>When running an Rdb query it will never return a result even if I explicitly set the AddClause to the oposite value.</DIV>]]>
   </description>
   <pubDate>Tue, 23 Oct 2007 10:01:07 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=518&amp;PID=1744#1744</guid>
  </item> 
 </channel>
</rss>