title: .NET Repository pattern generic Query Methodology
body: <p>I am using Repository pattern and i have a base repository and i use Entity Framework and web api;
  my question is I want to allow my clients to be able to query any data dynamically; something like query expressions and fetch xml used in Dynamics CRM;
  I tried specification pattern but it isn't enough as i want to allow client code to order data with different columns e.g. Name asc Address desc and also, allow pagination on the returned result;so my method requirements are</p>
  
  <ol>
  <li>Generic Filter that doesn't depend on ORM technology as i may
  change Entity Framework in the future</li>
  <li>Generic Sorting methodology; allow multiple sort columns e.g.
  Name asc Address desc</li>
  <li>The Client determine the returned columns or all columns e.g.
  columnSet to be "Address, Name and Id" or returned the entire record</li>
  <li>Allow Pagination e.g. Page Index and Page Size</li>
  <li>Support threshold on the number of returned records as large
  result may affect performance</li>
  </ol>
  
  <p>this is my initial method but i don't know if it is better or not</p>
  
  <pre><code>IList&lt;TEntity&gt; AllMatching(ISpecification&lt;TEntity&gt; specification = null,
                  Func&lt;IQueryable&lt;TEntity&gt;, IOrderedQueryable&lt;TEntity&gt;&gt; orderBy = null,
                  IList&lt;Expression&lt;Func&lt;TEntity, object&gt;&gt;&gt; includes = null,
                  int? pageIndex = null, int? pageCount = null);
  </code></pre>