<?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 : Doing &quot;generic&quot; queries with no ESQL</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Doing &quot;generic&quot; queries with no ESQL</description>
  <pubDate>Wed, 13 May 2026 11:33:03 -700</pubDate>
  <lastBuildDate>Thu, 12 Jan 2012 12:50:32 -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=3123</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>Doing &quot;generic&quot; queries with no ESQL :   Yes, thanks! I just figured...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12452#12452</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 12-Jan-2012 at 12:50pm<br /><br />Yes, thanks! I just figured it 5 minutes ago. The more I deal with DevForce the more I like it. Let's see how it goes in Production :)]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 12:50:32 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12452#12452</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL : Is this what you&amp;#039;re looking...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12451#12451</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> 3123<br /><strong>Posted:</strong> 12-Jan-2012 at 12:38pm<br /><br />Is this what you're looking for?<div><br></div><div>customerQuery.AddIncludePaths(Customer.PathFor(c =&gt; c.Orders));</div><div>customerQuery.AddIncludePaths(Customer.PathFor(c =&gt; c.Shippers));</div><div><br></div><div>or&nbsp;</div><div><br></div><div>customerQuery.AddIncludePaths("Orders");</div><div>customerQuery.AddIncludePaths("Shippers");</div>]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 12:38:09 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12451#12451</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :     Didn&amp;#039;t want to open...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12445#12445</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 12-Jan-2012 at 8:52am<br /><br />Didn't want to open another topic.<div><br>1. Is it possible to dynamically add "Include" statements?</div><div>&nbsp;</div><div>Something like (pseudocode)</div><div>&nbsp;</div><div>var customerQuery;</div><div>if (needOrders) customerQuery.Include("AA");</div><div>if (needHistory) customerQuery.Include("BB");</div><div>&nbsp;</div><div>customerQuery.execute..</div><div>&nbsp;</div><span style="font-size:10px"><br /><br />Edited by katit - 12-Jan-2012 at 10:28am</span>]]>
   </description>
   <pubDate>Thu, 12 Jan 2012 08:52:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12445#12445</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :    I&amp;#039;m doing it like this...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12414#12414</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 10-Jan-2012 at 2:11pm<br /><br /> I'm doing it like this just because I wanted to build abstraction layer between DevForce and my controls. <div>&nbsp;</div><div>Suggestion with selector also worked great.</div><div>&nbsp;</div><div>Thanks!</div>]]>
   </description>
   <pubDate>Tue, 10 Jan 2012 14:11:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12414#12414</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL : Ah I see. In that case, my suggestion...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12413#12413</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> 3123<br /><strong>Posted:</strong> 10-Jan-2012 at 2:05pm<br /><br /><div style="margin-left: 1px; margin-top: 1px; margin-right: 1px; margin-bottom: 1px; line-height: 1.4; border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-: initial; -: n&#111;ne; ">Ah I see. In that case, my suggestion would be to refactor the switch statement by putting another property on the FilterRow type that essentially maps FilterChoice to FilterOperator.<div><br></div><div>For example,<div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div>public class FilterRow {</div><div>&nbsp;&nbsp;</div><div>&nbsp; public FilterChoice FilterAs { get; set; }</div><div>&nbsp;&nbsp;</div><div>&nbsp; public FilterOperator {</div><div>&nbsp; &nbsp; get {</div><div>&nbsp; &nbsp; &nbsp; &nbsp;return GetFilterOperatorByFilterChoice(this.FilterAs);</div><div>&nbsp; &nbsp; }</div><div>&nbsp; }</div><div>}</div><div><br></div><div>//This can be a static or utility method.</div><div>private FilterOperator GetFilterOperatorByFilterChoice(FilterChoice filterAs) {</div><div>&nbsp; switch (filterAs) {</div><div>&nbsp; &nbsp; &nbsp;case FilterChoice.EqualsTo:</div><div>&nbsp; &nbsp; &nbsp; &nbsp;return FilterOperator.IsEqualTo;</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp;case FilterChoice.NotEqualsTo:</div><div>&nbsp; &nbsp; &nbsp; &nbsp;return FilterOperator.IsNotEqualTo;</div><div><br></div><div>&nbsp; &nbsp; &nbsp;etc.........</div><div>&nbsp; }</div><div>}</div><div></pre></td></tr></table></div></div><div><br></div><div>Then when you build your predicate, you can simply do,</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><span style="text-align: left; : rgb251, 251, 253; ">foreach (var filterBoxRow in filterRows.Where(x =&gt; !x.FilterAs.Equals(FilterChoice.All)))</span><br style="text-align: left; : rgb251, 251, 253; "><span style="text-align: left; : rgb251, 251, 253; ">{</span><br style="text-align: left; : rgb251, 251, 253; "><span style="text-align: left; : rgb251, 251, 253; ">&nbsp; &nbsp;&nbsp;</span><span style="text-align: left; : rgb251, 251, 253; ">predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, filterBoxRow.FilterOperator, filterBoxRow.FilterFrom));</span></div><div><span style="text-align: left; : rgb251, 251, 253; ">}</span></div><div></pre></td></tr></table></div><div><br></div><div>This is the only suggestion that I can think of. Hope it can get you started.</div></div>]]>
   </description>
   <pubDate>Tue, 10 Jan 2012 14:05:56 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12413#12413</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :    Originally posted by DenisKHi...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12397#12397</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 09-Jan-2012 at 6:31pm<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by DenisK</strong></em><br /><br />Hi katit;<div><br>If I understand correctly, it looks like the ForEach loop can be reduced to the following:</div><div style="text-align: left;">&nbsp;</div><div style="text-align: left;"></td></tr></table></div><div style="text-align: left;">&nbsp;</div><div style="text-align: left;">Actually I do need loop(I thought one item in switch statement illustrated what I'm doing) also number of items rarely going to be more than 2-3 and 10-15 max (I doubt it). I'm not building IN-clauses</div><div style="text-align: left;">&nbsp;</div><div style="text-align: left;">My code looks like:</div><div style="text-align: left;">&nbsp;</div><div style="text-align: left;">var baseQuery = EntityQuery.Create(typeof(T), this.entityManager);</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var predicates = new List&lt;PredicateDescription&gt;();<br>&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; foreach (var filterBoxRow in filterRows.Where(x =&gt; !x.FilterAs.Equals(FilterChoice.All)))<br>&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; switch (filterBoxRow.FilterAs)<br>&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; case FilterChoice.EqualsTo:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsEqualTo, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.NotEqualsTo:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsNotEqualTo, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.BeginsWith:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.StartsWith, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.EndsWith:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.EndsWith, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.GreaterThan:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.After:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsGreaterThan, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.LessThan:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.Before:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsLessThan, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case FilterChoice.Between:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsGreaterThanOrEqualTo, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsLessThanOrEqualTo, filterBoxRow.FilterTo));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&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; }</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ITypedEntityQuery query = baseQuery;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (predicates.Count &gt; 0)<br>&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; var compositePredicateDescription = PredicateBuilder.And(predicates.ToArray());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query = baseQuery.Where(compositePredicateDescription);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div style="text-align: left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query.ExecuteAsync(</div><span style="font-size:10px"><br /><br />Edited by katit - 09-Jan-2012 at 6:36pm</span>]]>
   </description>
   <pubDate>Mon, 09 Jan 2012 18:31:29 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12397#12397</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL : Hi katit; SELECT CustomerKey...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12395#12395</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> 3123<br /><strong>Posted:</strong> 09-Jan-2012 at 6:21pm<br /><br />Hi katit;<div><br></div><div><table width="99%"><tr><td class="BBquote"></div><div><span style="text-align: left; : rgb251, 251, 253; ">SELECT CustomerKey FROM TableCustomer WHERE CustomerId = @myParameter</span></div><div><span style="text-align: left; : rgb251, 251, 253; "></td></tr></table></span></div><div><span style="text-align: left; : rgb251, 251, 253; "><br></span></div><div style="text-align: left;">You can write the above query dynamically using a ProjectionSelector and a PredicateDescription. For example,</div><div style="text-align: left;"><br></div><div style="text-align: left;"><table width="99%"><tr><td><pre class="BBcode"></div><div style="text-align: left;"><div>&nbsp; &nbsp; &nbsp; var ids = _em1.Customers.Where(c =&gt; c.Id == custKey).Select(c =&gt; c.Id).ToList();</div><div>&nbsp; &nbsp; &nbsp; Assert.IsTrue(ids.Count == 1);</div><div>&nbsp; &nbsp; &nbsp; Assert.IsTrue(ids.First() == custKey);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; _em1.Clear();</div><div>&nbsp; &nbsp; &nbsp; var selector = new ProjectionSelector(Customer.EntityPropertyNames.Id);</div><div>&nbsp; &nbsp; &nbsp; var wherePredicate = PredicateBuilder.Make(Customer.EntityPropertyNames.Id, FilterOperator.IsEqualTo, custKey);</div><div>&nbsp; &nbsp; &nbsp; var rootQuery = EntityQuery.Create(typeof(Customer), _em1); &nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; var finalQuery = rootQuery.Where(wherePredicate).Select(selector);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; var ids2 = finalQuery.Execute().Cast&lt;long&gt;().ToList();</div><div>&nbsp; &nbsp; &nbsp; Assert.IsTrue(ids2.Count == 1);</div><div>&nbsp; &nbsp; &nbsp; Assert.IsTrue(ids2.First() == custKey);</div><div></pre></td></tr></table></div><div><br></div><div>Re: your second question,</div><div><br></div><div>If I understand correctly, it looks like the ForEach loop can be reduced to the following:</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div>var filterBoxRow = filterRows.Where(x =&gt; x.FilterAs.Equals(FilterChoice.EqualsTo)</div><div>predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsEqualTo, filterBoxRow.FilterFrom));</div><div></pre></td></tr></table></div><div><br></div><div>since you only want to build the predicates when filterBoxRow.FilterAs is FilterChoice.EqualsTo.</div><div><br></div><div>Looking at the whole query though, since you're building a list of predicates for equality comparison, you may get a StackOverflowException if your list of predicates gets too big.</div><div><br></div><div>I wonder if instead you can build a list of values and use FilterOperator.InList. For example,</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div>_em1.Customers.Where(c =&gt; ids.Contains(c.Id));</div><div><br></div><div>//The dynamic query equivalent of the above</div><div><div>var inListPredicate = PredicateBuilder.Make(typeof(Customer), "Id", FilterOperator.InList, ids);&nbsp; &nbsp; &nbsp;&nbsp;</div><div>rootQuery.Where(inListPredicate);</div></div><div></pre></td></tr></table></div><div><br></div><div>Hope this helps.</div></div>]]>
   </description>
   <pubDate>Mon, 09 Jan 2012 18:21:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12395#12395</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :   Another question...I implemented...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12394#12394</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 09-Jan-2012 at 3:49pm<br /><br />Another question...&nbsp;I implemented solution with PredicateBuilder. Here is how it looks:<div>&nbsp;</div><div><table width="99%"><tr><td class="BBquote"></div><div>var baseQuery = EntityQuery.Create(typeof(T), this.entityManager);</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var predicates = new List&lt;PredicateDescription&gt;();<br>&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; foreach (var filterBoxRow in filterRows.Where(x =&gt; !x.FilterAs.Equals(FilterChoice.All)))<br>&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; switch (filterBoxRow.FilterAs)<br>&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; case FilterChoice.EqualsTo:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; predicates.Add(PredicateBuilder.Make(typeof(T), filterBoxRow.FieldName, FilterOperator.IsEqualTo, filterBoxRow.FilterFrom));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&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; }</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ITypedEntityQuery query = baseQuery;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (predicates.Count &gt; 0)<br>&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; var compositePredicateDescription = PredicateBuilder.And(predicates.ToArray());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query = baseQuery.Where(compositePredicateDescription);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</div><div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query.ExecuteAsync(</div><div></td></tr></table></div><div>&nbsp;</div><div>I have filterRows array with list of my own descriptors for predicates. So, now I need to build predicates. </div><div>I wonder if my code looks reasanoble since I had to:</div><div>&nbsp;</div><div>1. Add new List where I store PredicateDescriptions</div><div>&nbsp;</div><div>2. cast baseQuery to ITypedEntityQuery</div><div>&nbsp;</div><div>3. if predicates there - use PredicateBuilder and "join" collected predicates.</div><div>&nbsp;</div><div>I'm just not sure if I can write it more compact and easy to look at..</div>]]>
   </description>
   <pubDate>Mon, 09 Jan 2012 15:49:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12394#12394</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :   Originally posted by DenisK I...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12393#12393</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 09-Jan-2012 at 12:31pm<br /><br /><table width="99%"><tr><td class="BBquote"><strong><em>Originally posted by DenisK</strong></em><br /><br />I see. Will this work for you?<div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>var entityType = typeof(Entity);</div><div>var baseQuery = EntityQuery.CreateQuery(entityType&nbsp;, anEntityManager);</div><div><div>PredicateDescription p1 = PredicateBuilder.Make(entityType, "IdColumnName",&nbsp;FilterOperator.IsEqualTo, id);</div></div><div>var query = baseQuery.Where(p1);</div></div><div>var result = query.Execute();</div><div></pre></td></tr></table></div></td></tr></table><div>&nbsp;</div><div>Thanks! That gives me an idea how I do this. What about scalar query like this?</div><div>&nbsp;</div><div>SELECT CustomerKey FROM TableCustomer WHERE CustomerId = @myParameter</div><div>&nbsp;</div><div>Is it possible to run such query with generics and return only one value? In this case I want not just run scalar query but also specify "CustomerKey" as field I need to select.</div><div>&nbsp;</div><div>From documentation I see that Scalar operations support .First and various aggregates. In my case I'm bringing whole object but it might be more efficient to just query one column. Can I achieve this with LINQ and DevForce?</div><div>&nbsp;</div><div>&nbsp;</div>]]>
   </description>
   <pubDate>Mon, 09 Jan 2012 12:31:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12393#12393</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL : You might want to also check out...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12179#12179</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=705" rel="nofollow">chuckc</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 07-Dec-2011 at 7:40pm<br /><br />You might want to also check out Dynamic LINQ.<div><br><div><a href="http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx" target="_blank">http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx</a></div></div>]]>
   </description>
   <pubDate>Wed, 07 Dec 2011 19:40:00 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12179#12179</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :  I see. Will this work for you? var...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12172#12172</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> 3123<br /><strong>Posted:</strong> 06-Dec-2011 at 7:10pm<br /><br />I see. Will this work for you?<div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><div>var entityType = typeof(Entity);</div><div>var baseQuery = EntityQuery.CreateQuery(entityType&nbsp;, anEntityManager);</div><div><div>PredicateDescription p1 = PredicateBuilder.Make(entityType, "IdColumnName",&nbsp;FilterOperator.IsEqualTo, id);</div></div><div>var query = baseQuery.Where(p1);</div></div><div>var result = query.Execute();</div><div></pre></td></tr></table></div><span style="font-size:10px"><br /><br />Edited by DenisK - 06-Dec-2011 at 7:10pm</span>]]>
   </description>
   <pubDate>Tue, 06 Dec 2011 19:10:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12172#12172</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :   I looked at it, I&amp;#039;m just...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12169#12169</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 06-Dec-2011 at 2:58pm<br /><br />I looked at it, I'm just not sure how to produce code equal to my E-SQL code]]>
   </description>
   <pubDate>Tue, 06 Dec 2011 14:58:15 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12169#12169</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL : Hi katit;Sounds like our dynamic...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12168#12168</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> 3123<br /><strong>Posted:</strong> 06-Dec-2011 at 2:33pm<br /><br />Hi katit;<div><br></div><div>Sounds like our dynamic LINQ support is your answer. Have you tried it?</div><div><br></div><div><a href="http://drc.ideablade.com/xwiki/bin/view/&#068;ocumentati&#111;n/dynamic-queries" target="_blank">http://drc.ideablade.com/xwiki/bin/view/Documentation/dynamic-queries</a></div>]]>
   </description>
   <pubDate>Tue, 06 Dec 2011 14:33:14 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12168#12168</guid>
  </item> 
  <item>
   <title>Doing &quot;generic&quot; queries with no ESQL :    I wonder if something like...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12157#12157</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=1264" rel="nofollow">katit</a><br /><strong>Subject:</strong> 3123<br /><strong>Posted:</strong> 05-Dec-2011 at 7:18am<br /><br />I wonder if something like this even possible. I'm writing bunch of repository classes and see this repeating pattern where generic class should solve my problem. Consider this example:<div>&nbsp;</div><div>public void GetKeyAsync(string id, Action&lt;int?&gt; onSuccess, Action&lt;Exception&gt; onError)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: SQL INjection!!<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: Scalar lookup<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO: Use hard types, no eSQL<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var esqlString = "SELECT VALUE e FROM " + typeof(T).Name + "s AS e";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; esqlString += " WHERE e." + this.IdColumnName + "='" + id + "'";<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </div><div>&nbsp;</div><div>In this example I know type(T) of my entity. And I know column I need to filter by. How do I write LINQ query in this case?</div><div>&nbsp;</div><div>If I have to stay with ESQL, is there any way to do Scalar query on ESQL query?</div><span style="font-size:10px"><br /><br />Edited by katit - 05-Dec-2011 at 7:50am</span>]]>
   </description>
   <pubDate>Mon, 05 Dec 2011 07:18:56 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=3123&amp;PID=12157#12157</guid>
  </item> 
 </channel>
</rss>