<?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 : Variable Linq</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : Variable Linq</description>
  <pubDate>Wed, 29 Jul 2026 10:06:20 -700</pubDate>
  <lastBuildDate>Thu, 02 Dec 2010 01:50: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=2263</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>Variable Linq : Hi, jolemaiavix.Why don&amp;#039;t...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=9293#9293</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=825" rel="nofollow">gkneo</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 02-Dec-2010 at 1:50am<br /><br />Hi, jolemaiavix.<div><br></div><div>Why don't you try the following:</div><div><br></div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><pre style="font-family: c&#111;nsolas">&nbsp;&nbsp;&nbsp;<span style="color: blue">foreach</span>&nbsp;(<span style="color: blue">var</span>&nbsp;fieldName&nbsp;<span style="color: blue">in</span>&nbsp;_orderFields)<br>&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;<span style="color: #2b91af">Type</span>&nbsp;t&nbsp;=&nbsp;_filterEntity.EntityAspect.GetDataProperty(fieldName).DataType;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">if</span>&nbsp;(t&nbsp;==&nbsp;<span style="color: blue">typeof</span>(<span style="color: #2b91af">String</span>))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;query&nbsp;=&nbsp;query.OrderBy(GetMember&lt;Employee,&nbsp;<span style="color: blue">string</span>&gt;(_filterEntity,&nbsp;fieldName));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">else</span>&nbsp;<span style="color: blue">if</span>&nbsp;(t&nbsp;==&nbsp;<span style="color: blue">typeof</span>(<span style="color: #2b91af">Int32</span>))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;query&nbsp;=&nbsp;query.OrderBy(GetMember&lt;Employee,&nbsp;<span style="color: #2b91af">Int32</span>&gt;(_filterEntity,&nbsp;fieldName));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div><br></div><div><br></div><div></pre></td></tr></table></div><div><br></div><div>and the GetMember method:</div><div><table width="99%"><tr><td><pre class="BBcode"></div><div><pre style="font-family: c&#111;nsolas">&nbsp;<span style="color: blue">public</span>&nbsp;<span style="color: blue">static</span>&nbsp;System.Linq.Expressions.<span style="color: #2b91af">Expression</span>&lt;<span style="color: #2b91af">Func</span>&lt;T,&nbsp;T2&gt;&gt;&nbsp;GetMember&lt;T,&nbsp;T2&gt;(T&nbsp;entity,&nbsp;<span style="color: blue">string</span>&nbsp;memberName)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Linq.Expressions.<span style="color: #2b91af">ParameterExpression</span>&nbsp;pe&nbsp;=<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Linq.Expressions.<span style="color: #2b91af">Expression</span>.Parameter(<span style="color: blue">typeof</span>(T),&nbsp;<span style="color: #a31515">"p"</span>);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: blue">return</span>&nbsp;(System.Linq.Expressions.<span style="color: #2b91af">Expression</span>&lt;<span style="color: #2b91af">Func</span>&lt;T,&nbsp;T2&gt;&gt;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Linq.Expressions.<span style="color: #2b91af">Expression</span>.Lambda(<span style="color: blue">typeof</span>(<span style="color: #2b91af">Func</span>&lt;T,&nbsp;T2&gt;),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.Linq.Expressions.<span style="color: #2b91af">Expression</span>.Property(pe,&nbsp;memberName),&nbsp;pe);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</pre></div><div></pre></td></tr></table></div><div><br></div><div>_filterEntity is a dummy instance (in this case of type Employee) used to retrieve information about the queried type. &nbsp;(I think may be another way to do this without using a dummy instance). &nbsp;</div><div><br></div><div>_orderFields is a list of string which values are the name of the fields to use in the "order by" clause.</div><div><br></div><div>query is a IEntityQuery&lt;Employee&gt;</div><div><br></div><div>Guillermo</div><div><br></div>]]>
   </description>
   <pubDate>Thu, 02 Dec 2010 01:50:03 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=9293#9293</guid>
  </item> 
  <item>
   <title>Variable Linq : Hi jolemaiavix,  Unfortunatelly,...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=9115#9115</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 15-Nov-2010 at 9:24am<br /><br />Hi jolemaiavix,<DIV>&nbsp;</DIV><DIV>Unfortunatelly, using OrderBy dynamically is not possible yet, but we have it in our list of features to be implemented.</DIV><DIV>&nbsp;</DIV><DIV>sbelini.</DIV>]]>
   </description>
   <pubDate>Mon, 15 Nov 2010 09:24:28 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=9115#9115</guid>
  </item> 
  <item>
   <title>Variable Linq : worked perfectly! Another question:...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=9030#9030</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=984" rel="nofollow">jolemaiavix</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 08-Nov-2010 at 4:47am<br /><br /><span id="result_" ="" lang="en"><span style="" title="">worked perfectly! </span><span style="" title="">Another question: how would for the "ORDER BY" also be dynamic as the WHERE</span></span>?]]>
   </description>
   <pubDate>Mon, 08 Nov 2010 04:47:13 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=9030#9030</guid>
  </item> 
  <item>
   <title>Variable Linq : I couldn&amp;#039;t reproduce the...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8979#8979</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 29-Oct-2010 at 10:48am<br /><br /><DIV>I couldn't reproduce the issue here.</DIV><DIV>Was&nbsp;expr1 created properly?</DIV><DIV>&nbsp;</DIV><DIV>Here's a testunit against NorthwindIB which executed with no issues:</DIV><DIV>&nbsp;</DIV><DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&#091;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>TestMethod</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&#093;</DIV><DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>public</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>void</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> TestPredicateBuilder2() {</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> mgr = </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>new</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>NorthwindIBEntityManager</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>();</DIV><DIV>&nbsp; mgr.AuthorizedThreadId = </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>null</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>;</DIV><DIV></FONT></FONT><FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas><FONT color=#008000 size=2 face=C&#111;nsolas>&nbsp; //var MyVariable = "EmployeeID == 1";</DIV><DIV></FONT></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> MyVariable = </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"LastName == 'Davolio'"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>;</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> strings = MyVariable.Split(</FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>' '</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>);</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> expr1 = </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>PredicateBuilder</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.Make(</FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>typeof</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>(</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>), strings&#091;0&#093;.Trim()</DIV><DIV>&nbsp;&nbsp;&nbsp; , </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>FilterOperator</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.IsEqualTo</DIV><DIV>&nbsp;&nbsp;&nbsp; , strings&#091;2&#093;.Trim(</FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>'\''</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>));</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> exprFunc = (</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Expression</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Func</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>, </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>bool</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;&gt;)expr1.ToLambdaExpression();</DIV><DIV></FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>&nbsp; Entity</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> instancia = (</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Entity</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>)</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Activator</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.CreateInstance(</FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>typeof</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>(</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>));</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> query = </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>new</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>EntityQuery</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;(instancia.EntityAspect.EntitySetName, mgr).Where(exprFunc);</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> emps = query.Execute();</DIV><DIV>}</DIV></FONT></FONT></DIV></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>I suggest you create a simple test, and gradually add complexity to it, so you can isolate what's causing the issue.</DIV></FONT></FONT><span style="font-size:10px"><br /><br />Edited by sbelini - 29-Oct-2010 at 10:51am</span>]]>
   </description>
   <pubDate>Fri, 29 Oct 2010 10:48:38 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8979#8979</guid>
  </item> 
  <item>
   <title>Variable Linq : The code looks like this:    ...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8977#8977</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=984" rel="nofollow">jolemaiavix</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 29-Oct-2010 at 9:49am<br /><br /><span id="result_" ="" lang="en"><span style="" title="">The code looks like this:<br>  <br></span></span>&nbsp;&nbsp;&nbsp; public override void Inicializar(string texto)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ListaRegistros = new ObservableCollection&lt;T&gt;();<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ListaRegistros.CollectionChanged += ListaRegistros_CollectionChanged;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _propriedadeDinamicaBusy = _propriedadeIsBusyMaster;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AthenasEntityManager.Fetching += (s, e) =&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IsBusy = true;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AthenasEntityManager.Queried += (s, e) =&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; IsBusy = false;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; _propriedadeDinamicaBusy = _propriedadeIsBusyDetail;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Entity instancia = (Entity)Activator.CreateInstance(typeof(T));<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var MyVariable = texto;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var strings = MyVariable.Split(' ');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var expr1 = PredicateBuilder.Make(typeof(T), strings&#091;0&#093;.Trim()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , FilterOperator.IsEqualTo<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; , Int32.Parse(strings&#091;2&#093;.Trim('\'')));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <font color="#cc3333">var exprFunc = (Expression&lt;Func&lt;T, bool&gt;&gt;)expr1.ToLambdaExpression();</font><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var query = new EntityQuery&lt;T&gt;(instancia.EntityAspect.EntitySetName, AthenasEntityManager).Where(exprFunc);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; query.ExecuteAsync(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; args =&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!Excecao.TratarRetornoCallback(args))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; args.Results.ForEach(ListaRegistros.Add);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; RegistroCorrenteLocal = ListaRegistros.FirstOrDefault();<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (AoCarregarRegistros != null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AoCarregarRegistros(this, new EventArgs());<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; });<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //var teste = ListaRegistros.Where&lt;string&gt;("","");<br>&nbsp;&nbsp;&nbsp; }<br><br><span id="result_" ="" lang="en"><span style="" title="">Type T is inherited in the call to "</span></span>ViewModelCadastro.Inicializar("codigo == 1");<span id="result_" ="" lang="en"><span style="" title="">".<br>    <br>  </span></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TipoDominioType = Util.GetAssemblyType("Dominio." + TipoDominio);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (TipoDominioType == null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Excecao.ExibirMensagem(string.Format("Não foi possível encontrar o domínio {0}.", TipoDominio));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ViewModelCadastro = (Activator.CreateInstance(typeof(ViewModel&lt;&gt;).MakeGenericType(new Type&#091;&#093; { TipoDominioType })) as IViewModel);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (ViewModelCadastro == null)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ViewModelCadastro.Inicializar("codigo == 1");<br><br><span id="result_" ="" lang="en"><span style="" title="">The red line is returning null to exprFunc. </span><span style=": rgb235, 239, 249;" title="">Where's the error?</span></span><br><br>]]>
   </description>
   <pubDate>Fri, 29 Oct 2010 09:49:39 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8977#8977</guid>
  </item> 
  <item>
   <title>Variable Linq : IdeaBlade.Linq  You can find...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8975#8975</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 29-Oct-2010 at 9:13am<br /><br />IdeaBlade.Linq<DIV>&nbsp;</DIV><DIV>You can find aditional information about PredicateBuilder at the API Documentation available <a href="http://drc.ideablade.com/Api&#068;ocumentati&#111;n/" target="_blank">online</A> and installed with DevForce2010.</DIV>]]>
   </description>
   <pubDate>Fri, 29 Oct 2010 09:13:26 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8975#8975</guid>
  </item> 
  <item>
   <title>Variable Linq : which namespaces need?  </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8973#8973</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=984" rel="nofollow">jolemaiavix</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 29-Oct-2010 at 5:57am<br /><br /><span id="result_" ="" lang="en"><span style="" title="">which namespaces need?</span></span>]]>
   </description>
   <pubDate>Fri, 29 Oct 2010 05:57:45 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8973#8973</guid>
  </item> 
  <item>
   <title>Variable Linq : Hi,   I mentioned the &amp;#034;contains&amp;#034;...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8962#8962</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 28-Oct-2010 at 12:30pm<br /><br />Hi, <DIV>&nbsp;</DIV><DIV>I mentioned the "contains" example because you had it initially in your snippet. </DIV><DIV>Yet, the PredicateBuilder is what you are looking for.</DIV><DIV>&nbsp;</DIV><DIV>Suppose MyVariable is "Name == 'test'":</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas></FONT></FONT></FONT>&nbsp;</DIV><DIV><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> MyVariable = </FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>"Name == 'test'"</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>;</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> strings = MaVariable.Split(</FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>' '</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>);</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> expr1 = </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>PredicateBuilder</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.Make(</FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>typeof</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>(</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>), strings&#091;0&#093;.Trim()</DIV><DIV>&nbsp;&nbsp;&nbsp; ,</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>FilterOperator</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.IsEqualTo</DIV><DIV>&nbsp;&nbsp;&nbsp; ,</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Int32</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.Parse(strings&#091;2&#093;.Trim(</FONT></FONT><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas><FONT color=#a31515 size=2 face=C&#111;nsolas>'\''</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>)));</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> exprFunc = (</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Expression</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Func</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Employee</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>, </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>bool</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;&gt;)expr1.ToLambdaExpression();</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> query = mgr.Employees.Where(exprFunc);</DIV><DIV></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>&nbsp; var</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> results = query.Execute();</FONT></FONT></DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>I hope it helps</DIV><span style="font-size:10px"><br /><br />Edited by sbelini - 28-Oct-2010 at 12:30pm</span>]]>
   </description>
   <pubDate>Thu, 28 Oct 2010 12:30:24 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8962#8962</guid>
  </item> 
  <item>
   <title>Variable Linq : I can not use &amp;#034;contains&amp;#034;....</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8955#8955</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=984" rel="nofollow">jolemaiavix</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 28-Oct-2010 at 4:57am<br /><br /><span id="result_" ="" lang="en"><span style="" title="">I can not use "contains". </span><span style="" title="">The contents of MyVariable will be filled on a selection by an end user. </span><span style="" title="">The content of it can be "Name == 'test'" or "Type == 2" or anything else.</span></span>]]>
   </description>
   <pubDate>Thu, 28 Oct 2010 04:57:16 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8955#8955</guid>
  </item> 
  <item>
   <title>Variable Linq : Hi jolemaiavix,   You can build...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8929#8929</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=892" rel="nofollow">sbelini</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 26-Oct-2010 at 2:34pm<br /><br />Hi jolemaiavix, <DIV>&nbsp;</DIV><DIV>You can build queries dynamically by using the Predicatebuilder.</DIV><DIV>In your case you will parse your MyVariable string and build the query according with the string. (i.e. "Name == 'test'" or Name.Contains("test") )</DIV><DIV>&nbsp;</DIV><DIV>You can find detailed information about PredicateBuilder in our API documentation (available <a href="http://drc.ideablade.com/Api&#068;ocumentati&#111;n/" target="_blank">online</A> and with your DevForce installation).</DIV><span style="font-size:10px"><br /><br />Edited by sbelini - 26-Oct-2010 at 2:40pm</span>]]>
   </description>
   <pubDate>Tue, 26 Oct 2010 14:34:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8929#8929</guid>
  </item> 
  <item>
   <title>Variable Linq : I need to run the linq below:IEntityQuery&amp;lt;Employee&amp;gt;...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8926#8926</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=984" rel="nofollow">jolemaiavix</a><br /><strong>Subject:</strong> 2263<br /><strong>Posted:</strong> 26-Oct-2010 at 12:20pm<br /><br /><span id="result_" ="" lang="en"><span style="" title="">I need to run the linq below:</span></span><br><br>IEntityQuery&lt;Employee&gt; qry = (IEntityQuery&lt;Employee&gt;)_entityManager.BasePersons<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Include(Employee.PathFor(b =&gt; b.Address))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Include(Employee.PathFor(b =&gt; b.Address.Country))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .Where(b =&gt; b.Name.Contains(pValue));<br><br><span id="result_" ="" lang="en"><span style="" title="">Being that I need to replace the code "Where (b =&gt; b.Name.Contains (pvalue))" for "Where (MyVariable)". </span><span style="" title="">MyVariable will contain "Name == 'test'." </span><span style="" title="">Is it possible? </span><span style="" title="">How do I?</span></span><br>]]>
   </description>
   <pubDate>Tue, 26 Oct 2010 12:20:42 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2263&amp;PID=8926#8926</guid>
  </item> 
 </channel>
</rss>