Note that there are some explanatory texts on larger screens.

plurals
  1. POc# Lambda Expression built with LinqKit does not compile
    primarykey
    data
    text
    <p>This lambda does not compile, but I do not understand why. </p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using LinqKit; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { var barModel = new BarModel(); string id = "some"; Console.WriteLine(barModel.subFor(id).ToString()); // output: m =&gt; (True AndAlso (m.key == value(ConsoleApplication2.Bar`1+&lt;&gt;c__DisplayClass0[ConsoleApplication2.Model]).id)) Console.ReadKey(); var subworkitems = barModel.list.Where(barModel.subFor(id).Compile()); // Exception {"variable 'm' of type 'ConsoleApplication2.Model' referenced from scope '', but it is not defined"} Console.WriteLine(subworkitems.ToString()); Console.ReadKey(); } } class Bar&lt;TModel&gt; { public Bar(Expression&lt;Func&lt;TModel, string&gt;&gt; foreignKeyExpression) { _foreignKeyExpression = foreignKeyExpression; } private Expression&lt;Func&lt;TModel, string&gt;&gt; _foreignKeyExpression { get; set; } public Expression&lt;Func&lt;TModel, bool&gt;&gt; subFor(string id) { var ex = forTargetId(id); return ex; } public Expression&lt;Func&lt;TModel, bool&gt;&gt; forTargetId(String id) { var fc = _foreignKeyExpression; Expression&lt;Func&lt;TModel, bool&gt;&gt; predicate = m =&gt; true; var result = predicate.And(m =&gt; fc.Invoke(m) == id).Expand(); return result; } } class Model { public string key; public string value; } class BarModel : Bar&lt;Model&gt; { public List&lt;Model&gt; list; public BarModel() : base(m =&gt; m.key) { list = new List&lt;Model&gt;(); } } } </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