title: ASP.NET - Advanced Where-Clause in LinqDataSource
body: <p>I have two tables:</p>
  
  <ol>
  <li>Orders </li>
  <li>OrderProducts - An order can have 1 to many orderProducts records associated with it.</li>
  </ol>
  
  <p>What I am trying to do (unsuccessfully) is to implement a GridView search using a LinqDataSource wherein the search returns Order results where any of the OrderProduct.Manufacturer columns contain a search query.</p>
  
  <p>I was hoping the following would work, however it seems lambda expressions do not work within a Where clause of a LinqDataSource (in VB):</p>
  
  <pre><code>    &lt;asp:LinqDataSource ID="dsOrders" runat="server" ContextTypeName="myDataContext" TableName="orders"
          Where="orderProducts.Any(Function(op) op.Manufacturer.Contains(@searchTerm))"&gt;
          &lt;WhereParameters&gt;
              &lt;asp:ControlParameter Name="searchTerm" ControlID="txtSearchTerm" DefaultValue="" /&gt;
          &lt;/WhereParameters&gt;
      &lt;/asp:LinqDataSource&gt;
  </code></pre>
  
  <p>In C# it would look like:</p>
  
  <pre><code>   &lt;asp:LinqDataSource ID="dsOrders" runat="server" ContextTypeName="myDataContext" TableName="orders"
          Where="orderProducts.Any(op =&gt; op.Manufacturer.Contains(@searchTerm))"&gt;
          &lt;WhereParameters&gt;
              &lt;asp:ControlParameter Name="searchTerm" ControlID="txtSearchTerm" DefaultValue="" /&gt;
          &lt;/WhereParameters&gt;
      &lt;/asp:LinqDataSource&gt;
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <blockquote>
    <p>No property or field 'op' exists in
    type 'orderProduct'</p>
  </blockquote>
  
  <p>Any clues as to how to get this working within the LinqDataSource definition, or will I have to handle and set up a custom OnSelecting event?</p>