Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>Disclaimer, I haven't got any compiled working code.</em></p> <p>2 problems.</p> <p>First problem probably lies in:</p> <pre><code>ParameterExpression billMapSetParameter = Expression.Parameter(typeof(billing_map_set_lu), "p"); </code></pre> <p>That's not a parameter you need in:</p> <pre><code>Expression.Lambda&lt;Func&lt;billmaps_lu, bool&gt;&gt;(Expression.Call(method, Expression.Property(**billMapSetParameter**, typeof(billing_map_set_lu).GetProperty("billmaps_lu")), myWhereClause1), billMaps) </code></pre> <p>Change the billMapSetParameter to the billMaps ParamterExpression, then you should be good to go. You are calling the PropertyExpression to obtain your billMapSet for you from the ParameterExpression.</p> <p>2nd problem: (Not sure, but my gut feeling) You may need to pass the Where clause as a ConstantExpression with type Expression&lt;.Func&lt;>>. .Any method takes two parameters, of which, the second is an Expression&lt;.Func&lt;>> (Or just a Func&lt;>? can't remember).</p> <pre><code>var whereExpression = Expression.Lambda&lt;.Func&lt;.billmaps_lu, bool&gt;&gt;(myWhereClause1, bms); var ce = Expression.Constant(whereExpression) </code></pre> <p>Then pass back ce into originally where you "myWhereClause1" is.</p> <p><em>Cross finger it works</em></p> <p>Edit- Scrap that, SHOW MI ZEH CODEZ</p> <pre><code>public class Foo { public List&lt;string&gt; Strings { get; set; } } class Program { static void Main(string[] args) { Func&lt;Foo, bool&gt; func = a =&gt; a.Strings.Any(b =&gt; b == "asdf"); // b =&gt; b == "asdf"; var bParameter = Expression.Parameter(typeof (string)); var asdfConstant = Expression.Constant("asdf"); var compare = Expression.Equal(bParameter, asdfConstant); var compareExpression = Expression.Lambda&lt;Func&lt;string, bool&gt;&gt;(compare, bParameter); var ceCompareExpression = Expression.Constant(compareExpression.Compile()); // a =&gt; a.Strings.Any(compareExpression) var parameter = Expression.Parameter(typeof (Foo)); var foosProperty = Expression.Property(parameter, typeof (Foo).GetProperty("Strings")); MethodInfo method = typeof(Enumerable).GetMethods().Where(m =&gt; m.Name == "Any" &amp;&amp; m.GetParameters().Length == 2).Single().MakeGenericMethod(typeof(string)); var anyMethod = Expression.Call(method, foosProperty, ceCompareExpression); var lambdaExpression = Expression.Lambda&lt;Func&lt;Foo, bool&gt;&gt;(anyMethod, parameter); // Test. var foo = new Foo {Strings = new List&lt;string&gt; {"asdf", "fdsas"}}; Console.WriteLine(string.Format("original func result: {0}", func(foo))); Console.Write(string.Format("constructed func result: {0}", lambdaExpression.Compile()(foo))); Console.ReadKey(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload