title: binding an Expression<Func> selector to a linq query
body: <p>I am using a library that converts linq expressions into event queries. (streaminsight).</p>
  
  <p>I need solve this problem:</p>
  
  <p>Given some values, and an expression that combines values.</p>
  
  <pre><code>var a = new[] { "a", "b", "c" };
  var b = new[] { "x", "y", "z" };
  Expression&lt;Func&lt;string, string, string&gt;&gt; combine = (x, y) =&gt; x + ":" + y;
  </code></pre>
  
  <p>I need to bind the combine function to the following query whilst still maintaining the expression syntax.</p>
  
  <pre><code>var query =
      from f in a
      from g in b
      select combine(f, g);
  
  query.Dump();
  </code></pre>
  
  <p>Unfortunately the target application for this linq statement does not support <code>Func&lt;string, string, string&gt;</code> in it's raw format because the query is interpreted at runtime.</p>
  
  <p>I get this error: <strong>Additional information: The following expression is not supported by Microsoft Complex Event Processing LINQ provider: 'Invoke(value(System.Func`3...</strong></p>
  
  <p>I think I will solve the problem if I can reproduce the expression as it would have been with:</p>
  
  <pre><code>var query =
      from f in a
      from g in b
      select x + ":" + y;
  </code></pre>
  
  <p>I want to pass the select part of the query into a function as an <code>Expression&lt;Func&lt;...</code> argument.</p>
  
  <p>I tried this, which obviously doesn't quite work:</p>
  
  <pre><code>var query =
      a.SelectMany(a1 =&gt; b, (x, y) =&gt; new { x, y })
       .Select(_ =&gt; combine(_.x, _.y));
  </code></pre>
  
  <p>I have simplified this question, but for reference, the real query looks like this:</p>
  
  <pre><code>        var ms =
              requestStream
                  .AlterEventLifetime(
                      _ =&gt; _.StartTime - TimeSpan.FromMilliseconds(10000),
                      _ =&gt; _.EndTime + TimeSpan.FromMilliseconds(10000) - _.StartTime)
                  .SelectMany(requestData =&gt; responseStream
                      .AlterEventLifetime(
                          _ =&gt; _.StartTime - TimeSpan.FromMilliseconds(10000),
                          _ =&gt; _.EndTime + TimeSpan.FromMilliseconds(10000) - _.StartTime),
                      (requestData, responseData) =&gt; new {requestData, responseData})
                  .Where(@t =&gt; @t.requestData.CorrelationTicketId == @t.responseData.CorrelationTicketId)
                  .Where(@t =&gt; @t.requestData.CorrelationTicketId &gt; 0
                               &amp;&amp; @t.requestData.SuccessFailureCode != 3001)
                  .Select(@t =&gt; expression(@t.requestData, @t.responseData));
  </code></pre>