title: Implementing service queryables: IQueryable to IEnumerable and back
body: <p>In RIA Services (and probably other frameworks such as WCF Data Services) one can implement data services methods by supplying methods returning an IQuerably. For example:</p>
  
  <pre><code>IQueryable&lt;Customer&gt; GetCustomers()
  {
      return this.DbContext.Customers.Where(c =&gt; !c.IsDeleted);
  }
  </code></pre>
  
  <p>A query from the client can then supply an additional filter (among other things). Both the client-provided filter and the filter for returning only undeleted customers will be combined an sent to the database in SQL by entity framework (or whatever ORM is used).</p>
  
  <p>Often entity framework isn't powerful enough to express the query one wants to write, in which case we have to go to linq to objects:</p>
  
  <pre><code>IQueryable&lt;CustomerWithFluff&gt; GetCustomers()
  {
      var customers =
          this.DbContext.Customers
          .Include("FluffBits")
          .Where(c =&gt; !c.IsDeleted)
          .ToList();
  
      return
          from c in customers
          select new CustomerWithFluff()
          {
              CustomerName = c.Name,
              ComplexFluff = String.Join(", ", from b in c.FluffBits select b.FluffText)
          };
  }
  </code></pre>
  
  <p>The sql to the database will now still contain the restriction on "IsDeleted", but not any further filter provided by a client: Those will be applied on the linq to objects level after all the data has already been fetched.</p>
  
  <p>If I don't care to let the client filter on any of the data that I need to compose with linq-to-objects (only "ComplexFluff" in this example), is there a way to still allow filtering on the properties that are simply projected (only "CustomerName" in this example)?</p>